c++ - OpenGL: GL_FRAMEBUFFER_UNSUPPORTED on specific combinations of framebuffer attachments -
im trying attach multiple targets framebuffer object. have following problem:
there no error, when using float texture attachments , depth attachment. there no error, when using float texture attachments , integer texture attachments. although these combinations work, cant use float, integer , depth attachments @ same time. results in gl_framebuffer_unsupported
status.
this code:
//working: framebuffer fb = framebuffer( 1280,720, { //attachmentinfo(gl_depth_component16,gl_depth_attachment), attachmentinfo(gl_rg32f,gl_color_attachment0), attachmentinfo(gl_rgb16ui,gl_color_attachment1), attachmentinfo(gl_rgb32f,gl_color_attachment2), attachmentinfo(gl_rgb32f,gl_color_attachment3), attachmentinfo(gl_rgba16f,gl_color_attachment4), attachmentinfo(gl_rgb32f,gl_color_attachment5), attachmentinfo(gl_rgb32f,gl_color_attachment6), } ); //working: framebuffer fb = framebuffer( 1280,720, { attachmentinfo(gl_depth_component16,gl_depth_attachment), attachmentinfo(gl_rg32f,gl_color_attachment0), //attachmentinfo(gl_rgb16ui,gl_color_attachment1), attachmentinfo(gl_rgb32f,gl_color_attachment2), attachmentinfo(gl_rgb32f,gl_color_attachment3), attachmentinfo(gl_rgba16f,gl_color_attachment4), attachmentinfo(gl_rgb32f,gl_color_attachment5), attachmentinfo(gl_rgb32f,gl_color_attachment6), } ); //not working: framebuffer fb = framebuffer( 1280,720, { attachmentinfo(gl_depth_component16,gl_depth_attachment), attachmentinfo(gl_rg32f,gl_color_attachment0), attachmentinfo(gl_rgb16ui,gl_color_attachment1), attachmentinfo(gl_rgb32f,gl_color_attachment2), attachmentinfo(gl_rgb32f,gl_color_attachment3), attachmentinfo(gl_rgba16f,gl_color_attachment4), attachmentinfo(gl_rgb32f,gl_color_attachment5), attachmentinfo(gl_rgb32f,gl_color_attachment6), } );
note: error when using nvidia gtx 970 graphics card. on bit older ati card no error occured.
i use glbinding
call glgeterror
after every gl*
function call, know, no other error occured.
this constructor code framebuffer
object:
framebuffer::framebuffer(uint width,uint height,initializer_list<attachmentinfo> attachments) :width(width),height(height) { glgenframebuffers(1,&fbid); glbindframebuffer(gl_framebuffer,fbid); if(std::none_of(attachments.begin(),attachments.end(),[](const attachmentinfo& a){ return a.attachment == gl_depth_attachment; })){ //depth test needs either depth renderbuffer or depth attachment. unsigned int rboid=0; glgenrenderbuffers(1, &rboid); glbindrenderbuffer(gl_renderbuffer, rboid); glrenderbufferstorage(gl_renderbuffer, gl_depth_component, width, height); glbindrenderbuffer(gl_renderbuffer, 0); glframebufferrenderbuffer(gl_framebuffer,gl_depth_attachment,gl_renderbuffer,rboid); } vector<glenum> buffers; glactivetexture(gl_texture0); for(attachmentinfo attachment:attachments){ gluint tid; glgentextures(1, &tid); glbindtexture(gl_texture_2d,tid); glint param; glgetinternalformativ(gl_texture_2d, attachment.internalformat, gl_framebuffer_renderable, 1, ¶m); if(param != gl_full_support){ _log(warning,"internal format " << attachment.internalformat << " support " << glenum(param) << "."); } gltexparameteri(gl_texture_2d, gl_texture_mag_filter, glint(gl_linear)); gltexparameteri(gl_texture_2d, gl_texture_min_filter, glint(gl_linear)); gltexparameteri(gl_texture_2d, gl_texture_wrap_s, glint(gl_clamp_to_edge)); gltexparameteri(gl_texture_2d, gl_texture_wrap_t, glint(gl_clamp_to_edge)); if(attachment.attachment == gl_depth_attachment){ gltexparameteri(gl_texture_2d, gl_texture_compare_mode, glint(gl_compare_ref_to_texture)); gltexparameteri(gl_texture_2d, gl_texture_compare_func, glint(gl_less)); } gltexstorage2d(gl_texture_2d,1,attachment.internalformat,width,height); glframebuffertexture(gl_framebuffer, attachment.attachment, tid, 0); if(tools::startswith(glbinding::meta::getstring(attachment.attachment),"gl_color_attachment")){ buffers.push_back(attachment.attachment); } texmap[attachment.attachment]=new texture(tid,gl_texture_2d); glbindtexture(gl_texture_2d,0); } if(buffers.empty()){ buffers.push_back(gl_none); } gldrawbuffers(buffers.size(),buffers.data()); glenum error=glcheckframebufferstatus(gl_framebuffer); if(error != gl_framebuffer_complete){ _log(error,"framebuffer error: " << error); } unbind(); }
im out of ideas can make work...
im out of ideas can make work...
your opengl implementation tells you, configuration choose not supported. have accept that. opengl specification not require particular combination of formats supported implementation, if want program portable , robust, if gl_framebuffer_unsupported error you'll have gradually step down format requirements until workable combination found.
a hint on what's supported enumerating fbconfigs supported creating opengl context; subset of permissible fbo configurations.
Comments
Post a Comment