PDA

View Full Version : Tesselation Callback function with glu



rudi
06-20-2002, 06:47 AM
Hi,
I have problems to compile the gluTessCallback
command under GLU Version 1.3
if I use the callbackfunction with parameters
unequal void. The error message is
ANSI C++ prohibits conversion from
(const GLfloat *) to (...).
Could anyboddy help?

ciao
rudi

06-20-2002, 05:22 PM
The quick and dirty way is to do a typecast. If you do not like that do you have to post some code for further help.

rudi
06-21-2002, 01:59 AM
Hi Zico,
Here one example (similar to examle 11-1 in Open GL Programming Guide Version 1.2 . p.472)

#ifndef CALLBACK
#define CALLLBACK
#endif

GLUtesselator *tobj;

tobj = gluNewTess();

//z.B.call of function errorCallback

gluTessCallback(tobj,GLU_TESS_ERROR,errorCallback) ;


// subroutine

void CALLBACK errorCallback(GLenum errorCode)
{
const GLubyte *estring;
estring = gluErrorString(errorCode);
fprintf(stderr,"Tesselation Error: %s\n",estring);
exit(0);
}

// here an example with implicit
conversion to GLenum

ciao
rudi

06-21-2002, 07:07 PM
Are you sure that your example demonstrtates the problem? No conversions takes place in the callback function. I tried the 11-1 example from the earlier version of the book about OpenGL 1.1. If I try to compile it as C++ code do I have some problem with the last line in this function:



void CALLBACK vertexCallback(GLvoid *vertex)
{
const GLdouble *pointer;

pointer = (GLdouble *) vertex;
glColor3dv(pointer+3);
glVertex3dv( vertex);
}

As mentioned before does a type cast work
glVertex3dv((const GLdouble *) vertex);
the extra varible could also be used
glVertex3dv(pointer );
but the best solution is probably to change the function



void CALLBACK vertexCallback(const GLdouble *vertex)
{
glColor3dv(vertex+3);
glVertex3dv(vertex);
}

rudi
06-28-2002, 01:55 AM
Hi Zico,

Your example work with GLU Version 1.1
There I got only a warning
ANSI C++ prohibits conversion from '()' to '(...)' for the gluTessCallback() call.

The are differences in the glu Versions which could be responsible for the problems


from glu.h Version 1.1

GLUAPI void APIENTRY gluTessCallback(GLUtriangulatorObj *tobj,
GLenum which, void (CALLBACK *fn)() )
from glu.h Version 1.3

void (GLAPIENTRY *_GLUfuncptr)();

GLAPIENTRY gluTessCallback (GLUtesselator *tess, GLenum which, _GLUfuncptr CallBackFunc);

Any Idea?

rudi
06-28-2002, 02:50 AM
Sorry I forgot the typedef command
in the line

typedef void (GLAPIENTRY *_GLUfuncptr)();

06-28-2002, 04:40 AM
Right, I think that I missunderstood your question. If you look at the red book example will you find type casts in the gluTessCallback calls like this:



gluTessCallback(tobj, GLU_TESS_VERTEX,
(GLvoid (CALLBACK*) ()) &vertexCallback);
gluTessCallback(tobj, GLU_TESS_BEGIN,
(GLvoid (CALLBACK*) ()) &beginCallback);
gluTessCallback(tobj, GLU_TESS_END,
(GLvoid (CALLBACK*) ()) &endCallback);
gluTessCallback(tobj, GLU_TESS_ERROR,
(GLvoid (CALLBACK*) ()) &errorCallback);
gluTessCallback(tobj, GLU_TESS_COMBINE,
(GLvoid (CALLBACK*) ()) &combineCallback);

rudi
07-01-2002, 10:39 PM
Thank's Zico! It works.