views:

61

answers:

2

The iPad now supports the OES_texture_half_float extension. Unfortunately I'm having trouble binding a floating-point texture to a framebuffer object. Here's my attempt:

GLuint textureHandle;
glGenTextures(1, &textureHandle);
glBindTexture(GL_TEXTURE_2D, textureHandle);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 256, 256, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
assert(GL_NO_ERROR == glGetError()); // this passes

GLuint fboHandle;
glGenFramebuffers(1, &fboHandle);
glBindFramebuffer(GL_FRAMEBUFFER, fboHandle);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureHandle, 0);
assert(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); // this asserts

This works fine when replacing GL_HALF_FLOAT_OES with GL_UNSIGNED_BYTE.

Is this a limitation with iOS or am I doing something incorrectly?

A: 

Are you checking GL errors? If not, do it, it might shed some light about the problem. Also, what does glCheckFramebufferStatus return?

Matias Valdenegro
glGetError returns GL_NO_ERROR at the end of this snippet. glCheckFramebufferStatus returns GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT.
prideout
A: 

prideout, I've got the same error. Looks like there is no support of rendering to float texture on iOS devices yet. Since, OpenGL ES 2.0 specs mark this feature as not mandatory. Did you make any more research on that? Can confirm such limitation?

HARDWARRIOR
Yes, this appears to be a driver limitation. I filed a bug against Apple. (8524103) I hope they add support for this as it would enable a variety of effects. For example: http://prideout.net/blog/?p=51
prideout