Jump to content
  • Advertisement
Sign in to follow this  
Hermes

GL_DEPTH_TEST

This topic is 5149 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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!