DrawElements() private method

private DrawElements ( uint mode, int count, uint type, IntPtr indices ) : void
mode uint
count int
type uint
indices System.IntPtr
return void
Example #1
0
        public override void Render(RenderEventArgs arg, ShaderProgram shaderProgram)
        {
            IntPtr offset;

            switch (this.Type)
            {
            case IndexElementType.UnsignedByte:
                offset = new IntPtr(this.FirstIndex * sizeof(byte));
                break;

            case IndexElementType.UnsignedShort:
                offset = new IntPtr(this.FirstIndex * sizeof(ushort));
                break;

            case IndexElementType.UnsignedInt:
                offset = new IntPtr(this.FirstIndex * sizeof(uint));
                break;

            default:
                throw new NotImplementedException();
            }
            glBindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.BufferId);
            if (arg.RenderMode == RenderModes.ColorCodedPicking &&
                arg.PickingGeometryType == GeometryType.Point &&
                this.Mode.ToGeometryType() == GeometryType.Line)   // picking point from a line
            {
                // this maybe render points that should not appear.
                // so need to select by another picking
                OpenGL.DrawElements(DrawMode.Points, this.ElementCount, (uint)this.Type, offset);
            }
            else
            {
                OpenGL.DrawElements(this.Mode, this.ElementCount, (uint)this.Type, offset);
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        public override void Render(RenderEventArgs arg)
        {
            int primCount = this.PrimCount;

            if (primCount < 1)
            {
                throw new Exception("error: primCount is less than 1.");
            }

            uint   mode = 0;
            IntPtr offset;

            if (arg.RenderMode == RenderModes.ColorCodedPicking &&
                arg.PickingGeometryType == GeometryType.Point &&
                this.Mode.ToGeometryType() == GeometryType.Line)   // picking point from a line
            {
                // this may render points that should not appear.
                // so need to select by another picking.
                mode = (uint)DrawMode.Points;
            }
            else
            {
                mode = (uint)this.Mode;
            }

            switch (this.Type)
            {
            case IndexElementType.UByte:
                offset = new IntPtr(this.FirstIndex * sizeof(byte));
                break;

            case IndexElementType.UShort:
                offset = new IntPtr(this.FirstIndex * sizeof(ushort));
                break;

            case IndexElementType.UInt:
                offset = new IntPtr(this.FirstIndex * sizeof(uint));
                break;

            default:
                throw new NotImplementedException();
            }

            glBindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.BufferId);
            if (primCount == 1)
            {
                OpenGL.DrawElements(mode, this.ElementCount, (uint)this.Type, offset);
            }
            else
            {
                glDrawElementsInstanced(mode, this.ElementCount, (uint)this.Type, offset, primCount);
            }
            glBindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, 0);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        public override void Render()
        {
            int primCount = this.PrimCount;

            if (primCount < 1)
            {
                throw new Exception("error: primCount is less than 1.");
            }

            uint mode = (uint)this.Mode;

            IntPtr offset;

            switch (this.ElementType)
            {
            case IndexBufferElementType.UByte:
                offset = new IntPtr(this.FirstIndex * sizeof(byte));
                break;

            case IndexBufferElementType.UShort:
                offset = new IntPtr(this.FirstIndex * sizeof(ushort));
                break;

            case IndexBufferElementType.UInt:
                offset = new IntPtr(this.FirstIndex * sizeof(uint));
                break;

            default:
                throw new NotImplementedException();
            }

            if (glBindBuffer == null)
            {
                glBindBuffer = OpenGL.GetDelegateFor <OpenGL.glBindBuffer>();
            }
            glBindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.BufferId);
            if (primCount == 1)
            {
                OpenGL.DrawElements(mode, this.ElementCount, (uint)this.ElementType, offset);
            }
            else
            {
                if (glDrawElementsInstanced == null)
                {
                    glDrawElementsInstanced = OpenGL.GetDelegateFor <OpenGL.glDrawElementsInstanced>();
                }

                glDrawElementsInstanced(mode, this.ElementCount, (uint)this.ElementType, offset, primCount);
            }
            glBindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, 0);
        }