I've been working with OpenGL and the gluTess functions to creating primitives with holes inside them. Simple enough right? From the red book's tess.c I've modified it to work with C++, VS2005 if that matters, and I'm having major problems.
The problem I have is resulting from the changes from the original tess.c to c++ code, I think.
After debugging, I saw that gluTessVertex is not calling my vertex function so that is why the primitives are never being drawn. Can anyone tell me how I can do this?
I suspect it has something to do with the (GLvoid) casts I have to add to the gluTessCallBack function parameters to eliminate the compile errors. Specifically:Code:GLdouble rec1[3] = {0.0, 0.0, 0.0}; GLdouble rec2[3] = {250.0, 0.0, 0.0}; GLdouble rec3[3] = {250.0, 65.0, 0.0}; GLdouble rec4[3] = {0.0, 65.0, 0.0}; GLdouble win1[3] = {5.0, 5.0, 0.0}; GLdouble win2[3] = {25.0, 5.0, 0.0}; GLdouble win3[3] = {25.0, 25.0, 0.0}; GLdouble win4[3] = {5.0, 25.0, 0}; GLdouble* outer[4] = {rec1, rec2, rec3, rec4}; GLdouble* inner[4] = {win1, win2, win3, win4}; GLvoid tcbBegin(GLenum type) { glBegin(type); } GLvoid tcbVertex(GLvoid *vertex) { glVertex3dv((GLdouble*)vertex); } GLvoid tcbEnd() { glEnd(); } GLvoid combineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut ) { GLdouble *vertex; vertex = (GLdouble *) malloc(3 * sizeof(GLdouble)); vertex[0] = coords[0]; vertex[1] = coords[1]; vertex[2] = coords[2]; *dataOut = vertex; } GLvoid errorCallback(GLenum errorCode) { const GLubyte *estring; estring = gluErrorString(errorCode); fprintf(stderr, "Tessellation Error: %s\n", estring); } //init() wall1 = gluNewTess(); gluTessCallback(wall1, GLU_TESS_VERTEX, (GLvoid)tcbVertex); gluTessCallback(wall1, GLU_TESS_BEGIN, (GLvoid)tcbBegin); gluTessCallback(wall1, GLU_TESS_END, (GLvoid)tcbEnd); gluTessCallback(wall1, GLU_TESS_COMBINE, (GLvoid)combineCallback); gluTessCallback(wall1, GLU_TESS_ERROR, (GLvoid)errorCallback); glShadeModel(GL_FLAT); //display() gluTessNormal(wall1, 0.0, 0.0, 1.0); gluTessProperty(wall1, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD); gluTessBeginPolygon(wall1, NULL); gluTessBeginContour(wall1); for (int i = 0; i < 4; i++) gluTessVertex(wall1, outer[i], outer[i]); gluTessEndContour(wall1); gluTessBeginContour(wall1); for (int i = 0; i < 4; i++) gluTessVertex(wall1, inner[i], inner[i]); gluTessEndContour(wall1); gluTessEndPolygon(wall1);
error C2664: 'gluTessCallback' : cannot convert parameter 3 from 'GLvoid (__cdecl *)(GLvoid *)' to 'void (__stdcall *)(void)'
I dont really understand what __stdcall is. Other than this problem, I cant see anything else wrong with this code. Suggestion?



LinkBack URL
About LinkBacks



