- Home /
Question by
balticdefense · Sep 13, 2016 at 06:05 AM ·
c#graphicsdrawinggl
Draw polygon from array of points
How to draw a filled polygon, non convex polygon if I have array of points ? I am drawing Rectangle as ( in OnRenderObject function ):
GL.PushMatrix ();
// Set transformation matrix for drawing to
// match our transform
GL.MultMatrix (transform.localToWorldMatrix);
GL.Begin (GL.QUADS);
GL.Color (new Color (0.0f, 0.2f, 0.0f, 0.4F));
GL.Vertex3 (0, 0, 0);
GL.Vertex3 (0, 0, 1);
GL.Vertex3 (1, 0, 1);
GL.Vertex3 (1, 0, 0);
GL.Color (new Color (0.7f, 0.2f, 0, 0.8F));
GL.Vertex3 (1, 0, 1);
GL.Vertex3 (1, 0, 2);
GL.Vertex3 (2, 0, 2);
GL.Vertex3 (2, 0, 1);
GL.End ();
GL.PopMatrix ();
But how to draw a filled polygon with some color ? ( I managed to draw by doing triangulation of polygon and then draw GL.TRIANGLES but I wonder is there better and quicker solution).
Comment
Answer by Zodiarc · Sep 13, 2016 at 06:59 AM
Look here http://answers.unity3d.com/questions/1241034/procedural-mesh-has-weird-offset.html#answer-1241060
Not applicable. He is not looking to create a mesh, but rather draw a polygon.
But creating a mesh is a way of drawing a filled polygon.