Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Stencil buffer

This topic is 5719 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

Hey. I just read the stencil buffer tutorial, but I can''t quite understand why the depth buffer must be disabled before drawing the floor into the stencil buffer. Why ?

Share this post

Link to post
Share on other sites
The depthbuffer is disabled because otherwise the "real" floor won''t be drawn.

The floor is drawn twice: The first time only the stencil buffer should be updated, so the depthbuffer and the colorbuffer are disabled.
If depthtest had been enabled the first time, nothing would be drawn the second time because the z-buffer test would fail.

It is perhaps clearer if you replace the calls to glDisable/Enable(GL_DEPTH_TEST) with:
glDepthMask(false); // do not update zbuffer

I guess glDisable(GL_DEPTH_TEST) is used in the tutorial because the floor is the first thing to be drawn so there is no need to do any zbuffer tests at all.

Share this post

Link to post
Share on other sites

  • 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!