]> git.tdb.fi Git - libs/gl.git/blobdiff - source/bloom.cpp
Allocate textures attached to framebuffers automatically
[libs/gl.git] / source / bloom.cpp
index 3993c8c901b9a01c66e621af65d6bcefc5ebc1f7..0e5ce9d616d9f6827aec8b80b029e87c15e0aba0 100644 (file)
@@ -76,8 +76,7 @@ Bloom::Bloom(unsigned w, unsigned h):
        {
                blur_shdata[i].uniform(loc, 0);
                tex[i].set_min_filter(NEAREST);
-               tex[i].storage(RGB16F, w, h, 0);
-               tex[i].image(0, RGB, UNSIGNED_BYTE, 0);
+               tex[i].storage(RGB16F, w, h);
        }
 
        combine_shdata.uniform(combine_shader.get_uniform_location("source"), 1);
@@ -133,8 +132,8 @@ void Bloom::render(const Texture2D &src)
        blur_shader.bind();
        fbo.bind();
        src.bind_to(0);
-       disable(DEPTH_TEST);
-       disable(BLEND);
+       Bind unbind_dtest(static_cast<DepthTest *>(0), true);
+       Bind unbind_blend(static_cast<Blend *>(0), true);
        for(unsigned i=0; i<2; ++i)
        {
                fbo.attach(COLOR_ATTACHMENT0, tex[i], 0);
@@ -155,9 +154,6 @@ void Bloom::render(const Texture2D &src)
        Program::unbind();
        Texture::unbind_from(1);
        Texture::unbind_from(0);
-       // XXX Should check if the modes were enabled in the first place
-       enable(DEPTH_TEST);
-       enable(BLEND);
 }
 
 } // namespace GL