From 0119ca4f792dc761e5248b76de71f2844c0e3997 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 18 Jun 2013 17:38:29 +0300 Subject: [PATCH] Render final pipeline output into the bound framebuffer --- source/pipeline.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/pipeline.cpp b/source/pipeline.cpp index 59e6bbb8..c6260f0e 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -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); } @@ -167,11 +171,11 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const if(i+1fbo.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) -- 2.45.2