glReadPixels不会在iOS上读取深度缓冲区值 [英] glReadPixels doesn't read depth buffer values on iOS

查看:477
本文介绍了glReadPixels不会在iOS上读取深度缓冲区值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在iOS 4.3上读取OpenGL 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);

我的深度缓冲区当前绑定到位并且可操作,但该函数只读取0值,并且它似乎几乎立即回归。如果我给它一个GL_RGBA,它将需要一段时间,并且确实会返回结果。 iOS上的ES2是否不支持此功能?

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?

谢谢!

推荐答案

正如您所猜测的,ES 2.x中不支持读取深度缓冲区。按照 glReadPixels手册页(从Khronos的直接)的只有ES 2中'format'的允许值是GL_ALPHA,GL_RGBA和GL_RGB。

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.

从内存来看,iOS的最新版本支持深度纹理,所以它应该是可能的运行一个像素着色器,将深度缓冲区转换为RGBA可以读取的内容,如果你处于死胡同状态。

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.

这篇关于glReadPixels不会在iOS上读取深度缓冲区值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆