GLDEPTHFUNC(3G)
π GLDEPTHFUNC(3G) β the depth test function glow-up
Okay so bestie, welcome to the 3G manual page for glDepthFunc, and ngl this one is lowkey short but it's iconic. It's all about telling OpenGL when a pixel is allowed to actually show up. Main character energy for your depth buffer, fr fr.
β¨ NAME β¨
glDepthFunc β specify the value used for depth buffer comparisons π«Ά
πΈ C SPECIFICATION πΈ
void glDepthFunc( GLenum func )
That's it. One argument. Slay.
π PARAMETERS π
funcβ specifies the depth comparison function. The symbolic constantsGL_NEVER,GL_LESS,GL_EQUAL,GL_LEQUAL,GL_GREATER,GL_NOTEQUAL,GL_GEQUAL, andGL_ALWAYSare accepted. The initial value isGL_LESS. π
π¦ DESCRIPTION π¦
So like, glDepthFunc specifies the function used to compare each incoming pixel depth value with the depth value present in the depth buffer. The comparison is performed only if depth testing is enabled β see glEnable and glDisable of GL_DEPTH_TEST. No depth test, no comparison, no drama (well, actually, lots of drama, but not this kind).
func specifies the conditions under which the pixel will be drawn. The comparison functions are as follows, and yes I'm listing all eight, we don't skip β¨:
GL_NEVERβ Never passes. Literally never. Not once. The pixel said "not today" and went back to bed πGL_LESSβ Passes if the incoming depth value is less than the stored depth value.GL_EQUALβ Passes if the incoming depth value is equal to the stored depth value.GL_LEQUALβ Passes if the incoming depth value is less than or equal to the stored depth value.GL_GREATERβ Passes if the incoming depth value is greater than the stored depth value.GL_NOTEQUALβ Passes if the incoming depth value is not equal to the stored depth value.GL_GEQUALβ Passes if the incoming depth value is greater than or equal to the stored depth value.GL_ALWAYSβ Always passes. Iconic. Unbothered. Thriving. Every pixel is welcome at this party π
The initial value of func is GL_LESS. Initially, depth testing is disabled. And here's the part you can't skip, bestie, pay attention: even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. So you can have a whole depth buffer sitting there ready and it will simply not be updated. Not a bug, just the vibe check failing π
π Friendly reminder that "depth testing is disabled" + "depth mask non-zero" still = depth buffer not updated. That's the rule. Don't argue with the spec, she's been through enough.
π ERRORS π
GL_INVALID_ENUMis generated iffuncis not an accepted value. So if you made up a constant, she will notice πGL_INVALID_OPERATIONis generated ifglDepthFuncis executed between the execution ofglBeginand the corresponding execution ofglEnd. Like, don't do that. That's an inside-the-blockzone call and it's not allowed β
π₯ ASSOCIATED GETS π₯
glGetwith argumentGL_DEPTH_FUNCglIsEnabledwith argumentGL_DEPTH_TEST
Use these to check what you actually set, iykyk π
π SEE ALSO π
glDepthRange(3G)glEnable(3G)glPolygonOffset(3G)
And that's the whole page, bestie β no cap, every single detail preserved, every flag and error intact πβ¨ππ¦πΈ
Cute sign-off time π«Ά: this was GLDEPTHFUNC(3G) β yeah, the footer says the exact same thing as the header, GLDEPTHFUNC(3G), which is honestly such a mood. Go forth and depth-test responsibly, queen πβ
π¦ 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-1017 on : a language model's rewrite of the original, under its terms