5
\$\begingroup\$

For the background render in my code I need to perform an operation that essentially acts like calling glClear(GL_DEPTH_BUFFER_BIT) except that it needs to use the current stencil buffer to mask out parts of the screen. The other requirement is that it has to work on fixed function pipeline systems, preferably back to OpenGL 1.3. Any suggestions on how to best do this?

\$\endgroup\$

1 Answer 1

7
\$\begingroup\$

You have to do this manually:

  • Disable depth testing.
  • Enable depth writing.
  • Set up an orthographic projection.
  • Enable stencil testing.
  • Draw a quad that covers the entire screen and whose Z is near your far plane.
\$\endgroup\$
1
  • 1
    \$\begingroup\$ More complex than I'd hoped, but it makes sense. I'm assuming there should be a glColorMask(GL_FALSE, GL_FALSE, GL_FALSE) in the setup to make it actually only clear the depth buffer. \$\endgroup\$
    – jdougan
    Apr 2, 2011 at 7:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .