GLUTESSENDPOLYGON(3G)
π GLUTESSENDPOLYGON β delimit a polygon description π
okay bestie, this is a page from the 3G manual (that's the GLU/OpenGL utility library section, iykyk) and it's about closing out a polygon so the tessellator can do its thing. it's giving "wrap it up, we're done here" energy and honestly? iconic.
π C SPECIFICATION π
void gluTessEndPolygon( GLUtesselator* tess )
π«Ά PARAMETERS π«Ά
tessβ this is the tessellation object, bestie. and which tessellation object, you ask? the one you made withgluNewTess. nogluNewTess, notess, no vibes. periodt.
β¨ DESCRIPTION β¨
so gluTessBeginPolygon and gluTessEndPolygon are the little matched set that delimits the definition of a polygon β and like, any polygon. convex? sure. concave? go off. self-intersecting? we love a chaotic main character, it's fine. π
inside every single gluTessBeginPolygon/gluTessEndPolygon pair, you must have one or more calls to gluTessBeginContour/gluTessEndContour. that's not a suggestion, that's the rule. and inside each of those contours, there are zero or more calls to gluTessVertex. zero is genuinely allowed, no judgment. π«Ά
the vertices you hand over specify a closed contour β and the cute little detail here is that the last vertex of each contour is automatically linked to the first one. so don't go closing the loop yourself, the library already did it for you. π
if you want the full lore, go read the gluTessVertex, gluTessBeginContour and gluTessEndContour reference pages β they've got the details.
then, the moment gluTessEndPolygon gets called, the polygon is tessellated, and the resulting triangles are described through callbacks. yes, callbacks β see gluTessCallback for what those callback functions actually do. that's where the triangles come out the other side. π₯
πΈ EXAMPLE πΈ
here's a quadrilateral with a triangular hole punched through it, described like this:
gluTessBeginPolygon(tobj, NULL);
gluTessBeginContour(tobj);
gluTessVertex(tobj, v1, v1);
gluTessVertex(tobj, v2, v2);
gluTessVertex(tobj, v3, v3);
gluTessVertex(tobj, v4, v4);
gluTessEndContour(tobj);
gluTessBeginContour(tobj);
gluTessVertex(tobj, v5, v5);
gluTessVertex(tobj, v6, v6);
gluTessVertex(tobj, v7, v7);
gluTessEndContour(tobj); gluTessEndPolygon(tobj);
β οΈ okay this part is important and it is not a vibe check you can skip: in the above example, the pointersv1throughv7should point to different addresses. why? because the values stored at these addresses will not be read by the tesselator untilgluTessEndPolygonis called. so if you were thinking "eh, I'll reuse the same buffer, it's fine" β no bestie, it is not fine. the tesselator is patient, it's just waiting, and it will read those addresses later. π
π SEE ALSO π
gluNewTess(3G)gluTessBeginContour(3G)gluTessVertex(3G)gluTessCallback(3G)gluTessProperty(3G)gluTessNormal(3G)gluTessBeginPolygon(3G)
and that's the whole page, bestie β this one comes to you straight from the GLUTESSENDPOLYGON(3G) corner of the 3G manual, so go tessellate something gorgeous. π¦β¨π
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- fedora 43: gl-manpages 1.1-34.20190306.fc43 Β· Apache-2.0 AND HPND AND HPND-sell-variant AND MIT AND OpenPBS-2.3 AND SGI-B-2.0 AND W3C-19980720 AND X11
- fedora 44: gl-manpages 1.1-35.20190306.fc44 Β· Apache-2.0 AND HPND AND HPND-sell-variant AND MIT AND OpenPBS-2.3 AND SGI-B-2.0 AND W3C-19980720 AND X11
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms