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)
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)
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
if(!in_frame)
setup_frame();
+ const Framebuffer *out_fbo = Framebuffer::current();
+ // XXX Make sure the correct FBO is restored if an exception is thrown
+
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);
}
{
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()))
renderer.render(*j->renderable, i->get_tag());
}
+ renderer.end();
+
if(target[0])
{
if(samples)
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)