GLDEPTHFUNC(3G)
π NAME π
glDepthFunc β bestie, this is the one that picks which depth comparison rule your depth buffer uses π (it's from the 3G manual, the OpenGL girlies, iykyk)
β¨ C SPECIFICATION β¨
void glDepthFunc(GLenum func);
πΈ PARAMETERS πΈ
funcβ the depth comparison function, aka the whole vibe check of this call. You pass one of these symbolic constants:GL_NEVER,GL_LESS,GL_EQUAL,GL_LEQUAL,GL_GREATER,GL_NOTEQUAL,GL_GEQUAL, andGL_ALWAYS. The initial value isGL_LESSβ that's the default she ships with π
π¦ DESCRIPTION π¦
Okay so glDepthFunc decides the function used to compare every incoming pixel's depth value against the depth value already sitting in the depth buffer. Iconic. But heads up β the comparison only happens if depth testing is enabled. (See glEnable() and
glDisable of GL_DEPTH_TEST.) Yeah, that sentence made me do a double take too π
func sets the conditions under which the pixel actually gets drawn. The comparison functions, ranked by how much they let through:
GL_NEVERβ never passes. not once. zero. nothing. π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. her door is open, everybody come in π
The initial value of func is GL_LESS. And initially, depth testing is disabled. If depth testing is disabled, or if there's just no depth buffer at all, it behaves as if the depth test always passes β yes, even with GL_NEVER set, because the test isn't even running, bestie π
π NOTES π
Real talk: even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated when the depth test is disabled. Like, it's there, it's ready, and it's getting ignored. To unconditionally write to the depth buffer, you gotta enable the depth test and set it to GL_ALWAYS. That's the move π
π₯ ERRORS π₯
GL_INVALID_ENUMis generated iffuncis not an accepted value. So likeβ¦ don't make up constants, she'll know π«Ά
π ASSOCIATED GETS π
glGet()with argumentGL_DEPTH_FUNCglIsEnabled()with argumentGL_DEPTH_TEST
β VERSION SUPPORT β
glDepthFunc / feature name: glDepthFunc β she's supported across the whole OpenGL glow-up, every single column checked β:
- OpenGL 2.0 β β
- OpenGL 2.1 β β
- OpenGL 3.0 β β
- OpenGL 3.1 β β
- OpenGL 3.2 β β
- OpenGL 3.3 β β
- OpenGL 4.0 β β
- OpenGL 4.1 β β
- OpenGL 4.2 β β
- OpenGL 4.3 β β
- OpenGL 4.4 β β
- OpenGL 4.5 β β
π§ SEE ALSO π§
glDepthRange()glEnable()glPolygonOffset()
π COPYRIGHT π
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/.
Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group
ngl that's the whole page, no cap. stay hydrated and go set your depth func to something cute π
mwah π β this one's sourced from [FIXME: source] and dated 08/09/2021, and yeah the manual page is literally called GLDEPTHFUNC(3G) if anyone asks π
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms