GLUtesselator *tobj;
tobj = gluNewTess();
gm_VertexPtrList = new CPtrList();
int templine;
gluTessCallback(tobj, GLU_TESS_BEGIN, (void (CALLBACK *) ())beginCallback);
gluTessCallback(tobj, GLU_TESS_VERTEX, (void (CALLBACK *) ()) vertexCallback);
gluTessCallback(tobj, GLU_TESS_END, (void (CALLBACK *) ())endCallback);
gluTessCallback(tobj, GLU_TESS_ERROR,(void (CALLBACK *) ())errorCallback);
gluTessCallback(tobj, GLU_TESS_COMBINE, (void (CALLBACK *) ())combineCallback);
glShadeModel(GL_FLAT);
gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO);
gluTessNormal(tobj, 0, 0, 1);
gluTessBeginPolygon(tobj, NULL);
gluTessBeginContour(tobj);
pVertex = new GLdouble[3];
pVertex[0] = XStartpt;
pVertex[1] = YStartpt;
pVertex[2] = 0.0;
gluTessVertex(tobj, pVertex, pVertex);
templine = 1;
noofpts = noofpts - 1;
for(int incvar1 = 0; incvar1 < noofpts; incvar1++)
{
OutlinePoints* outpts = (OutlinePoints*) outlinemacro -> Outline_Points.GetAt(incvar1);
XPoint = (GLfloat) (outpts -> XPoint);
YPoint = (GLfloat) (outpts -> YPoint);
XStartpt = XStart2 + XPoint;
YStartpt = YStart2 + YPoint;
pVertex = new GLdouble[3];
pVertex[0] = XStartpt;
pVertex[1] = YStartpt;
pVertex[2] = 0.0;
gluTessVertex(tobj, pVertex, pVertex);
templine++;
}
gluTessEndContour(tobj);
gluTessEndPolygon(tobj);
gluDeleteTess(tobj);
while( gm_VertexPtrList -> GetCount() > 0 )
{
GLdouble* pV = (GLdouble*)gm_VertexPtrList -> RemoveHead() ;
delete[] pV ;
pV = NULL ;
}
}
glPopMatrix();
delete[] pVertex;
pVertex = NULL;
}
void CALLBACK beginCallback(GLenum which)
{
glBegin(which);
}
void CALLBACK errorCallback(GLenum errorCode)
{
const GLubyte *estring;
estring = gluErrorString(errorCode);
fprintf(stderr, "Tessellation Error: %s\n", estring);
exit(0);
}
void CALLBACK CDocumentationView :: endCallback(void)
{
glEnd();
}
void CALLBACK vertexCallback(GLvoid *vertex)
{
GLdouble *pointer;
pointer = (GLdouble *) vertex;
// glColor3dv(pointer+3);
glVertex3dv(pointer);
}
//static memvar used to keep track of newly allocated vertices
void CALLBACK combineCallback(GLdouble coords[3],
GLdouble *vertex_data[4],
GLfloat weight[4], GLdouble **dataOut )
{
GLdouble *vertex = new GLdouble[3] ;
gm_VertexPtrList->AddTail( vertex ) ; //keep track for later delete[] at bottom of CMFCTessView::OnDraw()
vertex[0] = coords[0];
vertex[1] = coords[1];
vertex[2] = 0.0;
//01/13/05 bugfix
*dataOut = vertex;
}