示例#1
0
        private void Flush()
        {
            Assert.That(Shader != null);

            unsafe
            {
                fixed(VertexPosition2Color *vertexPtr = &_vertexData[0])
                {
                    _vertexBuffer.SubData <VertexPosition2Color>((IntPtr)vertexPtr, 0, _vertexCount);
                }
            }

            bool prevDepthTest = ParentContext.DepthTest;

            ParentContext.DepthTest = false;

            ParentContext.BindVertexBuffer(_vertexBuffer);
            ParentContext.BindShaderProgram(Shader);

            _vertexBuffer.VertexTypeInfo.Apply(Shader);

            GL.DrawArrays(PrimitiveType.Lines, 0, _vertexCount);

            ParentContext.DepthTest = prevDepthTest;

            // unchecked
            // {
            //     Metrics._drawCalls++;
            //     Metrics._primitiveCount += _count * 6;
            // }

            _vertexCount = 0;
        }
示例#2
0
        private void Flush()
        {
            Assert.That(Shader != null);
            Assert.That(_lastTexture != null);

            unsafe
            {
                fixed(VertexPosition2TextureColor *vertexPtr = &_vertexData[0])
                fixed(ushort *indexPtr = &_indexData[0])
                {
                    //_vertexBuffer.SubData(new Span<VertexPosition2TextureColor>(vertexPtr, _count * 4), 0);
                    _vertexBuffer.SubData <VertexPosition2TextureColor>((IntPtr)vertexPtr, 0, _count * 4);
                    //_indexBuffer.SubData(new Span<ushort>(indexPtr, _count * 6), 0);
                    _indexBuffer.SubData <ushort>((IntPtr)indexPtr, 0, _count * 6);
                }
            }

            ParentContext.BindVertexBuffer(_vertexBuffer);
            ParentContext.BindIndexBuffer(_indexBuffer);
            ParentContext.BindShaderProgram(Shader);
            ParentContext.BindTexture(0, _lastTexture);

            _vertexBuffer.VertexTypeInfo.Apply(Shader);

            bool prevDepthTest = ParentContext.DepthTest;

            ParentContext.DepthTest = false;

            GL.DrawRangeElements(PrimitiveType.Triangles,
                                 0,
                                 _count * 4,
                                 _count * 6,
                                 DrawElementsType.UnsignedShort,
                                 IntPtr.Zero);

            ParentContext.DepthTest = prevDepthTest;

            unchecked
            {
                // Metrics._drawCalls++;
                // Metrics._primitiveCount += _count * 6;
            }

            _count = 0;
        }