Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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.
share|improve this answer
    
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. –  jdougan Apr 2 '11 at 7:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.