]> git.tdb.fi Git - libs/gl.git/commitdiff
Disable blend and depth test while rendering Bloom
authorMikko Rasa <tdb@tdb.fi>
Sun, 26 Jul 2009 19:06:34 +0000 (19:06 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 26 Jul 2009 19:06:34 +0000 (19:06 +0000)
Restore original FBO after rendering ShadowMap

source/bloom.cpp
source/shadowmap.cpp

index b9e626989e1e585def0f45395cf6e5ff7ac1f016..b74bde80f970dd16f597452963a3863b7e2e50d3 100644 (file)
@@ -7,8 +7,11 @@ Distributed under the LGPL
 
 #include <cmath>
 #include <msp/strings/formatter.h>
+#include "blend.h"
 #include "bloom.h"
 #include "meshbuilder.h"
+#include "misc.h"
+#include "tests.h"
 #include "texunit.h"
 
 using namespace std;
@@ -130,6 +133,8 @@ void Bloom::render(const Texture2D &src)
        blur_shader.bind();
        fbo.bind();
        src.bind_to(0);
+       disable(DEPTH_TEST);
+       disable(BLEND);
        for(unsigned i=0; i<2; ++i)
        {
                fbo.attach(COLOR_ATTACHMENT0, tex[i], 0);
@@ -151,6 +156,9 @@ void Bloom::render(const Texture2D &src)
        Texture::unbind();
        TexUnit::activate(0);
        Texture::unbind();
+       // XXX Should check if the modes were enabled in the first place
+       enable(DEPTH_TEST);
+       enable(BLEND);
 }
 
 } // namespace GL
index 9c8b57bf938ebfc6c87a37a138bc35b72b7a858a..3691773ad3f58d9ae41ffb1148291b10acd08d32 100644 (file)
@@ -95,7 +95,8 @@ void ShadowMap::prepare()
                push_matrix();
                load_matrix(matrix);
 
-               Bind _bind_fbo(fbo);
+               const Framebuffer *old_fbo=Framebuffer::current();
+               fbo.bind();
                glViewport(0, 0, size, size);
                glClear(GL_DEPTH_BUFFER_BIT);
                scene.render("shadow");
@@ -104,6 +105,10 @@ void ShadowMap::prepare()
                pop_matrix();
                matrix_mode(MODELVIEW);
                pop_matrix();
+               if(old_fbo)
+                       old_fbo->bind();
+               else
+                       Framebuffer::unbind();
        }
 
        depth_buf.bind_to(3);