Tessellation Callback Functions


I’m trying to tessellate a shape with the glu library, and I’ve spent the best part of the day trying to get a few lines of code to work:-

GLUtesselation *tobj = gluNewTess();
gluTessCallback(tobj, GLU_TESS_BEGIN, glBegin);
gluTessCallback(tobj, GLU_TESS_VERTEX, glVertex3dv);
gluTessCallback(tobj, GLU_TESS_END, glEnd);

When I try to run this the compiler says that there is an invalid conversion on the third line from void()(unsigned int) to void()() and another on the forth line from void()(void) to void(*)().

I know that most people put their callbacks in seperate functions, but I don’t see any reason for me to do that since I’m using three one-line callbacks. I have tried putting them into functions, but to no avail.

-Can’t understand it. Any help would be very much appreciated.



They decided not to have entry points for all possible flavors of callbacks, so you need to cast all of them to void(CALLBACK*)(void), like
gluTessCallback(tobj, GLU_TESS_VERTEX, (void(CALLBACK*)(void))glVertex3fv).

CALLBACK is defined when you include windows.h (usually defined as __stdcall, but it’s probably a good idea to use the macro just in case).