Quote:Original post by Lutz
I tried to display the z-buffer using
glCopyPixels(0,0,SCREEN_W,SCREEN_H,GL_DEPTH);
I've set up the raster position and zoom factor correctly. All it did display is a white rectangle (even when I cleared the z-buffer with 0.0f beforehand).
What you're doing is rendering a rectangle using the current raster color and depth values taken from the depth buffer. If the current raster color is white, then the whole rectangle will be white.
I don't know if you can do what you want with glCopyPixels (at least not without an
extension.)
I tried getting it to work with fog, but didn't succeed.
Quote:Apart from that, it was terribly slow: 8FPS on a RadeOn 9800 Pro! As far as I understand, glCopyPixels should transfer the stuff on the GPU only, so it should be rather fast.
glCopyPixels isn't exactly the fastest operation. Making sure that texturing, lighting etc. are disabled might make it a bit faster..
Quote:Then I replaced glCopyPixels by
glReadPixels(0,0,SCREEN_W,SCREEN_H, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, buffer);glDrawPixels(SCREEN_W,SCREEN_H, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, buffer);
and it worked. It displayed the z-buffer contents correctly, but it was even slower (since it has to transfer stuff from GPU to CPU and back).
Any ideas why glCopyPixels doesn't give the expected results?
Yes, but I don't understand why the above worked [smile]
It shouldn't, unless you're doing something clever elsewhere in the code. glReadPixels/glDrawPixels with GL_DEPTH_COMPONENT shouldn't produce any better results than glCopyPixels with GL_DEPTH.
Now, if the format for glDrawPixels was something like GL_RED, then I'd understand. [smile]