简体   繁体   中英

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

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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