Jump to content
  • Advertisement
Sign in to follow this  
bassman

glu tesselation callbacks

This topic is 4822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I'm having some troubles with the glu tesselation callbacks. My custom callbacks do not work, glVertex3dv, glBegin and glEnd do. If i just make my callback functions empty, that makes no difference. I can get them to work when using statically allocated arrays. With dynamic allocations, the prog crashes at run time. I am aware that the glTessVertex function takes an adress rather than copying the data. I have got the feeling im missing something, tough.
GLdouble** points = NULL;
GLdouble poly = {{1.0, 1.0, 0.0}, {1.0, -1.0, 0.0}, {-1.0, -1.0, 0.0} {0.0, 0.0, 0.0} {-1.0, 1.0, 0.0}}

GLinit(){
// ....
	points = new GLdouble*[5];
	for(int i=0; i<5; i++){
		points = new GLdouble[3];
		points[0] = poly[0];
		points[1] = poly[1];
		points[2] = poly[2];
	}
// ...
}

typedef void (__stdcall *GluTessCallbackType)();

void tcbVertex(void *data) {}
void tcbBegin() {}
void tcbEnd() {}

void tesselate(){
	GLUtesselator* tess = gluNewTess();
	if (tess == NULL)
		printf("Creation of tesselation object failed.");

	gluTessCallback (tess, GLU_TESS_BEGIN, reinterpret_cast<GluTessCallbackType>(tcbBegin) );
	gluTessCallback (tess, GLU_TESS_VERTEX, reinterpret_cast<GluTessCallbackType>(tcbVertex) );
	gluTessCallback (tess, GLU_TESS_END, reinterpret_cast<GluTessCallbackType>(tcbEnd) );

	gluTessBeginPolygon(tess, NULL);
	gluTessBeginContour(tess);	
	
	for(i=0; i<5; i++)
		gluTessVertex(tess, points, points);
	
	gluTessEndContour(tess);
	gluTessEndPolygon(tess);
	gluDeleteTess(tess);
}


If someone has any suggestions about what might be wrong about my approach, feel free to make'm, as I am totally clueless. Thanks for reading anyway, greets

Share this post


Link to post
Share on other sites
Advertisement
Never mind, I solved it. For those interested:

on windows the callback functions should be declared:

void CALLBACK somefunction(...){
...
}

The CALLBACK is not mentioned in the glu faq as its
platform specific, luckily the all-containing red book
notes it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!