Sign in to follow this  

GL_DEPTH_TEST

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this