问题描述
我正在为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:
因此,您可以使用以下代码检查可用的类型/格式:
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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!