View Full Version : Purpose of glClearDepth
10-09-2001, 01:55 PM
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?
10-09-2001, 02:15 PM
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.
10-09-2001, 04:41 PM
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?
10-09-2001, 05:56 PM
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).
10-09-2001, 06:30 PM
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.
10-10-2001, 12:18 AM
DFrey I don't think you are mistaken http://www.opengl.org/discussion_boards/ubb/wink.gif. 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).
10-10-2001, 05:34 AM
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.
10-10-2001, 08:18 AM
I got it! Thanks folks http://www.opengl.org/discussion_boards/ubb/smile.gif
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.