opengl es - glFramebufferTexture2D fails on iPhone for certain texture sizes -


when try attach texture framebuffer, glcheckframebufferstatus reports gl_framebuffer_unsupported texture sizes. i've tested on both 2nd , 4th generation ipod touch. sizes of texture fail not identical between 2 models.

here interesting results:

2nd generation - 8x8 failed, 16x8 failed, 8x16 succeeded!

4th generation - 8x8 succeeded, 8x16 succeeded, 16x8 failed!

here's code used test attaching textures of different sizes:

void testfbotexturesize(int width, int height) {     gluint framebuffer, texture;      // create framebuffer     glgenframebuffersoes(1, &framebuffer);     glbindframebufferoes(gl_framebuffer_oes, framebuffer);      // create texture     glgentextures(1,&texture);     glbindtexture(gl_texture_2d,texture);     glteximage2d(gl_texture_2d, 0, gl_rgba, width, height, 0, gl_rgba, gl_unsigned_byte, null);     glbindtexture(gl_texture_2d,0);      // attach texture framebuffer     glframebuffertexture2does(gl_framebuffer_oes, gl_color_attachment0_oes, gl_texture_2d, texture, 0);     glenum error = glgeterror();     glenum status = glcheckframebufferstatusoes(gl_framebuffer_oes);     if (status==gl_framebuffer_complete_oes)         nslog(@"%dx%d succeeded!",width,height,status);     else         nslog(@"%dx%d failed: %x %x %d %d",width,height,status,error,texture,framebuffer);      // cleanup     glframebuffertexture2does(gl_framebuffer_oes, gl_color_attachment0_oes, gl_texture_2d, 0, 0);     gldeletetextures(1, &texture);     glbindframebufferoes(gl_framebuffer_oes, 0);     gldeleteframebuffersoes(1, &framebuffer);    }  void testfbotexturesizes() {     int width,height;     (width=1; width<=1024; width<<=1)     {         (height=1; height<=1024; height<<=1)             testfbotexturesize(width,height);     } } 

it seems long both dimensions @ least 16 pixels works ok on both devices. thing bothers me, though, haven't seen written texture size requirements attaching framebuffer object. 1 solution, now, restrict texture sizes @ least 16 pixels, might break in future or broken on device haven't tried? perform test code @ startup in order dynamically figure out texture sizes allowed, seems bit hokey.

i have experienced similar problem, when i'm trying render texture size 480x320 (full screen w/o resolution scale) on ipod touch 4. when call glcheckframebufferstatus() returns gl_framebuffer_unsupported. code:

glgentextures(1, &texture);     glbindtexture(gl_texture_2d, texture);         glteximage2d(gl_texture_2d, 0, gl_rgb, 480, 320, 0, gl_rgb, gl_unsigned_short_5_6_5, 0); glbindtexture(gl_texture_2d, 0);  glgenframebuffers(1, &framebuffer); glbindframebuffer(gl_framebuffer, framebuffer);  glframebuffertexture2d(gl_framebuffer, gl_color_attachment0, gl_texture_2d, texture, 0);  glenum status = glcheckframebufferstatus(gl_framebuffer); if (status != gl_framebuffer_complete) {     // report error } 

investigating problem have found gl_texture_2d has valid opengl es object if want use in render-to-texture mechanism. means texture should ready bound , use. fix error have set texture parameters. because use non-pot texture have set gl_texture_wrap_ gl_clamp_to_edge (default value gl_repeat) , gl_texture_min_filter gl_nearest or gl_linear (default value gl_nearest_mipmap_linear) use texture.

i couldn't find what's problem 16x8, 16x9 , 17x8 works fine if parameters set. hope information helpful you.


Comments