开发者

glReadPixels doesn't read depth buffer values on iOS

开发者 https://www.devze.com 2023-03-17 12:39 出处:网络
I can\'t seem to read the depth buffer values in OpenGL ES2 on iOS 4.3 afDepthPixels = (float*)malloc(sizeof(float) * iScreenWidth * iScreenHeight);

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消