public unsafe void DrawGeometry(Brush brush, Pen pen, Geometry geometry) { BrushShader shader = brush.GetShaderInternal(geometry); gl.EnableClientState(gl.GL_VERTEX_ARRAY); fixed (Color* colors = shader.Colors) { fixed (TextureCoordinate* texCoords = shader.TextureCoordinates) { if (colors != null) { gl.EnableClientState(gl.GL_COLOR_ARRAY); gl.ColorPointer(4, gl.GL_FLOAT, 0, (IntPtr)colors); } if (texCoords != null && shader.ImageSource != null) { gl.EnableClientState(gl.GL_TEXTURE_COORD_ARRAY); gl.Enable(gl.GL_TEXTURE_2D); gl.BindTexture(gl.GL_TEXTURE_2D, shader.ImageSource.myName); gl.TexCoordPointer(2, gl.GL_FLOAT, 0, (IntPtr)texCoords); } if (shader.Color != null) { Color color = shader.Color.Value; gl.Color4f(color.ScR, color.ScG, color.ScB, color.ScA); } fixed (short* indices = geometry.Indices) { fixed (Point* points = geometry.Points) { gl.VertexPointer(3, gl.GL_FLOAT, 0, (IntPtr)points); if (geometry.Indices != null) gl.DrawElements((uint)geometry.GeometryType, geometry.Indices.Length, gl.GL_UNSIGNED_SHORT, (IntPtr)indices); else gl.DrawArrays((uint)geometry.GeometryType, 0, geometry.Points.Length); } } if (shader.Color != null) gl.Color4f(1, 1, 1, 1); if (texCoords != null && shader.ImageSource != null) gl.Disable(gl.GL_TEXTURE_2D); if (colors != null) gl.DisableClientState(gl.GL_COLOR_ARRAY); } } gl.DisableClientState(gl.GL_VERTEX_ARRAY); }