From: Mikko Rasa Date: Sun, 26 Jul 2009 19:06:34 +0000 (+0000) Subject: Disable blend and depth test while rendering Bloom X-Git-Tag: 1.1~3 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=ac7c744dfb6e87481eea7081b84c5ae2f585ee7b;p=libs%2Fgl.git Disable blend and depth test while rendering Bloom Restore original FBO after rendering ShadowMap --- diff --git a/source/bloom.cpp b/source/bloom.cpp index b9e62698..b74bde80 100644 --- a/source/bloom.cpp +++ b/source/bloom.cpp @@ -7,8 +7,11 @@ Distributed under the LGPL #include #include +#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 diff --git a/source/shadowmap.cpp b/source/shadowmap.cpp index 9c8b57bf..3691773a 100644 --- a/source/shadowmap.cpp +++ b/source/shadowmap.cpp @@ -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);