GLUTESSVERTEX(3G)

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

πŸ’… GLUTESSVERTEX β€” the 3G page, bestie edition πŸŽ€

okay so this is gluTessVertex(3G) from the GLU crew, and it's literally the lil function that tells your tessellator "hey girl, here's a corner of my polygon" ✨


🌸 NAME 🌸

gluTessVertex β€” specify a vertex on a polygon


✨ C SPECIFICATION ✨

void gluTessVertex( GLUtesselator* tess,
                    GLdouble *location,
                    GLvoid* data )

🫢 PARAMETERS 🫢

  • tess β€” the tessellation object you made earlier with gluNewTess. your main character, basically πŸ‘‘
  • location β€” where the vertex actually is in space. its location, iconic of it πŸ’«
  • data β€” an opaque pointer that gets handed right back to your program through the vertex callback (the one you set up with gluTessCallback). like a little note you pass to future-you πŸŽ€

πŸ’– DESCRIPTION πŸ’–

so gluTessVertex describes a vertex on a polygon that your program defines. every time you call it, you're adding another corner. successive gluTessVertex calls describe a closed contour β€” like, a whole loop. wanna describe a quadrilateral? call gluTessVertex four times, boom, done, ate πŸ’…

lowkey important: gluTessVertex can only be called between gluTessBeginContour and gluTessEndContour. no sneaking it in anywhere else, bestie 🚫

and about data β€” normally it points to a structure that holds the vertex location plus all the other per-vertex glow-up details like color and normal. that pointer gets passed back to you through the GLU_TESS_VERTEX or GLU_TESS_VERTEX_DATA callback after tessellation happens (go read the gluTessCallback reference page for the tea, iykyk).


🌈 EXAMPLE 🌈

say you want a quadrilateral with a triangular hole in it. it's giving donut. it's giving very demure. 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);

⚠️ NOTES ⚠️

okay this next part is the part where everyone gets humbled, so listen up fr fr 😭

it is a very common error to use a local variable for location or data and then stuff values into it inside a loop. like this:

for (i = 0; i < NVERTICES; ++i) {
  GLdouble data[3];
  data[0] = vertex[i][0];
  data[1] = vertex[i][1];
  data[2] = vertex[i][2];
  gluTessVertex(tobj, data, data);
  }

this does not work. not a vibe. not it. πŸ’€

here's why: the pointers you hand over as location and data might not get dereferenced until gluTessEndPolygon actually runs. so every single set of vertex coordinates except the very last one can get overwritten before tessellation even begins. your poor little stack variable is living on borrowed time 🫠

two common symptoms of this problem are:

  • the result consists of a single point (this is what you get when a local variable is used for data), and
  • a GLU_TESS_NEED_COMBINE_CALLBACK error (this is what you get when a local variable is used for location).

so yeah. don't do that. allocate properly, bestie 🧚


πŸ‘‘ SEE ALSO πŸ‘‘

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

and that's the whole page, gorgeous πŸ’œ this lil slice of 3G manual realness goes out under the name GLUTESSVERTEX(3G) β€” that's the source/version tag and the date stamp on the footer, so if you ever need to cite it, that's your girl. go tessellate something iconic, ily, bye πŸ¦‹βœ¨

πŸ“¦ where this page comes from