-
Clearing a portion of the depth buffer
Is there a way to clear only a rectangle region of the depth buffer?
-
Senior Member
OpenGL Guru
Re: Clearing a portion of the depth buffer
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.
-
Re: Clearing a portion of the depth buffer
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.
-
Advanced Member
Frequent Contributor
Re: Clearing a portion of the depth buffer
does it? Hmm. okay...
what about trying defining a scissor region?
hope this helps
cheers,
John
-
Senior Member
OpenGL Guru
Re: Clearing a portion of the depth buffer
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.
-
Re: Clearing a portion of the depth buffer
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.
-
Re: Clearing a portion of the depth buffer
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules