Reputation: 275
Using GLES 2.0 on Android, I am trying to render to a framebuffer backed by a texture. The texture and framebuffer are created like this:
final int GL_RGB16F_EXT = 0x881B;
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGB, width, height, 0,
GL_RGB16F_EXT, type, null);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0,
GLES20.GL_TEXTURE_2D, textureHandle, 0);
For type=GL_HALF_FLOAT_OES
, this works on some devices, but gives a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
status on others.
The texture was created with GL_NEAREST
minify and magnify mode.
Note that on some devices (Nexus 5), the above works only when I use "GL_RGB
" instead of "GL_RGB16F_EXT
" as the internal format, on some (Nexus 6/7) it works only with GL_RGB16F_EXT
, on some it works with both (Nexus 9) and on some it doesn't work with either (Nexus 4).
The weird thing is that all my devices, including the failing ones, report GL_OES_texture_half_float
and GL_EXT_color_buffer_half_float
.
What else could I be missing here?
Upvotes: 1
Views: 1460
Reputation: 54642
I believe the correct combination of arguments for ES 2.0 is:
final int GL_HALF_FLOAT_OES = 0x8D61;
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGB, width, height, 0,
GLES20.GL_RGB, GL_HALF_FLOAT_OES, null);
ES 2.0 unfortunately does not support sized internal formats for glTexImage2D()
. It derives the internal format from the format/type parameters. Sized internal formats were added in ES 3.0.
Based on the EGL_color_buffer_half_float spec, GL_RGB16F_EXT
is only supported as the internalformat for glRenderbufferStorage()
.
Upvotes: 1