PDA

View Full Version : Extracting the z-buffer



Colby Toland
08-20-2004, 09:06 AM
This is a two parter. One, I have heard there is a function to extract the z-buffer from the final image but I haven't been able to find the function and two, does anyone know the formula for the z-buffer (I've been told it's non-linear normalization to increase the accuracy of near objects)?

Thanks,
Colby

Orzech
08-20-2004, 01:07 PM
Originally posted by Colby Toland:
does anyone know the formula for the z-buffer (I've been told it's non-linear normalization to increase the accuracy of near objects)?
Hi!

You can acces the contents of Z-buffer (Depth Buffer) with glReadPixels() command. Here is a sample use :


glReadPixels( x, y, width, height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, array)... where array is a pointer to memory where depth-values (in GLubyte type in this case) will be placed.

If you'd like to know more about manipulating buffers, get your self accustomed to two other commands : glDrawPixels(), glCopyPixels().

Hope it helps!