X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpipeline.cpp;h=1833001ff1288fb00257450fe694bd9e44ae62a1;hb=cdfdcecd046c494470bfb4cc1de66f6cfca5efec;hp=0df03ca7df7231931874355f855de9c3284cd148;hpb=31f4e9f522ba3009cfa74467bec380a263eabf73;p=libs%2Fgl.git diff --git a/source/pipeline.cpp b/source/pipeline.cpp index 0df03ca7..1833001f 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) @@ -49,8 +58,17 @@ void Pipeline::set_multisample(unsigned s) if(s==samples) return; + unsigned old_samples = samples; samples = s; - create_targets(1); + try + { + create_targets(1); + } + catch(...) + { + samples = old_samples; + throw; + } } void Pipeline::set_camera(const Camera *c) @@ -102,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 @@ -138,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]) { @@ -154,12 +178,15 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const Bind bind_depth_test(i->get_depth_test()); Bind bind_blend(i->get_blend()); renderer.set_lighting(i->get_lighting()); + renderer.set_clipping(i->get_clipping()); for(vector::const_iterator j=renderables.begin(); j!=renderables.end(); ++j) if(j->passes.empty() || j->passes.count(i->get_tag())) renderer.render(*j->renderable, i->get_tag()); } + renderer.end(); + if(target[0]) { if(samples) @@ -215,7 +242,8 @@ Pipeline::Pass::Pass(const Tag &t): tag(t), lighting(0), depth_test(0), - blend(0) + blend(0), + clipping(0) { } void Pipeline::Pass::set_lighting(const Lighting *l) @@ -233,6 +261,11 @@ void Pipeline::Pass::set_blend(const Blend *b) blend = b; } +void Pipeline::Pass::set_clipping(const Clipping *c) +{ + clipping =c; +} + Pipeline::Slot::Slot(const Renderable *r): renderable(r)