How to properly use GL_HALF_FLOAT_OES for textures?

心不动则不痛 提交于 2019-12-11 09:31:28

问题


I'm using OpenGL ES 2.0 on an iPad 2 / 3. I'd like to use GL_FLOAT when creating textures:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, rawData);

but the problem is that GL_LINEAR is not supported as a GL_TEXTURE_MAG_FILTER when GL_FLOAT is used if you don't have GL_OES_texture_float_linear showing up in your list of supported extensions. (None of the iPads do.)

But I do have GL_OES_texture_half_float_linear in my list of extensions. So using a half-float texture ought to work with linear interpolation.

Problem is, switching my texture creation to:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_HALF_FLOAT_OES, rawData);

causes EXC_BAD_ACCESS when I run the app. (libGPUSupportMercury.dlylib'gpus_ReturnGuiltyForHardwareRestart)

I haven't changed the format of the data since calling it with GL_FLOAT. Does the input data need to change for HALF_FLOAT somehow? If so, how? I don't know how I would split my input floats in half. Each component is GLfloat currently.


回答1:


My "solution" for right now has been to add my own bilinear interpolation to the fragment shader, since OpenGL won't do it for me when GL_FLOAT is used.



来源:https://stackoverflow.com/questions/13485937/how-to-properly-use-gl-half-float-oes-for-textures

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