Coloring polygons using GL.QUADS


I’m trying to color loops (polygons drawn with GL.QUADS) and it’s only working when the loop has 4 points.

Here’s a screenshot :


When there are 4 points, the loops is fully colored, but when there are more than 4 points, only one part of the loop is colored.

Here’s the function I’ve written :

public void ColorLoop(Loop l){
		// Color loop if closed, bool canColor is true and loops is not inversed
		if (l.isClosed() && l.canColorLoop && !l.isInverse()){ 
			float nearClip = cam.nearClipPlane + 0.00001f;
			Vector2[] points = l.getPoints();

			GL.Begin (GL.QUADS);
			GL.Color (l.getLoopColor());

			for (int i = 0; i < points.Length - 1; i++){
				GL.Vertex(cam.ViewportToWorldPoint(new Vector3(points_.x, points*.y, nearClip)));*_

* }*

* GL.End(); *
* }*
* }*
Any idea on how to color all the loop, even when it has more thant 4 points ?
Thanks !

A quad can only have 4 vertices. That’s what quad means. For more complex shapes draw it using a sequence of triangles, or triangle strip.