]> git.tdb.fi Git - libs/gl.git/commitdiff
Verify framebuffer completeness in effect constructors
authorMikko Rasa <tdb@tdb.fi>
Sat, 29 Dec 2012 17:51:55 +0000 (19:51 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 29 Dec 2012 17:51:55 +0000 (19:51 +0200)
This avoids silent failures due to an unsupported framebuffer
configuration.

source/ambientocclusion.cpp
source/bloom.cpp
source/bloom.h
source/environmentmap.cpp
source/shadowmap.cpp

index c02daf52a6942cd24af3a6c5dc34dd578419da43..4ef376251a6a065013666f85bfe4803db1b4f2e9 100644 (file)
@@ -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);
 
index fdd11703f6ceb565e20c91140df53cecda2fe8ba..ad7ec26943c4230a97ec0a5f0b30750f7680a22f 100644 (file)
@@ -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();
                }
index 1d9a654a87da0a875124d4cd2f6e67fc253a3ca0..9f1d93dcece4174c0912a8671bc0e98b2bb793b5 100644 (file)
@@ -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;
index 8cda8cbae63b7e7505dd26a1c73d17dfc4ee4db0..82e1f1d9ad86774d2c716306aebc5b03b012c369 100644 (file)
@@ -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
index 6f62870be5c73b7f8a5420ac72851f3b05ae4676..c4dd07b03dbdb288fa55bda158dc305386813d70 100644 (file)
@@ -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);