PDA

View Full Version : Drawing concave polygons



hexa
05-02-2007, 07:44 AM
Hi

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

songho
05-02-2007, 08: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.

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