Hi there.
I’m trying to draw a 2D polygon using GL.Line; however I’m not getting a polygon but separated lines instead. In the example below, I would expect a rectangle formed by the spheres:
[52977-screeshot01.png*|52977]
My code is the following:
void OnPostRender( )
{
GL.PushMatrix ( );
mat.SetPass ( 0 );
GL.LoadOrtho( );
GL.Begin( GL.LINES );
GL.Color( Color.white );
for ( int i = 0; i < spheres.Length; i++ )
{
currentVector = Camera.main.WorldToViewportPoint ( spheres*.transform.position );*
-
GL.Vertex3 ( currentVector.x, currentVector.y , 0 );* -
}* -
GL.End();* -
GL.PopMatrix();* -
}*
What am I doing wrong?
Am I supposed to use GL.Vertex for each pair of points (A, B, B, C, C, D, D, A)? As you can see in my code, right now, I’m only calling GL.Vertex for each point (A,B,C,D)
Thanks in advance!