PDA

View Full Version : Tesselation & Windows XP



02-21-2004, 07:37 PM
Hi,

I am trying to tesselate the famous "Star Trek" badge:
GLdouble starTrek [4] [2]
= { +0.4, -0.7,
0.0, +0.7,
-0.4, -0.7,
0.0, 0.0 } ;

However, Windows XP reports that my program "has encountered a problem and needs to close" whenever my contour includes more than 2 vertices (although there is no such complaint when the contour is comprised of 2 or fewer vertices).

Any advice you might have would be much-appreciated.

Dana J.

--------- code snippets follow --------

Here are my callbacks:
void CALLBACK beginCallback ( GLenum which )
{
glBegin ( which ) ;
} // end beginCallback

void CALLBACK endCallback ( void )
{
glEnd ( ) ;
} // end endCallback

void CALLBACK errorCallback ( GLenum errorCode )
{
std::cout << "Tessellation error: " << gluErrorString(errorCode) << std::endl ;
} // end errorCallback

(where there is an empty definition for CALLBACK as suggested on page 493 of Red Book for Version 1.4)

Here's how I register callbacks:
typedef void (__stdcall * TessFuncPtr)( );

gluTessCallback ( myTesselator, GLU_TESS_VERTEX, (TessFuncPtr) glVertex2dv ) ;
gluTessCallback ( myTesselator, GLU_TESS_BEGIN, (TessFuncPtr) beginCallback ) ;
gluTessCallback ( myTesselator, GLU_TESS_END, (TessFuncPtr) endCallback ) ;
gluTessCallback ( myTesselator, GLU_TESS_ERROR, (TessFuncPtr) errorCallback ) ;

Here's how I'm creating my display list:
glNewList ( starTrekDisplayList, GL_COMPILE ) ;
gluTessBeginPolygon ( myTesselator, NULL ) ;
gluTessBeginContour ( myTesselator ) ;
gluTessVertex ( myTesselator, starTrek[0], starTrek[0] ) ;
gluTessVertex ( myTesselator, starTrek[1], starTrek[1] ) ;
gluTessVertex ( myTesselator, starTrek[2], starTrek[2] ) ;
gluTessVertex ( myTesselator, starTrek[3], starTrek[3] ) ;
gluTessEndContour ( myTesselator ) ;
gluTessEndPolygon ( myTesselator ) ;
glEndList ( ) ;

And, finally, my display callback:
glClear ( GL_COLOR_BUFFER_BIT ) ;
glCallList ( starTrekDisplayList ) ;
glFlush ( ) ;

ZbuffeR
02-22-2004, 07:07 AM
It may help to learn C before OpenGL http://www.opengl.org/discussion_boards/ubb/smile.gif

Try this :

GLdouble starTrek [4] [2]
= { {+0.4, -0.7},
{ 0.0, +0.7},
{-0.4, -0.7},
{ 0.0, 0.0} } ;

02-22-2004, 12:24 PM
I appreciate your suggestion, ZbuffeR. However, your suggestion (see below) did not work for me:
GLdouble starTrek [4] [2]
= { { +0.4, -0.7 },
{ 0.0, +0.7 },
{ -0.4, -0.7 },
{ 0.0, 0.0 } } ;

My best guess is that somehow an invalid pointer value is being used, causing my program to try to reference a portion of memory that it's not permitted to reference.

Upon re-reading documentation of gluTessVertex, I saw that the second parameter is "GLdouble coords[3]", so I changed my vertices to have 3-dimensional coordinates (see below). That also did not fix my problem.
GLdouble starTrek [4] [3]
= { { +0.4, -0.7, 0.0 },
{ 0.0, +0.7, 0.0 },
{ -0.4, -0.7, 0.0 },
{ 0.0, 0.0, 0.0 } } ;

Of course, I also changed the callback registration:
gluTessCallback ( myTesselator, GLU_TESS_VERTEX, (TessFuncPtr) glVertex3dv ) ;