Re: [PyOpenGL-Users] Reading Depth Component - not working anymore?
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@vr...> - 2007-12-29 23:40:26
|
Hart's Antler wrote: > --- "Mike C. Fletcher" <mcf...@vr...> wrote: > ... > i dont have a stripped down example, but the code is just 3 lines you can insert into any pyopengl > demo. > data = glReadPixels(0,0,x,y, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE) # note x,y are screen size > img = Image.fromstring( 'L', (x,y), data ) # requires PIL > img.save( 'z.bmp' ) # when you open z.bmp you will find that it is blank - all white. > I can reproduce the effect you are reporting if I have a large frustum where the near and far clipping plans are at .01 and 1000 respectively. If I bring those down so that the geometry is just bracketed by the clipping planes, the depth buffer "image" shows up as black for that touching the front clipping plane (lowest depth) and white for that touching the back clipping plane (highest depth). That is, the wrapper *seems* to be working fine (though the extremely high (.999+) values in the float mode with a large frustum surprise me, they *seem* to represent real depth values). The code I'm using to test is available in the CVS here: http://pyopengl.cvs.sourceforge.net/pyopengl/OpenGLContext/tests/saveimage.py?view=markup You can see the commented-out code that uses GL_FLOAT type and maps the values to the 0-255 range using array operations as well. I'm open to the possibility that something is going wrong in the wrapper, but it *looks* like something unexpected in the GL, rather than something wrong with the wrapper. This URL http://www.opengl.org/resources/faq/technical/depthbuffer.htm would seem to suggest that the likely culprit for this kind of error is specifying a zNear which is too near to the camera. Hope this helps, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |