X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fpipelinebuilder.cpp;h=fcd5efbc18a6b3829d870465747f90800cbd0494;hb=d6f8db673345501a29231890b52cbdfce4a8ecf8;hp=cbf181fe6e81ee3588ed341f48f7537ac7d55ebd;hpb=18240e2bb031551e9c72a55c7d974904d209760a;p=libs%2Fgl.git diff --git a/source/pipelinebuilder.cpp b/source/pipelinebuilder.cpp index cbf181fe..fcd5efbc 100644 --- a/source/pipelinebuilder.cpp +++ b/source/pipelinebuilder.cpp @@ -17,6 +17,10 @@ PipelineBuilder::PipelineBuilder(const PipelineTemplate &t): const vector &passes = tmpl.get_passes(); for(vector::const_iterator i=passes.begin(); i!=passes.end(); ++i) renderables[i->renderable_name] = 0; + const vector &postprocs = tmpl.get_postprocessors(); + for(PipelineTemplate::PostProcessorArray::const_iterator i=postprocs.begin(); i!=postprocs.end(); ++i) + if(!i->slot_name.empty()) + postprocessors[i->slot_name] = 0; } void PipelineBuilder::set_renderable(const string &name, Renderable &rend) @@ -24,6 +28,11 @@ void PipelineBuilder::set_renderable(const string &name, Renderable &rend) get_item(renderables, name) = &rend; } +void PipelineBuilder::set_postprocessor(const string &name, PostProcessor &pproc) +{ + get_item(postprocessors, name) = &pproc; +} + void PipelineBuilder::build(Pipeline &pipeline) const { pipeline.set_hdr(tmpl.get_hdr()); @@ -49,11 +58,27 @@ void PipelineBuilder::build(Pipeline &pipeline) const const PipelineTemplate::PostProcessorArray &postprocs = tmpl.get_postprocessors(); for(PipelineTemplate::PostProcessorArray::const_iterator i=postprocs.begin(); i!=postprocs.end(); ++i) { - PostProcessor *proc = (*i)->create(pipeline.get_width(), pipeline.get_height()); - pipeline.add_postprocessor_owned(proc); + PostProcessor *proc = 0; + if(!i->slot_name.empty()) + proc = get_item(postprocessors, i->slot_name); + if(proc) + pipeline.add_postprocessor(*proc); + else if(i->postprocessor_template) + { + proc = i->postprocessor_template->create(pipeline.get_width(), pipeline.get_height()); + if(proc) + pipeline.add_postprocessor_owned(proc); + } } } +Pipeline *PipelineBuilder::build(unsigned w, unsigned h) const +{ + RefPtr pipeline = new Pipeline(w, h); + build(*pipeline); + return pipeline.release(); +} + Pipeline *PipelineBuilder::build(const View &view) const { RefPtr pipeline = new Pipeline(view); @@ -61,5 +86,12 @@ Pipeline *PipelineBuilder::build(const View &view) const return pipeline.release(); } +Pipeline *PipelineBuilder::build(const Framebuffer &fbo) const +{ + RefPtr pipeline = new Pipeline(fbo); + build(*pipeline); + return pipeline.release(); +} + } // namespace GL } // namespace Msp