public override void DrawOn3DControl() { if (_isDefaultInstance) { Opacity = 1; OutlineWidth = 0; } List <List <(float x, float y, float z, Color color)> > triData = GetFilteredTriangles() .ConvertAll(tri => new List <(float x, float y, float z, Color color)>() { (tri.X1, tri.Y1, tri.Z1, ColorUtilities.AddAlpha(GetColorForTri(tri, 1), OpacityByte)), (tri.X2, tri.Y2, tri.Z2, ColorUtilities.AddAlpha(GetColorForTri(tri, 2), OpacityByte)), (tri.X3, tri.Y3, tri.Z3, ColorUtilities.AddAlpha(GetColorForTri(tri, 3), OpacityByte)), }); Map3DVertex[] vertexArray = triData.SelectMany(vertexList => vertexList).ToList() .ConvertAll(vertex => new Map3DVertex(new Vector3( vertex.x, vertex.y, vertex.z), vertex.color)).ToArray(); List <Map3DVertex[]> vertexArray2 = triData.ConvertAll( vertexList => vertexList.ConvertAll(vertex => new Map3DVertex(new Vector3( vertex.x, vertex.y, vertex.z), OutlineColor)).ToArray()); Matrix4 viewMatrix = GetModelMatrix() * Config.Map3DCamera.Matrix; GL.UniformMatrix4(Config.Map3DGraphics.GLUniformView, false, ref viewMatrix); int buffer1 = GL.GenBuffer(); GL.BindTexture(TextureTarget.Texture2D, MapUtilities.WhiteTexture); GL.BindBuffer(BufferTarget.ArrayBuffer, buffer1); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertexArray.Length * Map3DVertex.Size), vertexArray, BufferUsageHint.DynamicDraw); Config.Map3DGraphics.BindVertices(); GL.DrawArrays(PrimitiveType.Triangles, 0, vertexArray.Length); GL.DeleteBuffer(buffer1); if (OutlineWidth != 0) { vertexArray2.ForEach(vertexes => { int buffer2 = GL.GenBuffer(); GL.BindTexture(TextureTarget.Texture2D, MapUtilities.WhiteTexture); GL.BindBuffer(BufferTarget.ArrayBuffer, buffer2); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertexes.Length * Map3DVertex.Size), vertexes, BufferUsageHint.DynamicDraw); GL.LineWidth(OutlineWidth); Config.Map3DGraphics.BindVertices(); GL.DrawArrays(PrimitiveType.LineLoop, 0, vertexes.Length); GL.DeleteBuffer(buffer2); }); } }