Results 1 to 4 of 4

Thread: glu tesselation : what's wrong with this code

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    14

    glu tesselation : what's wrong with this code

    hello

    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!

    Code :
    #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\n", i/3, i%3, *numVert);
     
    	i++;
    }
     
    int main(){
     
    	*i0=0;
    	*i1=1;
    	*i2=2;
    	*i3=3;
     
     
    	// 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);
     
    		//gluTessNormal(tobj,...);
    		gluTessBeginContour(tessobj);
    			gluTessVertex(tessobj, v0, i0);
    			gluTessVertex(tessobj, v1, i1);
    			gluTessVertex(tessobj, v2, i2);
    			gluTessVertex(tessobj, v3, i3);
    		gluTessEndContour(tessobj);
     
    	gluTessEndPolygon(tessobj);
     
    	gluDeleteTess(tessobj);
    }
    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

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    14

    Re: glu tesselation : what's wrong with this code

    i have edited the post there were some errors !

    please help!

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jan 2004
    Posts
    314

    Re: glu tesselation : what's wrong with this code

    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.

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    14

    Re: glu tesselation : what's wrong with this code

    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?!

Similar Threads

  1. [HELP] something wrong with the code?
    By noobprogrammer89 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-13-2011, 11:59 AM
  2. what is wrong with my code?
    By alexopenglbeginner in forum OpenGL: Windows
    Replies: 1
    Last Post: 09-02-2009, 03:09 PM
  3. what is wrong with this code?
    By openman in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-04-2008, 05:22 AM
  4. what is wrong with this code?
    By openman in forum OpenGL: Linux
    Replies: 1
    Last Post: 08-04-2008, 04:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean