private static void DrawWireOverlay(Mesh meshToRender, RenderTypes renderType, Color color, Action meshChanged = null) { GL.Color4(color.red, color.green, color.blue, color.alpha == 0 ? 255 : color.alpha); GL.Disable(EnableCap.Lighting); GL.DisableClientState(ArrayCap.TextureCoordArray); GLMeshWirePlugin glWireMeshPlugin = null; if (renderType == RenderTypes.Outlines) { glWireMeshPlugin = GLMeshWirePlugin.Get(meshToRender, MathHelper.Tau / 8, meshChanged); } else { glWireMeshPlugin = GLMeshWirePlugin.Get(meshToRender); } GL.EnableClientState(ArrayCap.VertexArray); VectorPOD <WireVertexData> edgeLines = glWireMeshPlugin.EdgeLines; unsafe { fixed(WireVertexData *pv = edgeLines.Array) { GL.VertexPointer(3, VertexPointerType.Float, 0, new IntPtr(pv)); GL.DrawArrays(BeginMode.Lines, 0, edgeLines.Count); } } GL.DisableClientState(ArrayCap.VertexArray); GL.Enable(EnableCap.Lighting); }
private static void DrawWithWireOverlay(Mesh meshToRender, RenderTypes renderType) { GLMeshTrianglePlugin glMeshPlugin = GLMeshTrianglePlugin.Get(meshToRender); GL.Enable(EnableCap.PolygonOffsetFill); GL.PolygonOffset(1, 1); DrawToGL(meshToRender); GL.Color4(0, 0, 0, 255); GL.PolygonOffset(0, 0); GL.Disable(EnableCap.PolygonOffsetFill); GL.Disable(EnableCap.Lighting); GL.DisableClientState(ArrayCap.TextureCoordArray); GLMeshWirePlugin glWireMeshPlugin = null; if (renderType == RenderTypes.Outlines) { glWireMeshPlugin = GLMeshWirePlugin.Get(meshToRender, MathHelper.Tau / 8); } else { glWireMeshPlugin = GLMeshWirePlugin.Get(meshToRender); } VectorPOD <WireVertexData> edegLines = glWireMeshPlugin.edgeLinesData; GL.EnableClientState(ArrayCap.VertexArray); #if true unsafe { fixed(WireVertexData *pv = edegLines.Array) { GL.VertexPointer(3, VertexPointerType.Float, 0, new IntPtr(pv)); GL.DrawArrays(BeginMode.Lines, 0, edegLines.Count); } } #else GL.InterleavedArrays(InterleavedArrayFormat.V3f, 0, edegLines.Array); GL.DrawArrays(BeginMode.Lines, 0, edegLines.Count); #endif GL.DisableClientState(ArrayCap.VertexArray); GL.Enable(EnableCap.Lighting); }