]> git.tdb.fi Git - libs/gl.git/blobdiff - source/bloom.cpp
Give both color and depth buffers to postprocessors
[libs/gl.git] / source / bloom.cpp
index 5f2adc85c2bf592a8379d58ee9d3efc228fe055a..db10c3b26fc45b3c7b0c28ba4c51687ef964a13d 100644 (file)
@@ -75,9 +75,8 @@ Bloom::Bloom(unsigned w, unsigned h):
        for(unsigned i=0; i<2; ++i)
        {
                blur_shdata[i].uniform(loc, 0);
-               tex[i].storage(RGB16F, w, h, 0);
-               tex[i].image(0, RGB, UNSIGNED_BYTE, 0);
                tex[i].set_min_filter(NEAREST);
+               tex[i].storage(RGB16F, w, h);
        }
 
        combine_shdata.uniform(combine_shader.get_uniform_location("source"), 1);
@@ -127,14 +126,14 @@ void Bloom::set_strength(float s)
        combine_shdata.uniform(combine_shader.get_uniform_location("strength"), s);
 }
 
-void Bloom::render(const Texture2D &src)
+void Bloom::render(const Texture2D &src, const Texture2D &)
 {
        const Framebuffer *dest = Framebuffer::current();
        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);
@@ -153,12 +152,8 @@ void Bloom::render(const Texture2D &src)
        src.bind_to(1);
        quad.draw();
        Program::unbind();
-       Texture::unbind();
-       TexUnit::activate(0);
-       Texture::unbind();
-       // XXX Should check if the modes were enabled in the first place
-       enable(DEPTH_TEST);
-       enable(BLEND);
+       Texture::unbind_from(1);
+       Texture::unbind_from(0);
 }
 
 } // namespace GL