GLUTESSENDPOLYGON(3G)

πŸ“¦ version 1.1, in centos-stream 9, fedora 43, fedora 44

πŸ’… 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 with gluNewTess. no gluNewTess, no tess, 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 pointers v1 through v7 should point to different addresses. why? because the values stored at these addresses will not be read by the tesselator until gluTessEndPolygon is 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