ios - GLKit Offscreen render to texture not working -
when try create fbo texture attached in opengl es 2.0 this:
glgenframebuffers(1, &framebuffer); glgentextures(1, &textureid); glbindframebuffer(gl_framebuffer, framebuffer); glbindtexture(gl_texture_2d, textureid); glteximage2d(gl_texture_2d, 0, gl_rgba, width, height, 0, gl_rgba, gl_unsigned_byte, null); gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_linear); gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_linear); gltexparameteri(gl_texture_2d, gl_texture_wrap_s, gl_clamp_to_edge); gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_clamp_to_edge); glframebuffertexture2d(gl_framebuffer, gl_color_attachment0, gl_texture_2d, framebuffer, 0); glenum status; status = glcheckframebufferstatus(gl_framebuffer); switch(status) { case gl_framebuffer_complete: nslog(@"fbo complete"); break; case gl_framebuffer_unsupported: nslog(@"fbo unsupported"); break; default: /* programming error; fail on hardware */ nslog(@"framebuffer error"); break; } glbindtexture(gl_texture_2d, 0); glbindframebuffer(gl_framebuffer, 0);
and apply this:
glbindframebuffer(gl_framebuffer, rendertarget.framebufferid); glbindtexture(gl_texture_2d, rendertarget.textureid); glviewport(0, 0, rendertarget.width, rendertarget.height);
then render on , draw attached texture screen. result empty black screen (everything works fine if render screen directly). tried several fbo tutorials (the current code 1 of them) no difference.
also when use opengl debugger xcode have warnings like: "slow framebuffer load issue" on gldrawarrays can see texture not empty (i can see texture right size , right glclearcolor)
would great if had issue before , knows im doing wrong here :)
thanks in advance
ok solved problem. there few smaller problems main problem bound framebuffer , texture (see top related question). other problem $!&()#^ (i mean wonderful) opengl coordinate system (bottom left) quick fix. working fine expect of poor performance when drawing fullscreen quad, open question that.
Comments
Post a Comment