GLPOLYGONMODE(3G)

πŸ’… GLPOLYGONMODE πŸ’…

okay so bestie, welcome to glPolygonMode from section 3G of the manual β€” yes, that's the OpenGL one, and it is literally the main character of "how do we even draw this polygon, though?" Sit down, this one's fun. πŸŽ€


✨ NAME ✨

glPolygonMode β€” pick a polygon rasterization mode. that's it, that's the vibe check. πŸ¦‹


✨ C SPECIFICATION ✨

void glPolygonMode(GLenum face, GLenum mode);

she takes two args and she takes them seriously. periodt. πŸ’…


✨ PARAMETERS ✨

  • face β€” which polygons the mode applies to. and ngl, it must be GL_FRONT_AND_BACK for front- and back-facing polygons. no other option, the whole face card or nothing. 🫢
  • mode β€” how those polygons get rasterized. accepted values are GL_POINT, GL_LINE, and GL_FILL. the initial value is GL_FILL for both front- and back-facing polygons, which is lowkey the sane default. ⭐

✨ DESCRIPTION ✨

so glPolygonMode controls the interpretation of polygons for rasterization. and face tells it which polygons mode applies to: both front and back-facing polygons (GL_FRONT_AND_BACK). πŸ›

key thing, bestie β€” the polygon mode affects only the final rasterization of polygons. specifically: a polygon's vertices are lit, and the polygon is clipped and possibly culled before these modes are applied. so like, the lighting and clipping pipeline already did its thing by the time this shows up. she's the last stop on the glow-up train. πŸš‚βœ¨

three modes are defined and can be specified in mode:

🌸 GL_POINT

polygon vertices that are marked as the start of a boundary edge are drawn as points. point attributes such as GL_POINT_SIZE and GL_POINT_SMOOTH control the rasterization of the points. and here's the gag: polygon rasterization attributes other than GL_POLYGON_MODE have no effect. πŸ’€

🌸 GL_LINE

boundary edges of the polygon are drawn as line segments. line attributes such as GL_LINE_WIDTH and GL_LINE_SMOOTH control the rasterization of the lines. same deal here: polygon rasterization attributes other than GL_POLYGON_MODE have no effect. 😭

🌸 GL_FILL

the interior of the polygon is filled. polygon attributes such as GL_POLYGON_SMOOTH control the rasterization of the polygon. this is the full-send, filled-in, no-notes version. πŸ”₯


✨ EXAMPLES ✨

want a surface with outlined polygons? iconic, wireframe era, call this:

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

go off. πŸ‘‘


✨ NOTES ✨

vertices are marked as boundary or nonboundary with an edge flag. edge flags are generated internally by the GL when it decomposes triangle stips and fans. (yes, "stips" β€” that's the original's spelling, not me being chaotic for once. πŸ™ˆ)


✨ ERRORS ✨

GL_INVALID_ENUM is generated if either face or mode is not an accepted value. so like, don't just make stuff up. the GL will clock you. πŸ’€


✨ ASSOCIATED GETS ✨

glGet() with argument GL_POLYGON_MODE β€” that's how you check what mood she's in. 🧚


✨ VERSION SUPPORT ✨

the table said glPolygonMode has a βœ” in every single column, and the columns were every OpenGL version from 2.0 all the way through 4.5. so: 2.0 βœ”, 2.1 βœ”, 3.0 βœ”, 3.1 βœ”, 3.2 βœ”, 3.3 βœ”, 4.0 βœ”, 4.1 βœ”, 4.2 βœ”, 4.3 βœ”, 4.4 βœ”, 4.5 βœ”. twelve out of twelve, flawless attendance, never missed a day in her life. πŸŒˆπŸ‘‘

the row was labeled both "Function / Feature Name" β€” that's how the original table had it, and yes glPolygonMode was the one and only function name listed. πŸŽ€

✨ SEE ALSO ✨

  • glLineWidth()
  • glPointSize()

go read those next, they're the supporting cast and they ate. πŸ’–


Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.

(this one's the encore, don't skip it 🫢)

Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group


okay that's the whole page, bestie β€” source line says [FIXME: source] (still a FIXME, we love an unfinished icon 😭) and it's dated 08/09/2021. mwah, go draw some wireframes. πŸ’…πŸ’œ

πŸ“¦ where this page comes from