]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pipeline.cpp
Store and expose the projection matrix
[libs/gl.git] / source / pipeline.cpp
index 59e6bbb843c40bbf470087eb63b7bf9a8fa9f987..0df03ca7df7231931874355f855de9c3284cd148 100644 (file)
@@ -137,10 +137,14 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const
        if(!in_frame)
                setup_frame();
 
+       const Framebuffer *out_fbo = Framebuffer::current();
+       /* Binding the current object is a no-op, but this will restore the original
+       FBO in case an exception is thrown. */
+       Bind restore_fbo(out_fbo, true);
+
        if(target[0])
        {
                Framebuffer &fbo = (samples ? target_ms->fbo : target[0]->fbo);
-               // XXX exception safety
                fbo.bind();
                fbo.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
        }
@@ -149,7 +153,7 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const
        {
                Bind bind_depth_test(i->get_depth_test());
                Bind bind_blend(i->get_blend());
-               Bind bind_lighting(i->get_lighting());
+               renderer.set_lighting(i->get_lighting());
 
                for(vector<Slot>::const_iterator j=renderables.begin(); j!=renderables.end(); ++j)
                        if(j->passes.empty() || j->passes.count(i->get_tag()))
@@ -167,11 +171,11 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const
                        if(i+1<postproc.size())
                                target[1-j]->fbo.bind();
                        else
-                               Framebuffer::unbind();
+                               out_fbo->bind();
                        postproc[i]->render(target[j]->color, target[j]->depth);
                }
 
-               Framebuffer::unbind();
+               out_fbo->bind();
        }
 
        if(!was_in_frame)