have you some executable soure code of reading the z-buffer value?

help!
i have try all the ways i can find,but i still can not find the problem

thanks a lot

float* buffer=(float*)malloc(640480sizeof(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.

Small nitpick. GL_FLOAT is flexible but may not be the best performing destination format here. Use GL_UNSIGNED_INT speedier readbacks.

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.

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.