简体   繁体   English

glReadPixels 不读取 iOS 上的深度缓冲区值

[英]glReadPixels doesn't read depth buffer values on iOS

I can't seem to read the depth buffer values in OpenGL ES2 on iOS 4.3我似乎无法读取 iOS 4.3 上 OpenGL ES2 中的深度缓冲区值

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.我的深度缓冲区目前已绑定到位并且可以运行,但是 function 只读取 0 值,并且它似乎几乎立即返回。 If I give it a GL_RGBA, it will take quite a while, and will indeed return results.如果我给它一个 GL_RGBA,这将需要相当长的时间,并且确实会返回结果。 Is this functionality just not supported in ES2 on iOS? iOS 上的 ES2 是否不支持此功能?

Thanks!谢谢!

As you guess, reading the depth buffer isn't supported in ES 2.x.如您所料,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.根据glReadPixels 手册页(直接来自 Khronos),ES 2 中“格式”的唯一允许值是 GL_ALPHA、GL_RGBA 和 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.从 memory 开始,最新版本的 iOS 支持深度纹理,因此如果您处于死胡同,应该可以运行像素着色器将深度缓冲区转换为可以读取为 RGBA 的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM