GLDEPTHFUNC(3G)

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

πŸ’… 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 constants GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, and GL_ALWAYS are accepted. The initial value is GL_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_ENUM is generated if func is not an accepted value. So if you made up a constant, she will notice πŸ“
  • GL_INVALID_OPERATION is generated if glDepthFunc is executed between the execution of glBegin and the corresponding execution of glEnd. Like, don't do that. That's an inside-the-blockzone call and it's not allowed βœ‹

πŸ”₯ ASSOCIATED GETS πŸ”₯

  • glGet with argument GL_DEPTH_FUNC
  • glIsEnabled with argument GL_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