PDA

View Full Version : Nurbs Callback Error



JonGould
12-21-2000, 02:10 AM
Can anyone tell me how to install the Nurbs callback function correctly?

My code looks like this

GLUnurbsObj *pNurb = NULL;
pNurb = gluNewNurbsRenderer();

// Install error handler to notify user of NURBS errors
gluNurbsCallback(pNurb, GLU_ERROR, &NurbsErrorHandler);


gluNurbsProperty(pNurb, GLU_SAMPLING_TOLERANCE, 25.0);
gluNurbsProperty(pNurb, GLU_DISPLAY_MODE, (GLfloat) GLU_FILL);

gluBeginSurface(pNurb);
gluNurbsSurface(pNurb,
aIndexU+aDegU+2, uKnot,
aIndexV+aDegV+2, vKnot,
8*3,
3,
&ControlPoints[0][0][0],
aIndexU+1,
aIndexV+1,
GL_MAP2_VERTEX_3);
gluEndSurface(pNurb);

....

// NURBS callback error handler
void NurbsErrorHandler(GLenum nErrorCode )
{
char cMessage[64];


// Extract a text message of the error
strcpy(cMessage,"NURBS error occured: ");
strcat(cMessage,gluErrorString((GLenum) nErrorCode));

// Display the message to the user
// MessageBox(NULL,cMessage,NULL,MB_OK | MB_ICONEXCLAMATION);
}

The compile error I get is.

cannot convert parameter 3 from 'void (__cdecl *)(unsigned int)' to 'void (__stdcall *)(void)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast

Thanks in advance.

Eric
12-21-2000, 02:12 AM
Do the following:

// Install error handler to notify user of NURBS errors
gluNurbsCallback(pNurb, GLU_ERROR, (void (__stdcall *) (void)) &NurbsErrorHandler);

That's a function typecast... It took me quite a long time to find how to declare those callbacks properly !

Have fun !

Eric

JonGould
12-21-2000, 03:13 AM
Thanks Eric, thats really helpful.

JonG