Hi Guys,
I am currentlly working on the managed c++(VS2008) and Opengl
one part of my code is using gluTessBeginPolygon to draw Polygons.
here is my function to draw polygon
void Display1()
{
GLdouble rect[4][3] = {50.0, 50.0, 0.0,
200.0, 50.0, 0.0,
200.0, 200.0, 0.0,
50.0, 200.0, 0.0};
GLUtesselator* tobj = gluNewTess();
gluTessCallback(tobj, GLU_TESS_BEGIN,(void (CALLBACK*) ()) beginCallback);
gluTessCallback(tobj, GLU_TESS_VERTEX,(void (CALLBACK*) ()) glVertex3dv);
gluTessCallback(tobj, GLU_TESS_END,(void (CALLBACK*) ()) endCallback);
gluTessBeginPolygon(tobj, NULL);
gluTessBeginContour(tobj);
gluTessVertex(tobj, rect[0], rect[0]);
gluTessVertex(tobj, rect[1], rect[1]);
gluTessVertex(tobj, rect[2], rect[2]);
gluTessEndContour(tobj);
gluTessEndPolygon(tobj);
}
static void CALLBACK beginCallback(GLenum which)
{
glBegin(which);
}
static void CALLBACK errorCallback(GLenum errorCode)
{
const GLubyte *estring;
estring = gluErrorString(errorCode);
fprintf(stderr, "Tessellation Error: %s
", estring);
exit(0);
}
static void CALLBACK endCallback(void)
{
glEnd();
}
But when I am debugging at line: gluTessEndPolygon(tobj);
I always get exception:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
does anybody have experience to deal with this problem?