X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpipelinebuilder.cpp;fp=source%2Fpipelinebuilder.cpp;h=cbf181fe6e81ee3588ed341f48f7537ac7d55ebd;hb=18240e2bb031551e9c72a55c7d974904d209760a;hp=0000000000000000000000000000000000000000;hpb=e6bd08e977f3138bfcfa3a1b6cc45201c383e016;p=libs%2Fgl.git diff --git a/source/pipelinebuilder.cpp b/source/pipelinebuilder.cpp new file mode 100644 index 00000000..cbf181fe --- /dev/null +++ b/source/pipelinebuilder.cpp @@ -0,0 +1,65 @@ +#include +#include +#include "error.h" +#include "pipeline.h" +#include "pipelinebuilder.h" +#include "pipelinetemplate.h" +#include "renderbuffer.h" + +using namespace std; + +namespace Msp { +namespace GL { + +PipelineBuilder::PipelineBuilder(const PipelineTemplate &t): + tmpl(t) +{ + const vector &passes = tmpl.get_passes(); + for(vector::const_iterator i=passes.begin(); i!=passes.end(); ++i) + renderables[i->renderable_name] = 0; +} + +void PipelineBuilder::set_renderable(const string &name, Renderable &rend) +{ + get_item(renderables, name) = &rend; +} + +void PipelineBuilder::build(Pipeline &pipeline) const +{ + pipeline.set_hdr(tmpl.get_hdr()); + unsigned samples = min(tmpl.get_maximum_multisample(), Renderbuffer::get_max_samples()); + if(samplesrenderable_name); + if(!renderable) + continue; + + Pipeline::Pass &pass = pipeline.add_pass(i->tag, *renderable); + pass.set_blend(i->blend.get()); + pass.set_depth_test(i->depth_test.get()); + pass.set_lighting(i->lighting.get()); + } + + 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); + } +} + +Pipeline *PipelineBuilder::build(const View &view) const +{ + RefPtr pipeline = new Pipeline(view); + build(*pipeline); + return pipeline.release(); +} + +} // namespace GL +} // namespace Msp