I can't seem to read the depth buffer values in OpenGL ES2 on iOS 4.3
afDepthPixels = (float*)malloc(sizeof(float) * iScreenWidth * iScreenHeight);
glReadPixels(0, 0, iScreenWidth, iScreenHeight, GL_DEPTH_COMPONENT, GL_FLOAT, afDepthPixels);
My depth buffer is currently bound in place and operational, however that function reads nothing but 0 values, and it seems to return almost immediately. If I give it a GL_RGBA, it will take quite a w开发者_开发百科hile, and will indeed return results. Is this functionality just not supported in ES2 on iOS?
Thanks!
As you guess, reading the depth buffer isn't supported in ES 2.x. Per the glReadPixels man page (direct from Khronos) the only permissible values for 'format' in ES 2 are GL_ALPHA, GL_RGBA and GL_RGB.
From memory, depth textures are supported on recent versions of iOS, so it should be possible to run a pixel shader to convert a depth buffer into something you can read as RGBA if you're otherwise at a dead end.
精彩评论