I'm having problems with drawing in OpenGL and I need to see exactly what values are being placed in the depth buffer. Can anyone tell me how to retrieve these values? Thanks Chris
Asked
Active
Viewed 6,066 times
1 Answers
8
Use glReadPixels with format = GL_DEPTH_COMPONENT, for example:
float depth;
glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
Will get the depth of pixel (0, 0).

Dr. Snoopy
- 55,122
- 7
- 121
- 140
-
Thanks for that. Is there anyway to print a debug statement if the value in the depth buffer is changed rather than having to print out a frame of pixels each render loop? – Sonoman Dec 21 '10 at 14:46
-
There is: Occlusion Query. – MickLH Aug 12 '15 at 14:55