X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Fsequence.cpp;h=9161c75146cc7552ac5363e21d69700a7ff5b564;hb=c5583e23cc7b064ac28f2b2b6993d1e5fa415d5b;hp=b8fb6076e1fe5937ee8107aece475b5d3a763c44;hpb=e72f81ac7f8708daab71965cfc9949ea64fd8a94;p=libs%2Fgl.git diff --git a/source/render/sequence.cpp b/source/render/sequence.cpp index b8fb6076..9161c751 100644 --- a/source/render/sequence.cpp +++ b/source/render/sequence.cpp @@ -47,6 +47,9 @@ void Sequence::init(unsigned w, unsigned h) Sequence::~Sequence() { + for(vector::iterator i=postproc.begin(); i!=postproc.end(); ++i) + if(i->owned) + delete i->postproc; delete target[0]; delete target[1]; delete target_ms; @@ -114,25 +117,25 @@ Sequence::Step &Sequence::add_step(Tag tag, Renderable &r) void Sequence::add_postprocessor(PostProcessor &pp) { - add_postprocessor(&pp, true); + add_postprocessor(&pp, false); } void Sequence::add_postprocessor_owned(PostProcessor *pp) { - add_postprocessor(pp, false); + add_postprocessor(pp, true); } -void Sequence::add_postprocessor(PostProcessor *pp, bool keep) +void Sequence::add_postprocessor(PostProcessor *pp, bool owned) { - postproc.push_back(pp); - if(keep) - postproc.back().keep(); + postproc.push_back(PostProcStep(pp, owned)); try { create_targets(0); } catch(...) { + if(!owned) + delete pp; postproc.pop_back(); throw; } @@ -182,7 +185,8 @@ void Sequence::render(Renderer &renderer, Tag tag) const else Blend::unbind(); - renderer.set_lighting(i->get_lighting()); + if (const Lighting *lighting = i->get_lighting()) + renderer.add_shader_data(lighting->get_shader_data()); renderer.set_clipping(i->get_clipping()); if(const Renderable *renderable = i->get_renderable()) @@ -206,7 +210,7 @@ void Sequence::render(Renderer &renderer, Tag tag) const out_fbo->bind(); const Texture2D &color = target[j]->get_target_texture(RENDER_COLOR); const Texture2D &depth = target[j]->get_target_texture(RENDER_DEPTH); - postproc[i]->render(renderer, color, depth); + postproc[i].postproc->render(renderer, color, depth); } } } @@ -238,6 +242,33 @@ void Sequence::create_targets(unsigned recreate) if(!target_ms && samples) target_ms = new RenderTarget(width, height, samples, fmt); + +#ifdef DEBUG + if(!debug_name.empty()) + set_target_debug_names(); +#endif +} + +void Sequence::set_debug_name(const string &name) +{ +#ifdef DEBUG + debug_name = name; + if(!name.empty()) + set_target_debug_names(); +#else + (void)name; +#endif +} + +void Sequence::set_target_debug_names() +{ +#ifdef DEBUG + for(unsigned i=0; i<2; ++i) + if(target[i]) + target[i]->set_debug_name(format("%s [RT:%d]", debug_name, i)); + if(target_ms) + target_ms->set_debug_name(debug_name+" [RT:ms]"); +#endif }