• Advertisement
Sign in to follow this  

glu tessellation not working

This topic is 1541 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

I'm trying to render a 2D polygon using glu's tessellation facilities. However I'm not seeing anything.


Here's my code:

        GLUtesselator * tess = gluNewTess();
        gluTessCallback(tess, GLU_TESS_VERTEX,  (GLvoid (*) ()) &poly_vert_callvack);
        gluTessCallback(tess, GLU_TESS_BEGIN,   (GLvoid (*) ()) &poly_begin_callback);
        gluTessCallback(tess, GLU_TESS_END,     (GLvoid (*) ()) &poly_end_callback);
        gluTessCallback(tess, GLU_TESS_ERROR,   (GLvoid (*) ()) &poly_error_callback);
        gluTessCallback(tess, GLU_TESS_COMBINE, (GLvoid (*) ()) &poly_combine_callback);
        gluTessBeginPolygon(tess, NULL);

        for (size_t v = 0; v < _vert.size(); v++)
            GLdouble vert[3] = {(double)_vert[v].X, (double)_vert[v].Y, 0.0};
            gluTessVertex(tess, vert, vert);




Also here are the callback functions:

void poly_begin_callback(GLenum wh)
    void poly_vert_callvack(GLvoid *vertex)
        const GLdouble *pointer;
        pointer = (GLdouble *) vertex;
    void poly_end_callback(void)
    void poly_error_callback(GLenum errorCode)
        const GLubyte *estring;
        estring = gluErrorString(errorCode);
        fprintf (stderr, "Tessellation Error: %s\n", estring);
        exit (0);
    void poly_combine_callback(GLdouble coords[3], 
                               GLdouble *vertex_data[4],
                               GLfloat weight[4], GLdouble **dataOut )
        GLdouble *vertex;
        int i;
        vertex = (GLdouble *) malloc(6 * sizeof(GLdouble));
        vertex[0] = coords[0];
        vertex[1] = coords[1];
        vertex[2] = coords[2];
        for (i = 3; i < 7; i++)
            vertex[i] = weight[0] * vertex_data[0][i] 
            + weight[1] * vertex_data[1][i]
            + weight[2] * vertex_data[2][i] 
            + weight[3] * vertex_data[3][i];
        *dataOut = vertex;

The colour is set at some point before. Anyone see any problems here? Thanks

Edited by Zotoaster

Share this post

Link to post
Share on other sites

Okay I got it fixed. Turns out it stores references to vertices before actually creating them in the 'gluTessEndPolygon()' function. So it was assuming all vertices were the last vertex I gave it. It also wanted 3D vertices which means by polygon class has to have two versions of the vertex list (it could just use the 3d one but then it wouldn't interface well with the rest of the program).

Share this post

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

  • Advertisement