GLALPHAFUNC(3G)

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

πŸ’– GLALPHAFUNC(3G) β€” the alpha test function, explained by your fave πŸ’–

okay bestie, pull up a chair, we're doing glAlphaFunc from the 3G manual and honestly? it's giving gatekeeper energy. ✨


πŸŽ€ NAME πŸŽ€

glAlphaFunc β€” specify the alpha test function. that's it, that's the whole vibe. no cap. πŸ’…


πŸ“œ C SPECIFICATION πŸ“œ

void glAlphaFunc( GLenum func,
                  GLclampf ref )

literally copy that exactly, do not freestyle it, i'm watching. πŸ‘€


🌸 PARAMETERS 🌸

  • func β€” this is the alpha comparison function, the moment of truth, the main character. the symbolic constants it accepts are GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, and GL_ALWAYS. the initial value is GL_ALWAYS. 🫢
  • ref β€” the reference value that your incoming alpha values get compared against. it gets clamped to the range [0, 1], where 0 is the lowest possible alpha value and 1 is the highest possible value. initial reference value is 0. πŸ’œ

✨ DESCRIPTION ✨

so here's the tea: the alpha test discards fragments based on how a comparison between an incoming fragment's alpha value and a constant reference value turns out. glAlphaFunc is the one that sets both the reference value and the comparison function. πŸ”₯

lowkey important: the comparison only happens if alpha testing is enabled, and by default it is not enabled. (see glEnable and glDisable of GL_ALPHA_TEST.)

func and ref together decide when a pixel actually gets drawn. your incoming alpha value gets compared to ref using whatever function func says. if the value passes the comparison, the incoming fragment is drawn β€” but only if it also passes the subsequent stencil and depth buffer tests (yes, it has to pass multiple vibe checks, we don't make the rules). if the value fails the comparison, nothing changes in the frame buffer at that pixel location. periodt. πŸ’€

here's the full lineup of comparison functions, no skips:

  • GL_NEVER β€” never passes. it's not even trying. πŸ™ˆ
  • GL_LESS β€” passes if the incoming alpha value is less than the reference value.
  • GL_EQUAL β€” passes if the incoming alpha value is equal to the reference value.
  • GL_LEQUAL β€” passes if the incoming alpha value is less than or equal to the reference value.
  • GL_GREATER β€” passes if the incoming alpha value is greater than the reference value.
  • GL_NOTEQUAL β€” passes if the incoming alpha value is not equal to the reference value.
  • GL_GEQUAL β€” passes if the incoming alpha value is greater than or equal to the reference value.
  • GL_ALWAYS β€” always passes. that's the initial value, bestie, it's the default yes-girl. πŸ‘‘

and the range of this whole thing?? glAlphaFunc operates on all pixel write operations, including the ones that come from the scan conversion of points, lines, polygons, and bitmaps, and from pixel draw and copy operations. 🌈

but NOT screen clear operations. glAlphaFunc does not affect screen clear operations. clear is off doing its own thing, unbothered. βœ‹

πŸ“ NOTES πŸ“

alpha testing is performed only in RGBA mode. iykyk. 🌸


🚨 ERRORS 🚨

  • GL_INVALID_ENUM is generated if func is not an accepted value. (you made up an option. it knows. 😭)
  • GL_INVALID_OPERATION is generated if glAlphaFunc is executed between the execution of glBegin and the corresponding execution of glEnd. do NOT do that. that's illegal sandwich behaviour. πŸ’€

πŸ” ASSOCIATED GETS πŸ”

  • glGet with argument GL_ALPHA_TEST_FUNC
  • glGet with argument GL_ALPHA_TEST_REF
  • glIsEnabled with argument GL_ALPHA_TEST

πŸ¦‹ SEE ALSO πŸ¦‹

glBlendFunc(3G), glClear(3G), glDepthFunc(3G), glEnable(3G), glStencilFunc(3G)


okay that's the whole page, you're officially fluent, go forth and alpha test slay πŸ’–βœ¨πŸŽ€

signing off from the GLALPHAFUNC(3G) manual page itself β€” that's the source and the version tag, bestie, straight from the 3G pages. no date was ever given, so i'm not about to invent one. 🫢🌈⭐

πŸ“¦ where this page comes from