X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpipeline.cpp;h=466aa23c69b6b3107457817f8efea8f33aa829ac;hb=cd1f63c76463bb5ba78f6c3bb13aa40a97f1e004;hp=2dd178f247a53b97d26f74bbfe526292e21ae4d2;hpb=2e6a73a93eac0a18063ec675a24a8e6eeeb80a0c;p=libs%2Fgl.git diff --git a/source/pipeline.cpp b/source/pipeline.cpp index 2dd178f2..466aa23c 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -21,7 +21,8 @@ Pipeline::Pipeline(unsigned w, unsigned h, bool d): height(h), hdr(d), samples(0), - target_ms(0) + target_ms(0), + in_frame(false) { target[0] = 0; target[1] = 0; @@ -98,6 +99,20 @@ void Pipeline::add_postprocessor(PostProcessor &pp) create_targets(false); } +void Pipeline::setup_frame() const +{ + in_frame = true; + for(vector::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) + i->renderable->setup_frame(); +} + +void Pipeline::finish_frame() const +{ + in_frame = false; + for(vector::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) + i->renderable->finish_frame(); +} + void Pipeline::render(const Tag &tag) const { if(tag.id) @@ -112,6 +127,10 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const if(tag.id) return; + bool was_in_frame = in_frame; + if(!in_frame) + setup_frame(); + if(target[0]) { Framebuffer &fbo = (samples ? target_ms->fbo : target[0]->fbo); @@ -148,6 +167,9 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const Framebuffer::unbind(); } + + if(!was_in_frame) + finish_frame(); } void Pipeline::create_targets(bool recreate)