PDA

View Full Version : How to use Callback fuction in gluTessCallback?



yszhang
02-16-2004, 08:59 PM
Using Visual C++ 6.0, I attempted to compile a tessellation example with texturing. I am using the Visual C++ 6.0 compiler. When it tries to compile a gluTessCallback(tobj, GLU_TESS_VERTEX, (void (CALLBACK *)())Vertex ) statement, I get an error :
"error C2664: 'gluTessCallback' : cannot convert parameter 3 from 'void (void *)' to 'void (__stdcall *)(void)'
None of the functions with this name in scope match the target type"

here,"Vertex" in the statement is a Callback function defined by me:
void CSceneView::Vertex(void *xyz)
{
glTexCoord2dv((double*)xyz + 3);
glVertex3dv((double*)xyz);
}

The same code will compile and run fine using the C compiler. Has anyone encountered this problem? Please help me!

mikael_aronsson
02-16-2004, 11:51 PM
Hi !

Make sure you got all the function declarations correct, you might also need to put an:

extern "C" { ... }

around your callback function.

What the compiler complains about is that it want the callback to be declared __stdcall like:

void __stdcall mycallback()
{
}

Mikael