GL_DEPTH_TEST

Started by
4 comments, last by Hermes 19 years, 7 months ago
When enabeling GL_DEPTH_TEST does this defaults to glDepthFunc(GL_LEQUAL);or do i have to specify it myself. And another thing ,when rendering the scene if i specify glClear(GL_DEPTH_BUFFER_BIT) do i need to call lets say glClearDepth(1.0f) in the initialization function ?[looksaround] Thanks for your help!
Advertisement
its probably for the best todo those things, I cant recall off the top of my head what the spec says but its better to perform those operations at start up to ensure you are getting the content you think you are, its not like it costs you any time or anything.
The default for GL_DEPTH_TEST is GL_LEQUAL. I always call glDepthFunc(GL_LEQUAL) in my initialization anyway. And, yes, you need to call glClearDepth(1.0f) in your initialization code, then call glClear(GL_DEPTH_BUFFER_BIT) before you render...
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Could you tell me why do i have to clear it before
glClear(GL_DEPTH_BUFFER_BIT) please.
Doesn't it clear it anyways at every call to the rendering function or the clearing process means filling the buffer with 1.0f value(in my case).
Thanks!
Quote:Original post by Hermes
Could you tell me why do i have to clear it before
glClear(GL_DEPTH_BUFFER_BIT) please.
Doesn't it clear it anyways at every call to the rendering function or the clearing process means filling the buffer with 1.0f value(in my case).
Thanks!

glClearDepth only specifies what value is written to the depth buffer when the buffer is cleared. The actual clearing is only performed when glClear is called.

Anyways, the default depth test function is GL_LESS, not GL_LEQUAL. This could be an important difference, as GL_LESS does not work well with multipass rendering for example. And 1.0 is the default depth clear value, so no need to call glClearDepth unless you want another value.
Thanks for the tip brother!

This topic is closed to new replies.

Advertisement