Original Post
🔒 Locked
Stencil buffer
Advertisement
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
DrawFloor();
glDepthMask(true);
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.
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
DrawFloor();
glDepthMask(true);
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement