From: Mikko Rasa Date: Sat, 29 Dec 2012 17:51:55 +0000 (+0200) Subject: Verify framebuffer completeness in effect constructors X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=db735acce6c9409fabcab80d87930263032af47c;p=libs%2Fgl.git Verify framebuffer completeness in effect constructors This avoids silent failures due to an unsupported framebuffer configuration. --- diff --git a/source/ambientocclusion.cpp b/source/ambientocclusion.cpp index c02daf52..4ef37625 100644 --- a/source/ambientocclusion.cpp +++ b/source/ambientocclusion.cpp @@ -81,6 +81,7 @@ AmbientOcclusion::AmbientOcclusion(unsigned w, unsigned h, float depth_ratio): occlusion.set_mag_filter(NEAREST); occlusion.set_wrap(CLAMP_TO_EDGE); fbo.attach(COLOR_ATTACHMENT0, occlusion, 0); + fbo.require_complete(); combine_texturing.attach(2, occlusion); diff --git a/source/bloom.cpp b/source/bloom.cpp index fdd11703..ad7ec269 100644 --- a/source/bloom.cpp +++ b/source/bloom.cpp @@ -59,6 +59,8 @@ Bloom::Bloom(unsigned w, unsigned h): tex[i].set_min_filter(NEAREST); tex[i].set_wrap(CLAMP_TO_EDGE); tex[i].storage(RGB16F, w, h); + fbo[i].attach(COLOR_ATTACHMENT0, tex[i], 0); + fbo[i].require_complete(); } combine_shdata.uniform("source", 1); @@ -104,11 +106,10 @@ void Bloom::render(const Texture2D &src, const Texture2D &) { Bind bind_shader(blur_shader); blur_shdata_common.apply(); - Bind bind_fbo(fbo, true); for(unsigned i=0; i<2; ++i) { + Bind bind_fbo(fbo[i], true); Bind bind_tex(i ? tex[0] : src); - fbo.attach(COLOR_ATTACHMENT0, tex[i], 0); blur_shdata[i].apply(); quad.draw(); } diff --git a/source/bloom.h b/source/bloom.h index 1d9a654a..9f1d93dc 100644 --- a/source/bloom.h +++ b/source/bloom.h @@ -23,7 +23,7 @@ a blur filter. class Bloom: public PostProcessor { private: - Framebuffer fbo; + Framebuffer fbo[2]; Texture2D tex[2]; Program blur_shader; ProgramData blur_shdata_common; diff --git a/source/environmentmap.cpp b/source/environmentmap.cpp index 8cda8cba..82e1f1d9 100644 --- a/source/environmentmap.cpp +++ b/source/environmentmap.cpp @@ -20,6 +20,7 @@ EnvironmentMap::EnvironmentMap(unsigned s, Renderable &r, Renderable &e): { fbo[i].attach(COLOR_ATTACHMENT0, env_tex, TextureCube::enumerate_faces(i), 0); fbo[i].attach(DEPTH_ATTACHMENT, depth_buf); + fbo[i].require_complete(); } // XXX Make the depth range configurable diff --git a/source/shadowmap.cpp b/source/shadowmap.cpp index 6f62870b..c4dd07b0 100644 --- a/source/shadowmap.cpp +++ b/source/shadowmap.cpp @@ -29,6 +29,7 @@ ShadowMap::ShadowMap(unsigned s, const Renderable &r, const Light &l): depth_buf.set_wrap(CLAMP_TO_EDGE); depth_buf.storage(DEPTH_COMPONENT, size, size); fbo.attach(DEPTH_ATTACHMENT, depth_buf, 0); + fbo.require_complete(); set_darkness(0.7); set_texture_unit(3);