glu tesselation : what's wrong with this code


i wrote this little program juste to test the tesselation with glu

i put a printf in the callback function to view if the result of the tesselation is correct!

#include <GL/glu.h>
#include <stdio.h>

int *i0 = new int;
int *i1 = new int;
int *i2 = new int;
int *i3 = new int;

double v0[3]={0.0,0.0,0.0}, v1[3]={1.0,0.0,0.0}, v2[3]={1.0,1.0,0.0}, v3[3]={0.0,1.0,0.0};

// callback function
void vertex_fn(int *numVert){
	static int i=0;
	printf("face %d, point %d, numvert %d
", i/3, i%3, *numVert);

int main(){
	// Init tessalation
	GLUtesselator *tessobj = gluNewTess();
	gluTessCallback(tessobj, GLU_TESS_EDGE_FLAG, NULL);
	gluTessCallback(tessobj, GLU_TESS_VERTEX, (GLvoid(*)())vertex_fn);
	// Begin tessalation
	gluTessBeginPolygon(tessobj, NULL);
			gluTessVertex(tessobj, v0, i0);
			gluTessVertex(tessobj, v1, i1);
			gluTessVertex(tessobj, v2, i2);
			gluTessVertex(tessobj, v3, i3);

the result of the printf in the callback function is :
face 0, point 0, numvert 0
face 0, point 1, numvert 1
face 0, point 2, numvert 2
face 0, point 0, numvert 3

the callback function is called only 4 times
it should be called 6 times normaly to perform the tessalation!

thanks for help

i have edited the post there were some errors !

please help!

I don’t know any specifics about the tesselation functions, so these are only suggestions:

It looks to me as though your four vertices are all in the same plane? If so, I would assume there is nothing to be gained from adding vertices, which might mean you’re just getting your original four vertices.
I’d suggest moving one vertex in the Z-direction to guarantee that there is a reason to add triangles.

If the callback is supposed to be performed for every edge, then my guess is that you may only be getting 4 edges because you’ve specified a quad, not two separate triangles.

yes you’re probably right
but what i want to do is triangularisation in order to store the data in a .3ds file for example and i can store only triangles in it

i don’t know if it is possible to oblige the tessalator to generate triangles?!