PDA

View Full Version : Z-Buffer



Acid-Chris
05-17-2001, 03:55 AM
Is there a way to directly access the OpenGL Z-Buffer or how can i blit a precalculated
Z-field into the Z-Buffer?

Thaellin
05-17-2001, 04:15 AM
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

Tom Nuydens
05-17-2001, 09:29 AM
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

mcraighead
05-17-2001, 04:01 PM
It's certainly not 100 times faster, not if you're doing things right.

- Matt

Acid-Chris
05-18-2001, 12:13 AM
- Thanks for your reply!
it helped a lot!

- Christoph

Relic
05-18-2001, 12:31 AM
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.

Tom Nuydens
05-18-2001, 12:34 AM
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 http://www.opengl.org/discussion_boards/ubb/smile.gif

That said, I get 210 fps using buffer regions, so I was only off by about a factor 14 http://www.opengl.org/discussion_boards/ubb/smile.gif

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).]