PDA

View Full Version : Clearing a portion of the depth buffer



ben
08-09-2000, 07:26 AM
Is there a way to clear only a rectangle region of the depth buffer?

Bob
08-09-2000, 09:27 AM
Not sure about this, but try to setup a viewport (glViewport()), which covers the area you want to clear. Then use the standard glClear-function.

ben
08-09-2000, 04:47 PM
I don't think this will work. On windows, I set the viewport to be a small portion of the screen and used the glClear on the color buffer bit and the entire area of the window was cleared. I think this extends to the depth buffer bit as well.

john
08-09-2000, 05:25 PM
does it? Hmm. okay...

what about trying defining a scissor region?

hope this helps

cheers,
John

Bob
08-10-2000, 02:02 AM
Coyp-and-pasted directly from MSVC 6 documentation on glClear()...

The pixel-ownership test, the scissor test, dithering, and the buffer writemasks affect the operation of glClear. The scissor box bounds the cleared region. The alpha function, blend function, logical operation, stenciling, texture mapping, and z-buffering are ignored by glClear.

So it seems like a scissor box should do the job.

ben
08-10-2000, 04:40 AM
I'll try the scissor region. Thanks.

About glClear clearing the entire window DC regardless of what the viewport is set too, I'm recalling this from a while back, so I'm going to verify that what I said previously is true. I just want to clear up any confusion I might have caused.

ben
08-10-2000, 05:27 AM
Yup, I confirmed it. I did this...

- Set my viewport to be the entire viewing area

- Drew test scene 1 to the back buffer, but didn't swap buffers

- Set my viewport to be a portion of the viewing area using glViewport

- Called glClear(GL_COLOR_BUFFER_BIT)

- Drew test scene 2

- Swap the buffers

- The only scene that is visible is the test scene 2.

By contrast, if you skip the glClear call after setting the viewport, both test scenes are on the screen.