The documentation indicates that “The glClearDepth function specifies the clear value for the depth buffer” and that it is clamped to the range [0,1]. So what does setting the depth buffer clear value do?
Well, it does exactly what the description says. You use it to specify the value used when the depth buffer is cleared. And if you try to set it to a value less than 0, it will use 0, and if you try to set it to a value greater than 1, it will use 1.
I understand that. What I mean to ask is what physical difference will be noticed when I use 0.5 as opposed to 1.0 and 0.0?
When you clear the depth buffer if you have this value set to 0 nothing will get cleared. If you have it set to 1 (the default) everything gets cleared. Anything in between clears part of the depth buffer (remember z depth is not linear).
Unless I’m mistaken, the value used to clear the depth buffer does not affect in any way how much of it gets cleared when using glClear. glClear will clear the entire depth buffer by writing the value to all pixels. Just like selecting the color clear value doesn’t affect how much of the color buffer gets cleared, the depth clear value does not determine how much of the depth buffer gets cleared.
DFrey I don’t think you are mistaken . glClearDepth clears the complete DepthBuffer no matter which value is set.
glClearDepth sets the value, which will be written to the depthbuffer when calling glClear, like glClearcolor for the colorbuffer, so u can set a clipplane which will be between the nearclipplane and farclipplane …
glClearDepth can be seen as an additional clip plane. But that is not always true.
If depthtest function is disabled, this “plane” is also disabled. If depthtest function is GL_ALWAYS, GL_GREATER or similar, you can “make holes” in the plane, writing new values, which is larger that the clear value, into the depthbuffer.
So, this clipplane analogy is only valid if depthtest is on, and depthfunction is a less-variant (GL_LESS, GL_LEQUAL).
Yup, I’m wrong here. I’ve never used it and just thought that was how it worked. Looked it up and see I’m wrong. Sorry about that folks.
I got it! Thanks folks