Beispiel #1
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();
            }
        }
Beispiel #2
0
 public void AllocateBuffer()
 {
     GL.GenBuffers(1, out m_buffer);
     GLWrapper.BindBuffer(All.ArrayBuffer, m_buffer);
     GL.BufferData(All.ArrayBuffer, new IntPtr(VertexDeclaration.VertexStride * VerticesCount), IntPtr.Zero, All.StaticDraw);
 }
Beispiel #3
0
 public void AllocateBuffer()
 {
     GL.GenBuffers(1, out m_buffer);
     GLWrapper.BindBuffer(All.ElementArrayBuffer, m_buffer);
     GL.BufferData(All.ElementArrayBuffer, new IntPtr(IndexFormat.GetSize() * IndicesCount), IntPtr.Zero, All.StaticDraw);
 }
 public void GenerateMipMaps()
 {
     GLWrapper.BindTexture(All.Texture2D, m_texture, forceBind: false);
     GL.GenerateMipmap(All.Texture2D);
 }
Beispiel #5
0
 internal static void Initialize()
 {
     GLWrapper.Initialize();
     GLWrapper.InitializeCache();
     Resize();
 }
Beispiel #6
0
 public static void ResetGLStateCache()
 {
     GLWrapper.InitializeCache();
 }
Beispiel #7
0
 public static void Clear(Vector4?color, float?depth = null, int?stencil = null)
 {
     GLWrapper.Clear(RenderTarget, color, depth, stencil);
 }
Beispiel #8
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()));
 }