View Full Version : Drawing concave polygons

05-02-2007, 08:44 AM

I'm looking for example of drawing concave polygons (in FILL mode).

Of course one of the solutions is to divide the original polygon in triangles, but is there any OpenGL alternative?

I heard it can be done with the stencil buffer. Is there any sample code?

Thanks in andvance

05-02-2007, 09:05 AM
OpenGL redbook describes very well about drawing concave polygon using stencil buffer.

Here is my example using stencil buffer, drawing 3 non-convex polygons;
1. simple concave quad.
2. a polygon with a hole in it.
3. self intersected polygon.
It works #1 and #2 cases except #3.
stencilTess.zip (http://www.songho.ca/opengl/files/stencilTess.zip)

Also, check out OpenGL Tessellator (http://www.songho.ca/opengl/gl_tessellation.html) , too.

05-03-2007, 06:16 AM
Thanks a lot
(How simply it was! :) )