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: Z-Buffer

  1. #1
    Intern Newbie
    Join Date
    May 2001
    Location
    Austria
    Posts
    30

    Z-Buffer

    Is there a way to directly access the OpenGL Z-Buffer or how can i blit a precalculated
    Z-field into the Z-Buffer?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Vancouver
    Posts
    110

    Re: Z-Buffer

    You can use glReadBuffer and glDrawBuffer to set the target read/write buffers, then access them using glReadPixels/glDrawPixels/glCopyPixels.

    The process might not be as fast as you would like, though.

    -- Jeff

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    857

    Re: Z-Buffer

    You can use WGL_ARB_buffer_region to store a "depth image" in video RAM and blit it to the Z buffer. It's very fast (as in: at least a hundred times faster than using glDrawPixels()).

    - Tom

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Sep 2000
    Location
    Santa Clara, CA
    Posts
    1,463

    Re: Z-Buffer

    It's certainly not 100 times faster, not if you're doing things right.

    - Matt

  5. #5
    Intern Newbie
    Join Date
    May 2001
    Location
    Austria
    Posts
    30

    Re: Z-Buffer

    - Thanks for your reply!
    it helped a lot!

    - Christoph

  6. #6
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: Z-Buffer

    Precalculated means like stored in a file, or rendered by the same program while running?
    Tom, there is no way to get the data into a buffer region other than to use Save- and RestoreBufferRegion.
    Furthermore, you don't have access to the internal data representation used for those regions.

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    857

    Re: Z-Buffer

    Originally posted by mcraighead:
    It's certainly not 100 times faster, not if you're doing things right.
    So it seems! I just tried modifying my WGL_ARB_buffer_region demo to use glDrawPixels() instead, and I got a very respectable 30 fps for a 512x512 depth image (PII-350 with a GeForce2). To my defense, though, I don't think I've used glReadPixels()/glDrawPixels() since I was still running on a Riva128. That may have biased my estimate a bit

    That said, I get 210 fps using buffer regions, so I was only off by about a factor 14

    Relic: what I did is load the depth image from file, then draw it to the framebuffer with glDrawPixels(), then save it using SaveBufferRegion(). Not very elegant, but hey, you only have to do it once.

    - Tom

    [This message has been edited by Tom Nuydens (edited 05-18-2001).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •