X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpipeline.cpp;h=bcbbb05fe3b63aa0064c6e71db0fa5142f28d867;hb=89d3d10b75a42f86b224feb00b20283af66c0b01;hp=d7e175de7185fe39fcf890c2c8eeb89c8986346a;hpb=6cfe786e84d9d9474c7bd5a78d1b5c92e3868e4e;p=libs%2Fgl.git diff --git a/source/pipeline.cpp b/source/pipeline.cpp index d7e175de..bcbbb05f 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -40,8 +40,17 @@ void Pipeline::set_hdr(bool h) if(h==hdr) return; + bool old_hdr= hdr; hdr = h; - create_targets(2); + try + { + create_targets(2); + } + catch(...) + { + hdr = old_hdr; + throw; + } } void Pipeline::set_multisample(unsigned s) @@ -111,7 +120,15 @@ void Pipeline::remove_renderable(const Renderable &r) void Pipeline::add_postprocessor(PostProcessor &pp) { postproc.push_back(&pp); - create_targets(0); + try + { + create_targets(0); + } + catch(...) + { + postproc.pop_back(); + throw; + } } void Pipeline::setup_frame() const @@ -147,9 +164,7 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const 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); + // XXX Make sure the correct FBO is restored if an exception is thrown if(target[0]) { @@ -169,6 +184,8 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const renderer.render(*j->renderable, i->get_tag()); } + renderer.end(); + if(target[0]) { if(samples)