PDA

View Full Version : Tessellation Question



pseudosig
06-04-2007, 02:01 PM
I need some help with concave polygons. I wrote a program that can take 2d spatial data and create a list of vertices (counter clockwise) to define a contour. In this contouring of my data, I can have either convex or concave polygons... so GL_POLYGON is not an option in the case of a concave polygon (unless I decompose the polygon into convex primitives... which I don't intend to do).

My question is this: How can I most efficiently render these polygon contours which consist of both concave and convex polygons? I would really like to use VBO's, since they're so fast in rendering and my data is large... but it looks like I'm forced to use gluTessCallback but I don't know how to use gluTessCallback with VBO's or vertex arrays (or it's impossible).

Any help is appreciated...
thanks

songho
06-04-2007, 08:05 PM
Yes, you CAN store the tessellated polygon data into VBO or display list.

When tessellation process is done, the tessellator sends the primitive types and vertex data to your callback functions. So, you can record these info into VBO or display list. For example, you can get the primitive type in your GLU_TESS_BEGIN callback, and get vertex coordinates in your GLU_TESS_VERTEX callback.

Here is an example how to record the tessellated polygon data: tessellation.zip (http://www.songho.ca/opengl/files/tessellation.zip)

And, there is a simpler way to do by using stencil buffer. I think this method is very effective and easy. First, store all vertex data into a VBO, and then, draw GL_TRIANGLE_FAN starting from the first vertex to the last vertex into the stencil buffer. (See the detailed instruction in the redbook.)

Here is an example using stencil buffer. Please compare with the previous example:
stencilTess.zip (http://www.songho.ca/opengl/files/stencilTess.zip)

pseudosig
06-05-2007, 07:13 AM
So GLU_TESS_VERTEX gets called back with the new stripped down convex vertices... after the concave polygon vertices have been processed?

pseudosig
06-05-2007, 09:08 AM
I'm assuming GLU_TESS_VERTEX does get called back with the new stripped down convex vertices. Given this, after storing the NEW vertices, how does one know how the new vertices should be rendered (i.e. the union of the new convex polygons construct the original concave polygon, but how do you know when one convex polygon began and another ended from GLU_TESS_VERTEX and therefore when to begin and end each convex polygon?)?

pseudosig
06-05-2007, 10:21 AM
okay, never mind, I figured it out.

Thank you very much... this has been VERY helpful