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(); } }
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); }
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); }
internal static void Initialize() { GLWrapper.Initialize(); GLWrapper.InitializeCache(); Resize(); }
public static void ResetGLStateCache() { GLWrapper.InitializeCache(); }
public static void Clear(Vector4?color, float?depth = null, int?stencil = null) { GLWrapper.Clear(RenderTarget, color, depth, stencil); }
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())); }