GLFRONTFACE(3G)

πŸ“¦ version 24.3.3, in opensuse-leap 16.0

πŸ’… GLFRONTFACE (3G) β€” the "which way is front, even" page πŸŽ€

okay so bestie, this is a page from section 3G of the manual β€” yes, GLFRONTFACE(3G), she's got a name and she's using it. Sit down, grab a strawberry πŸ“, and let's talk about which way your polygons are facing.


✨ NAME ✨

glFrontFace β€” define front- and back-facing polygons. that's it. that's the whole job. iconic honestly πŸ‘‘


🌸 C SPECIFICATION 🌸

void glFrontFace( GLenum mode )

look at her. one argument. no drama. πŸ’…


πŸ¦‹ PARAMETERS πŸ¦‹

  • mode β€” tells the system which orientation counts as "front-facing". your girl accepts GL_CW and GL_CCW. the initial value is GL_CCW. that's the default, no cap.

πŸ’– DESCRIPTION πŸ’–

so picture a scene made entirely of opaque closed surfaces β€” like, every object is solid and shut, nothing see-through, nothing open. in that situation, back-facing polygons are literally never visible. never. not once. πŸ™ˆ

and cutting out those invisible polygons? obvious benefit, bestie β€” it speeds up your rendering. free performance, we love to see it. ✨ to turn this elimination of back-facing polys on and off, you call glEnable and glDisable with the argument GL_CULL_FACE.

okay now the actual winding tea β˜•. here's the vibe check on "clockwise winding":

imagine a lil imaginary object 🧚 walking the path of a polygon's projection into window coordinates β€” from its first vertex, to its second vertex, and so on, all the way to its last vertex, and finally back to its first vertex. if that lil guy moves in a clockwise direction around the interior of the polygon, the polygon's winding is said to be clockwise. if the same lil guy following the same path moves counterclockwise around the interior, then the winding is said to be counterclockwise. periodt. πŸ’€

glFrontFace specifies whether polygons with clockwise winding in window coordinates, or counterclockwise winding in window coordinates, get taken to be front-facing. it's giving "choose your fighter":

  • pass GL_CCW to mode β†’ counterclockwise polygons are selected as front-facing
  • pass GL_CW to mode β†’ clockwise polygons are selected as front-facing

and by default, counterclockwise polygons are taken to be front-facing. remember that, iykyk. 🫢


πŸ’€ ERRORS πŸ’€

  • GL_INVALID_ENUM is generated if mode is not an accepted value. (rude of you, honestly)
  • GL_INVALID_OPERATION is generated if glFrontFace is executed between the execution of glBegin and the corresponding execution of glEnd. like, don't do that. read the room. 😭
fr fr do not call this between glBegin and glEnd. it will not slay. it will error.

πŸ”₯ ASSOCIATED GETS πŸ”₯

glGet with argument GL_FRONT_FACE β€” so you can go ask her what she thinks later. main character energy πŸ‘‘


🌈 SEE ALSO 🌈

  • glCullFace(3G)
  • glLightModel(3G)

go read those too, they're the friend group 🫢


and that's the page, bestie! 🌸 it came to you straight from the GLFRONTFACE(3G) corner of the manual β€” same title at the top, same title at the bottom, the classic sandwich πŸ₯ͺ β€” with a whole lot of love and zero changes to the facts. now go face those fronts. πŸ’œ

πŸ“¦ where this page comes from