GLALPHAFUNC(3G)
π 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 areGL_NEVER,GL_LESS,GL_EQUAL,GL_LEQUAL,GL_GREATER,GL_NOTEQUAL,GL_GEQUAL, andGL_ALWAYS. the initial value isGL_ALWAYS. π«Άrefβ the reference value that your incoming alpha values get compared against. it gets clamped to the range[0, 1], where0is the lowest possible alpha value and1is the highest possible value. initial reference value is0. π
β¨ 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. (seeglEnableandglDisableofGL_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_ENUMis generated iffuncis not an accepted value. (you made up an option. it knows. π)GL_INVALID_OPERATIONis generated ifglAlphaFuncis executed between the execution ofglBeginand the corresponding execution ofglEnd. do NOT do that. that's illegal sandwich behaviour. π
π ASSOCIATED GETS π
glGetwith argumentGL_ALPHA_TEST_FUNCglGetwith argumentGL_ALPHA_TEST_REFglIsEnabledwith argumentGL_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
- opensuse-leap 16.0: Mesa-libGL-devel 24.1.7-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms