What could be a reason when tesselation is not working?
It’s not drawing anything.
Here is my source code (the relevant part of it)
I’m calling DrawTessPolys in my main drawing loop
Am I missing something?
Thanks a lot in advance
void CALLBACK TessBegin_P(GLenum en);
void CALLBACK TessEnd_P();
void CALLBACK TessError_P(GLenum err);
void CALLBACK TessVertex_P(const GLvoid *data);
void GenTessPolys();
void DrawTessPolys();
void FreeTessPolys();
GLUtesselator *tess;
//-----------------------------------------------------------------------------
void GenTessPolys()
{
// create polygons
///…
tess = gluNewTess(); // create a tessellator
if(!tess) return;
// register callback functions
gluTessCallback(tess,GLU_TESS_BEGIN, (void (CALLBACK *)())TessBegin_P);
gluTessCallback(tess,GLU_TESS_END, (void (CALLBACK *)())TessEnd_P);
gluTessCallback(tess,GLU_TESS_ERROR, (void (CALLBACK *)())TessError_P);
gluTessCallback(tess,GLU_TESS_VERTEX, (void (CALLBACK *)())TessVertex_P);
}
//-----------------------------------------------------------------------------
void DrawTessPolys()
{
double vertex[3];
glColor3f(0.55,0.55,0.55);
glNormal3f(0.0,1.0,0.0);
for (int i = 0; i < NumPolys;i++)
{
if( polys[i].NumVer < 5) continue;
gluTessBeginPolygon(tess, 0); // with NULL data
gluTessBeginContour(tess);
for(int ii = 0;ii < polys[i].NumVer;ii++)
{
vertex[0] = polys[i].ver[ii].X;
vertex[1] = polys[i].ver[ii].Y + polys[i].Height;
vertex[2] = polys[i].ver[ii].Z;
gluTessVertex(tess,vertex,vertex);
}
gluTessEndContour(tess);
gluTessEndPolygon(tess);
}
}
//-----------------------------------------------------------------------------
void FreeTessPolys()
{
// … free other memory
//…
gluDeleteTess(tess); // delete after tessellation
}
//-----------------------------------------------------------------------------
void CALLBACK TessBegin_P(GLenum en)
{
glBegin(en);
}
//-----------------------------------------------------------------------------
void CALLBACK TessEnd_P()
{
glEnd();
}
//-----------------------------------------------------------------------------
void CALLBACK TessError_P(GLenum err)
{
const GLubyte *errorStr;
errorStr = gluErrorString(err);
}
//-----------------------------------------------------------------------------
void CALLBACK TessVertex_P(const GLvoid *data)
{
// cast back to double type
const GLdouble ptr = (const GLdouble)data;
glVertex3dv(ptr);
}
//-----------------------------------------------------------------------------