glReadPixels 不读取 iOS 上的深度缓冲区值
我似乎无法在 iOS 4.3 上读取 OpenGL ES2 中的深度缓冲区值。
afDepthPixels = (float*)malloc(sizeof(float) * iScreenWidth * iScreenHeight);
glReadPixels(0, 0, iScreenWidth, iScreenHeight, GL_DEPTH_COMPONENT, GL_FLOAT, afDepthPixels);
我的深度缓冲区当前已绑定到位且可操作,但是该函数只读取 0 值,并且似乎几乎立即返回。如果我给它一个GL_RGBA,它会花费相当长的时间,并且确实会返回结果。 iOS 上的 ES2 是否不支持此功能?
谢谢!
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 while, and will indeed return results. Is this functionality just not supported in ES2 on iOS?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您所猜测的,ES 2.x 不支持读取深度缓冲区。根据 glReadPixels 手册页(直接来自 Khronos) ES 2 中“格式”的唯一允许值为 GL_ALPHA、GL_RGBA 和 GL_RGB。
根据记忆,最新版本的 iOS 支持深度纹理,因此如果您陷入困境,应该可以运行像素着色器将深度缓冲区转换为可以读取为 RGBA 的内容。
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.