[Plib-users] Tessellation Example
Brought to you by:
sjbaker
From: Peijing <est...@si...> - 2007-09-03 16:11:08
|
Hi, I'm new to plib and I need to create a rectangular polygon with a = triangular hole like this: _______ | | =20 |__/\___| but I do not know how to do this with plibs. I've got some examples from = the opengl redbook and I'm looking for a plib equivalent of it.=20 Could someone enlighten me regarding how to go about doing this or any = online references I can refer to? The opengl code is such: GLUtesselator *tobj; =20 GLdouble rect[4][3] =3D {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] =3D {75.0, 75.0, 0.0, 125.0, 175.0, 0.0, 175.0, 75.0, 0.0}; =20 glClearColor(0.0, 0.0, 0.0, 0.0); startList =3D glGenLists(2); tobj =3D gluNewTess(); gluTessCallback(tobj, GLU_TESS_VERTEX,=20 glVertex3dv); gluTessCallback(tobj, GLU_TESS_BEGIN,=20 beginCallback); gluTessCallback(tobj, GLU_TESS_END,=20 endCallback); gluTessCallback(tobj, GLU_TESS_ERROR,=20 errorCallback); /* rectangle with triangular hole inside */ glNewList(startList, GL_COMPILE); glShadeModel(GL_FLAT); =20 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(); gluDeleteTess(tobj); Any help is appreciated.=20 Thanks, EL |