vr1
January 18, 2001, 4:35am
1
Hi! I have encountered compile-time error when I try to use tessellator for concave polygon. Anyone know why is this so?
VC++ 6.0 Compile-time Error:
error C2664: ‘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
part of my code:
glShadeModel(GL_SMOOTH);
glColor3f(0.42f, 0.35f, 0.03f);
GLdouble tess_ver[3];
GLUtesselator* tess;
tess = gluNewTess();
gluTessCallback(tess, GLU_TESS_BEGIN, glBegin);
gluTessCallback(tess, GLU_TESS_VERTEX, glVertex3dv);
gluTessCallback(tess, GLU_TESS_END, glEnd);
gluTessBeginPolygon(tess, NULL);
gluTessBeginContour(tess);
glNormal3f(0.0f, 1.0f, 0.0f);
tess_ver[0] = …
tess_ver[1] = …
tess_ver[2] = …
gluTessVertex(tess, tess_ver, NULL);
gluTessEndContour(tess);
gluEndPolygon(tess);
The error is on the line gluTessCallback(…BEGIN…) and gluTessCallback(…END…)
but not on the line gluTessCallback(…VERTEX…)
Thanks in advance!!!
Eric
January 18, 2001, 5:34am
2
This is how it works:
void APIENTRY TessBeginData(GLenum Type,void *Polygon);
void APIENTRY TessEndData(void *Polygon);
void APIENTRY TessEdgeFlagData(GLboolean Flag,void *Polygon);
void APIENTRY TessVertexData(void *Vertex,void *Polygon);
void APIENTRY TessCombineData(GLdouble Coords[3],void *Vertex[4],GLfloat Weight[4],void **Out,void *Polygon);
void APIENTRY TessErrorData(GLenum Errno,void *Polygon);
void SetTesselator(void)
{
gluTessCallback(myTesselator,GLU_TESS_BEGIN_DATA,(void (__stdcall *) (void)) &TessBeginData);
gluTessCallback(myTesselator,GLU_TESS_END_DATA,(void (__stdcall *) (void)) &TessEndData);
gluTessCallback(myTesselator,GLU_TESS_EDGE_FLAG_DATA,(void (__stdcall *) (void)) &TessEdgeFlagData);
gluTessCallback(myTesselator,GLU_TESS_VERTEX_DATA,(void (__stdcall *) (void)) &TessVertexData);
gluTessCallback(myTesselator,GLU_TESS_COMBINE_DATA,(void (__stdcall *) (void)) &TessCombineData);
gluTessCallback(myTesselator,GLU_TESS_ERROR_DATA,(void (__stdcall *) (void)) &TessErrorData);
}
In your example, try:
gluTessCallback(tess, GLU_TESS_BEGIN, ,(void (__stdcall *) (void)) &glBegin);
gluTessCallback(tess, GLU_TESS_VERTEX, ,(void (__stdcall *) (void)) &glVertex3dv);
gluTessCallback(tess, GLU_TESS_END, ,(void (__stdcall *) (void)) &glEnd);
This is basically a function pointer typecast problem…
Regards.
Eric
[This message has been edited by Eric (edited 01-18-2001).]
vr1
January 18, 2001, 8:37am
3
Thank you very much. However, after trying your suggestion solution, although it can be compiled successfully, the program was abnormally terminated when it runs. Any idea?
Thanks a lot in advance!!
coco
January 18, 2001, 9:15am
4
I think you should remove the ‘&’ from Erics suggestion.