GLUTESSBEGINPOLYGON(3G)

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

πŸ’– GLUTESSBEGINPOLYGON πŸ’–

okay bestie, gather round, because we're about to open up a polygon and it's giving main character energy. this page lives in the 3G manual, so if you see (3G) floating around, that's just its last name. πŸŽ€


✨ NAME ✨

gluTessBeginPolygon β€” delimit a polygon description

like, it draws the little starting line for your polygon's story. that's it, that's the job. πŸ’…


🌸 C SPECIFICATION 🌸

void gluTessBeginPolygon( GLUtesselator* tess,
                          GLvoid* data )

no cap, that's the whole signature. two args, zero drama (until the tessellator does its thing).


πŸ¦‹ PARAMETERS πŸ¦‹

  • tess β€” the tessellation object, babe. you make one with gluNewTess. no tess, no vibes.
  • data β€” a pointer to your user polygon data. it's your data, your rules, your little pocket of per-polygon lore.

πŸ’… DESCRIPTION πŸ’…

so gluTessBeginPolygon and gluTessEndPolygon are the lil bookends that delimit the definition of a polygon β€” and not just any polygon: convex, concave, or self-intersecting. yes, even the messy self-intersecting ones. we don't judge here, we tessellate. ✨

inside every gluTessBeginPolygon/gluTessEndPolygon pair, you must have one or more calls to gluTessBeginContour/gluTessEndContour. not optional, bestie β€” the way that you cannot just rawdog a polygon with no contour is wild. 😭

and inside each contour? zero or more calls to gluTessVertex. the vertices specify a closed contour, meaning the last vertex of each contour is automatically linked to the first β€” the circle of life, but make it geometry. πŸŒ€

if you want the full tea on all of that, go read the gluTessVertex, gluTessBeginContour, and gluTessEndContour reference pages. iykyk. πŸ“š

now, data is a pointer to a user-defined data structure. if you've set up the appropriate callback(s) β€” see gluTessCallback β€” then this pointer gets handed right back to the callback function(s). so it's a convenient lil way to store per-polygon information. basically a little purse you carry around and the callbacks get to peek inside. πŸ‘œβœ¨

once you call gluTessEndPolygon, boom, the polygon is tessellated, and the resulting triangles are described through callbacks. for descriptions of those callback functions, go check gluTessCallback. no guessing, it's all written down.


🌈 EXAMPLE 🌈

say you want a quadrilateral with a triangular hole punched in it. iconic. here's how you'd describe it:

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);

outer quad, inner triangle, hole achieved. ate that fr fr. πŸ’–

side note: yes, the gluTessEndContour(tobj); gluTessEndPolygon(tobj); really is squished onto one line up there. copy it exactly like that and you're golden. πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

  • gluNewTess(3G)
  • gluTessBeginContour(3G)
  • gluTessVertex(3G)
  • gluTessCallback(3G)
  • gluTessProperty(3G)
  • gluTessNormal(3G)
  • gluTessEndPolygon(3G)

aaaand that's the whole page, babe. this lil masterpiece is filed under GLUTESSBEGINPOLYGON(3G) in the 3G manual β€” go off, tessellate something gorgeous, and remember: close your contours. πŸ«ΆπŸŒΈπŸ’œ

πŸ“¦ where this page comes from