Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Clearing a portion of the depth buffer

  1. #1
    Intern Contributor
    Join Date
    Mar 2000
    Location
    PA, USA
    Posts
    74

    Clearing a portion of the depth buffer

    Is there a way to clear only a rectangle region of the depth buffer?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    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.

  3. #3
    Intern Contributor
    Join Date
    Mar 2000
    Location
    PA, USA
    Posts
    74

    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.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    839

    Re: Clearing a portion of the depth buffer

    does it? Hmm. okay...

    what about trying defining a scissor region?

    hope this helps

    cheers,
    John

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    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.

  6. #6
    Intern Contributor
    Join Date
    Mar 2000
    Location
    PA, USA
    Posts
    74

    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.

  7. #7
    Intern Contributor
    Join Date
    Mar 2000
    Location
    PA, USA
    Posts
    74

    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
  •