Exemple #1
0
 public static void DrawIndexed(PrimitiveType primitiveType, Shader shader, VertexBuffer vertexBuffer, IndexBuffer indexBuffer, int startIndex, int indicesCount)
 {
     VerifyParametersDrawIndexed(primitiveType, shader, vertexBuffer, indexBuffer, startIndex, indicesCount);
     GLWrapper.ApplyRenderTarget(RenderTarget);
     GLWrapper.ApplyViewportScissor(Viewport, ScissorRectangle, RasterizerState.ScissorTestEnable);
     GLWrapper.ApplyShaderAndBuffers(shader, vertexBuffer.VertexDeclaration, IntPtr.Zero, vertexBuffer.m_buffer, indexBuffer.m_buffer);
     GLWrapper.ApplyRasterizerState(RasterizerState);
     GLWrapper.ApplyDepthStencilState(DepthStencilState);
     GLWrapper.ApplyBlendState(BlendState);
     GL.DrawElements(GLWrapper.TranslatePrimitiveType(primitiveType), indicesCount, GLWrapper.TranslateIndexFormat(indexBuffer.IndexFormat), new IntPtr(startIndex * indexBuffer.IndexFormat.GetSize()));
 }
Exemple #2
0
 public static void Draw(PrimitiveType primitiveType, Shader shader, VertexBuffer vertexBuffer, int startVertex, int verticesCount)
 {
     VerifyParametersDraw(primitiveType, shader, vertexBuffer, startVertex, verticesCount);
     GLWrapper.ApplyRenderTarget(RenderTarget);
     GLWrapper.ApplyViewportScissor(Viewport, ScissorRectangle, RasterizerState.ScissorTestEnable);
     GLWrapper.ApplyShaderAndBuffers(shader, vertexBuffer.VertexDeclaration, IntPtr.Zero, vertexBuffer.m_buffer, null);
     GLWrapper.ApplyRasterizerState(RasterizerState);
     GLWrapper.ApplyDepthStencilState(DepthStencilState);
     GLWrapper.ApplyBlendState(BlendState);
     GL.DrawArrays(GLWrapper.TranslatePrimitiveType(primitiveType), startVertex, verticesCount);
 }
Exemple #3
0
        public static void DrawUser <T>(PrimitiveType primitiveType, Shader shader, VertexDeclaration vertexDeclaration, T[] vertexData, int startVertex, int verticesCount) where T : struct
        {
            VerifyParametersDrawUser(primitiveType, shader, vertexDeclaration, vertexData, startVertex, verticesCount);
            GCHandle gCHandle = GCHandle.Alloc(vertexData, GCHandleType.Pinned);

            try
            {
                GLWrapper.ApplyRenderTarget(RenderTarget);
                GLWrapper.ApplyViewportScissor(Viewport, ScissorRectangle, RasterizerState.ScissorTestEnable);
                GLWrapper.ApplyShaderAndBuffers(shader, vertexDeclaration, gCHandle.AddrOfPinnedObject() + startVertex * vertexDeclaration.VertexStride, 0, null);
                GLWrapper.ApplyRasterizerState(RasterizerState);
                GLWrapper.ApplyDepthStencilState(DepthStencilState);
                GLWrapper.ApplyBlendState(BlendState);
                GL.DrawArrays(GLWrapper.TranslatePrimitiveType(primitiveType), startVertex, verticesCount);
            }
            finally
            {
                gCHandle.Free();
            }
        }
Exemple #4
0
        public static void DrawUserIndexed <T>(PrimitiveType primitiveType, Shader shader, VertexDeclaration vertexDeclaration, T[] vertexData, int startVertex, int verticesCount, ushort[] indexData, int startIndex, int indicesCount) where T : struct
        {
            VerifyParametersDrawUserIndexed(primitiveType, shader, vertexDeclaration, vertexData, startVertex, verticesCount, indexData, startIndex, indicesCount);
            GCHandle gCHandle  = GCHandle.Alloc(vertexData, GCHandleType.Pinned);
            GCHandle gCHandle2 = GCHandle.Alloc(indexData, GCHandleType.Pinned);

            try
            {
                GLWrapper.ApplyRenderTarget(RenderTarget);
                GLWrapper.ApplyViewportScissor(Viewport, ScissorRectangle, RasterizerState.ScissorTestEnable);
                GLWrapper.ApplyShaderAndBuffers(shader, vertexDeclaration, gCHandle.AddrOfPinnedObject(), 0, 0);
                GLWrapper.ApplyRasterizerState(RasterizerState);
                GLWrapper.ApplyDepthStencilState(DepthStencilState);
                GLWrapper.ApplyBlendState(BlendState);
                GL.DrawElements(GLWrapper.TranslatePrimitiveType(primitiveType), indicesCount, All.UnsignedShort, gCHandle2.AddrOfPinnedObject() + 2 * startIndex);
            }
            finally
            {
                gCHandle.Free();
                gCHandle2.Free();
            }
        }