Hi Guys,

I am trying to draw a polygon, which is essentially like a upside down “L”, if I use GL_POINTS they are in the right place, but when I use GL_POLYGON I get a different shape???

The problem is around 4,5,6. Any got any ideaS???



glVertex3f(-1.75f,0.05f,0.0f); //1
glVertex3f(-0.75f,0.05f,0.0f); //2
glVertex3f(-0.75f,-0.15f,0.0f); //3
glVertex3f(-0.85f,-0.15f,0.0f); //4
glVertex3f(-0.85f,-0.05f,0.0f); //5
glVertex3f(-1.75f,-0.05f,0.0f); //6

The problem is that “L” shape is a concave polygon, but OpenGL accepts only convex polygons.

You may tessellate it into a convex polygon by using GLU tessellattor, or may try the stencil trick.

The redbook(OpenGL programming Guide) describes both methods very well. Please look at “Drawing Filled, Polygons Using the Stencil Buffer” section especially for the stencil trick.

Righto - sounds good. Thanks!

Or simply split your “L” to 2 convex polygons (rectangles) “|” and “_”.

Originally posted by glome:
Or simply split your “L” to 2 convex polygons (rectangles) “|” and “_”.
…but watch out for T-junctions…