Konkáv tesszaláció

Top  Previous  Next

 GLdouble rect[4][3] = {50.0, 50.0, 0.0,

                        200.0, 50.0, 0.0,

                        200.0, 200.0, 0.0,

                        50.0, 200.0, 0.0};

 GLdouble tri[3][3] = {75.0, 75.0, 0.0,

                       125.0, 175.0, 0.0,

                       175.0, 75.0, 0.0};

 GLdouble star[5][6] = {250.0, 50.0, 0.0, 1.0, 0.0, 1.0,

                        325.0, 200.0, 0.0, 1.0, 1.0, 0.0,

                        400.0, 50.0, 0.0, 0.0, 1.0, 1.0,

                        250.0, 150.0, 0.0, 1.0, 0.0, 0.0,

                        400.0, 150.0, 0.0, 0.0, 1.0, 0.0};

 

 startList = glGenLists(2);

 tobj = gluNewTess();

 gluTessCallback(tobj, GLU_TESS_VERTEX,

                 (GLvoid (*) ()) &glVertex3dv);

 gluTessCallback(tobj, GLU_TESS_BEGIN,

                 (GLvoid (*) ()) &beginCallback);

 gluTessCallback(tobj, GLU_TESS_END,

                 (GLvoid (*) ()) &endCallback);

 gluTessCallback(tobj, GLU_TESS_ERROR,

                 (GLvoid (*) ()) &errorCallback);

 

 glNewList(startList, GL_COMPILE);

 glShadeModel(GL_FLAT);

 gluTessBeginPolygon(tobj, NULL);

    gluTessBeginContour(tobj);

       gluTessVertex(tobj, rect[0], rect[0]);

       gluTessVertex(tobj, rect[1], rect[1]);

       gluTessVertex(tobj, rect[2], rect[2]);

       gluTessVertex(tobj, rect[3], rect[3]);

    gluTessEndContour(tobj);

    gluTessBeginContour(tobj);

       gluTessVertex(tobj, tri[0], tri[0]);

       gluTessVertex(tobj, tri[1], tri[1]);

       gluTessVertex(tobj, tri[2], tri[2]);

    gluTessEndContour(tobj);

 gluTessEndPolygon(tobj);

 glEndList();

 

 gluTessCallback(tobj, GLU_TESS_VERTEX,

                 (GLvoid (*) ()) &vertexCallback);

 gluTessCallback(tobj, GLU_TESS_BEGIN,

                 (GLvoid (*) ()) &beginCallback);

 gluTessCallback(tobj, GLU_TESS_END,

                 (GLvoid (*) ()) &endCallback);

 gluTessCallback(tobj, GLU_TESS_ERROR,

                 (GLvoid (*) ()) &errorCallback);

 gluTessCallback(tobj, GLU_TESS_COMBINE,

                 (GLvoid (*) ()) &combineCallback);

 

 glNewList(startList + 1, GL_COMPILE);

 glShadeModel(GL_SMOOTH);

 gluTessProperty(tobj, GLU_TESS_WINDING_RULE,

                 GLU_TESS_WINDING_POSITIVE);

 gluTessBeginPolygon(tobj, NULL);

    gluTessBeginContour(tobj);

       gluTessVertex(tobj, star[0], star[0]);

       gluTessVertex(tobj, star[1], star[1]);

       gluTessVertex(tobj, star[2], star[2]);

       gluTessVertex(tobj, star[3], star[3]);

       gluTessVertex(tobj, star[4], star[4]);

    gluTessEndContour(tobj);

 gluTessEndPolygon(tobj);

 glEndList();