PDA

View Full Version : have you some executable soure code of reading the z-buffer value?



xixitomato
02-19-2004, 06:59 PM
help!
i have try all the ways i can find,but i still can not find the problem

thanks a lot

zeckensack
02-19-2004, 09:16 PM
float* buffer=(float*)malloc(640*480*sizeof(float));
glReadPixels(0,0,640,480,
GL_DEPTH_COMPONENT,
GL_FLOAT,
buffer);
If that doesn't work for you, it is doubtful that your z buffer contains what you expected.
I've seen in your other thread that you're using a scenegraph. You might have to tell the scenegraph to render the objects first.

Ordering hazards between OpenGL functions don't exist, but they do exist if you mix OpenGL with some layered library.
OpenGL itself will "know" that it must finish rendering before it can properly do ReadPixels. The scenegraph doesn't know anything about ReadPixels, so it still may have some geometry stored in its buffers that isn't rendered.

Okay?

Btw, don't create multiple threads for basically the same topic. It can become confusing and is regarded as impolite.

Relic
02-20-2004, 02:38 AM
Small nitpick. GL_FLOAT is flexible but may not be the best performing destination format here. Use GL_UNSIGNED_INT speedier readbacks.

zeckensack
02-20-2004, 03:39 AM
Originally posted by Relic:
Small nitpick. GL_FLOAT is flexible but may not be the best performing destination format here. Use GL_UNSIGNED_INT speedier readbacks.Last time I checked GL_FLOAT was the fastest format for Radeon cards. YMMV, of course.

xixitomato
02-20-2004, 09:01 PM
The problem has been resolved. Thanks for your help
I have found the problem, it is not the reading z-buffer function, but the camera i used.