PDA

View Full Version : Tessellation with MFC



BillJ
07-27-2001, 11:19 AM
I can run this code snip with GLUT and Win32 but when going to MFC the compiler comes up with with the following errors.

I have no problems running anything other OpenGL code in MFC.

GLUtesselator *tobj;

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

MFC compiler errors ???????????? what to do to fix this ??????????????????????

'gluTessCallback' : cannot convert parameter 3 from 'void (const double *)' to 'void (__stdcall *)(void)'
None of the functions with this name in scope match the target type
'gluTessCallback' : cannot convert parameter 3 from 'void (unsigned int)' to 'void (__stdcall *)(void)'
None of the functions with this name in scope match the target type

mikael_aronsson
07-27-2001, 02:16 PM
Hmmm, not much OpenGL in this, but ok.

Is it maybe possible that your glut code was in .c files ?

C++ is much more picky with correct types being used, the function you try to use as a callback is not the same type as the one expected by the gluFunctions.

When you declare a function in C++ is will be a "C++" function, this is not compatible with a "C" function.

To solve this you need to put an extern "C" in front of your function definition.

__stdcall defines how the function is called, argument order, name prefix and so on.

To have a function defined as an stdcall function you define it like this:

void __stdcall myFunction( blabla)
{
}

I hope that helps a bit.

Mikael