- Bind bind_depth_test(pass.depth_test);
- Bind bind_blend(pass.blend);
- Bind bind_lighting(pass.lighting);
+ const Framebuffer *out_fbo = Framebuffer::current();
+ // These are no-ops but will ensure the related state gets restored
+ BindRestore restore_fbo(out_fbo);
+ BindRestore restore_depth_test(DepthTest::current());
+ BindRestore restore_blend(Blend::current());
+
+ if(target[0])
+ {
+ Framebuffer &fbo = (samples ? target_ms : target[0])->get_framebuffer();
+ fbo.bind();
+ fbo.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
+ }
+
+ for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i)
+ {
+ if(const DepthTest *dt = i->get_depth_test())
+ dt->bind();
+ else
+ DepthTest::unbind();
+
+ if(const Blend *b = i->get_blend())
+ b->bind();
+ else
+ Blend::unbind();
+
+ renderer.set_lighting(i->get_lighting());
+ renderer.set_clipping(i->get_clipping());
+
+ if(const Renderable *renderable = i->get_renderable())
+ renderer.render(*renderable, i->get_tag());
+
+ 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());
+ }