OpenGL ES 2.0 :glReadPixels() with float or half_float textures

╄→гoц情女王★ 提交于 2020-01-04 05:09:29

问题


I am writing an OpenGL ES 2.0 app for the iPhone (iOS 4.1). At the end of the computations, which are done in the shaders, i need to write back some data to the CPU. As far as I know this can be done by glReadPixels(). In order to keep precision, i want to use half_float or float textures between the shaders, which seem to be supported by extensions.

Question: Is it possible to read float or half_float textures with glReadPixels() ?

Thanks,

Lars


回答1:


I have faced up to this problem either. For iOS you can check the available extensions list with GL_EXTENSIONS parameter - GL_OES_texture_float must present. But! According to specification this doesn't give an opportunity to read float values from GPU. This is from glReadPixels() docs:

Only two format/type parameter pairs are accepted. GL_RGBA/GL_UNSIGNED_BYTE is always accepted, and the other acceptable pair can be discovered by querying GL_IMPLEMENTATION_COLOR_READ_FORMAT and GL_IMPLEMENTATION_COLOR_READ_TYPE.

So you can check available types/formats you can read with code below:

GLint ext_format, ext_type;
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &ext_format);
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &ext_type);


来源:https://stackoverflow.com/questions/5788197/opengl-es-2-0-glreadpixels-with-float-or-half-float-textures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!