a polygon drawing problem

I have encountered a strange problem when I was drawing a polygon having 7 vertices. The problem is that when one of the interior angle of the polygon is greater than 180 degrees, the polygon is not correctly drawn at that vertex. The code which I used to draw polygon is below;

glBegin(GL_POLYGON);
glVertex3f(-22.60,0,0);
glVertex3f(-22.60,0,40.49);
glVertex3f(-50,0,40.49);
glVertex3f(-50,0,100);
glVertex3f(50,0,100);
glVertex3f(50,0,27.80);
glVertex3f(24.57,0,0);
glEnd();
The second vertex causes this problem.

Does it mean that I always have to draw polygons that have interior angles smaller than 180 degrees?
If so, is there another way to draw these kind of polygons?

Yes, as far as I’m aware, OGL requires your polygons to be convex, not concave. Any angle over 180 would make a polygon concave.

You can easily overcome this simply by splitting your polygons down into smaller triangles. That way, they’ll all be convex.

Dan.

kazmalak,
You may try tessellator in GLU library.
Please look at OpenGL FAQ 4.040 .

GLU provides tessellation routines to let you render concave polygons, self-intersecting polygons, and polygons with holes.