具有float或half_float纹理的OpenGL ES 2.0:glReadPixels() [英] OpenGL ES 2.0 :glReadPixels() with float or half_float textures

查看:248
本文介绍了具有float或half_float纹理的OpenGL ES 2.0:glReadPixels()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iPhone(iOS 4.1)编写OpenGL ES 2.0应用程序.在着色器中完成计算的最后,我需要将一些数据写回CPU.据我所知,这可以通过glReadPixels()完成.为了保持精度,我想在着色器之间使用half_float或float纹理,这似乎受到扩展的支持.

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.

问题: 是否可以使用glReadPixels()读取float或half_float纹理?

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

谢谢

Lars

推荐答案

我也已经遇到了这个问题.对于iOS,您可以使用GL_EXTENSIONS参数检查可用的扩展程序列表-GL_OES_texture_float必须存在.但!根据规范,这没有机会从GPU读取浮点值.这是来自glReadPixels()文档:

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:

仅接受两个格式/类型参数对.始终接受GL_RGBA/GL_UNSIGNED_BYTE,可以通过查询GL_IMPLEMENTATION_COLOR_READ_FORMAT和GL_IMPLEMENTATION_COLOR_READ_TYPE来发现其他可接受的对.

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

这篇关于具有float或half_float纹理的OpenGL ES 2.0:glReadPixels()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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