Accessing the tessallated vertices

HI All,

I’m using the GLU for tessallating the polygons. My problem is that i want to use VBO to increase performance in my application.
I’m initializing the VBO and getting the vertices from the tessallator callback functions as

void CALLBACK vertexCallback(GLvoid *vertex)

if(i == 2)
	i = 0;

pointer = (GLdouble *) vertex;
ver[vertex_count][i] = pointer;
ver[vertex_count][2] = 0;


and then loading this data to VBO. but geometry of the polygon is not coming exact. Am i accessing the vertices in callback function in a wrong way?

or is there any mechanism for using VBO with GLUtess. I dont have any other options but to use GLU TESS only.

PS: whenever the callback function called it generates only single vertex. how to use this vertex data to draw the exact geometry as tess. I’m also using the same drawing mode as tess i.e. GL_TRIANGLE_STRIP


I had already posted a reply to your other thread, but I now understand that you are unable to use the GPU to do tessellation.

GLU tessellation will be horribly slow because each tessellated vertex will produce a call through a function pointer, and the tessellation will almost certainly be done on the CPU. If you can find a way, I would strongly suggest using the GPU (via AMD_vertex_shader_tessellator, Geometry Shaders or some other method). However, if this must be a GLU based solution, I can see a few issues with your implementation.

  1. You haven’t included your GLU_TESS_BEGIN or GLU_TESS_END callbacks in your example.
  2. You are storing pointers, which is probably not what you need to do. You should store the data, so you have
vec[vertex_count][0] = pointer[0];
vec[vertex_count][1] = pointer[1];
vec[vertex_count][2] = pointer[2];
  1. It looks like you’re using a 2-dimensional array to store the data. If you put that straight into the VBO, it may not do what you want. OpenGL VBOs are 1-dimensional arrays. You may want something more like
vec[vertex_count * 3] = pointer[0];
vec[vertex_count * 3 + 1] = pointer[1];
vec[vertex_count * 3 + 2] = pointer[2];
  1. Even this will store doubles. While GL_DOUBLE is an acceptable argument to glVertexPointer, it is highly unlikely that your GPU will be able to fetch the data from the VBO natively, which means that the driver will have to convert the data or worse, fall back to software emulation. Even if your GPU can fetch the double precision data, it will likely do so at a reduced rate. You should probably declare vec as an array of floats and typecast the double data as it comes in from GLU.
  2. The GLU tessellator may break the polygon into several GL_TRIANGLE_STRIPs or other primitive types. You need to record them and then draw them separately. If the primitives are all of the same type, you may be able to use MultiDrawArrays to do this. If they’re different, you’re going to have to use separate draw calls which will eat your performance.

Basically, GLU tessellation was designed to drive immediate mode and really isn’t a great fit for VBO implementation. Even if you can get the data into a VBO and get it to render correctly, I don’t expect you’ll see much of a performance increase because of the way the GLU (may) generate vertices. My advice really, truly is, don’t use GLU tessellation in a new application.

Now, if your limitation is that you must use the CPU (but not necessarily GLU), I would suggest that you write your own CPU-based tessellation functions that pack the VBO data directly.



Thanks Graham for giving such insight about the tessellations, and thanks for showing me right way to store vertex values. Any ways i started looking for cpu based tess algorithms. Can u tell me about any method available for above, Thanks in advance. :slight_smile: