1 #include <msp/core/maputils.h>
2 #include <msp/datafile/collection.h>
5 #include "colorcurve.h"
7 #include "pipelinetemplate.h"
15 PipelineTemplate::PipelineTemplate():
17 required_multisample(0),
22 PipelineTemplate::Pass::~Pass()
26 PipelineTemplate::Loader::Loader(PipelineTemplate &t):
27 DataFile::CollectionObjectLoader<PipelineTemplate>(t, 0)
32 PipelineTemplate::Loader::Loader(PipelineTemplate &t, Collection &c):
33 DataFile::CollectionObjectLoader<PipelineTemplate>(t, &c)
38 void PipelineTemplate::Loader::init()
40 add("bloom", &Loader::postprocessor<Bloom>);
41 add("colorcurve", &Loader::postprocessor<ColorCurve>);
42 add("hdr", &PipelineTemplate::hdr);
43 add("multisample", &Loader::multisample);
44 add("multisample", &Loader::multisample_range);
45 add("pass", &Loader::pass);
48 void PipelineTemplate::Loader::multisample(unsigned samples)
50 obj.required_multisample = samples;
51 obj.max_multisample = samples;
54 void PipelineTemplate::Loader::multisample_range(unsigned req, unsigned max)
56 obj.required_multisample = req;
57 obj.max_multisample = max;
60 void PipelineTemplate::Loader::pass(const string &tag, const string &rend)
64 pss.renderable_name = rend;
70 obj.passes.push_back(pss);
74 void PipelineTemplate::Loader::postprocessor()
76 RefPtr<typename T::Template> postproc = new typename T::Template;
78 obj.postprocessors.push_back(postproc.release());
82 PipelineTemplate::Pass::Loader::Loader(Pass &p):
83 DataFile::CollectionObjectLoader<Pass>(p, 0)
88 PipelineTemplate::Pass::Loader::Loader(Pass &p, Collection &c):
89 DataFile::CollectionObjectLoader<Pass>(p, &c)
94 void PipelineTemplate::Pass::Loader::init()
96 add("blend", &Loader::blend);
97 add("blend", &Loader::blend_predefined);
98 add("depth_test", &Loader::depth_test);
99 add("depth_test", &Loader::depth_test_predefined);
100 add("lighting", &Loader::lighting);
101 add("lighting", &Loader::lighting_inline);
104 void PipelineTemplate::Pass::Loader::blend_predefined(const string &name)
106 const Blend *blend = 0;
108 blend = &Blend::alpha();
109 else if(name=="additive")
110 blend = &Blend::additive();
111 else if(name=="additive_alpha")
112 blend = &Blend::additive_alpha();
114 throw key_error(name);
120 void PipelineTemplate::Pass::Loader::blend(BlendFactor src, BlendFactor dest)
122 obj.blend = new Blend(src, dest);
125 void PipelineTemplate::Pass::Loader::depth_test_predefined(const string &name)
127 const DepthTest *dtest = 0;
129 dtest = &DepthTest::lequal();
131 throw key_error(name);
133 obj.depth_test = dtest;
134 obj.depth_test.keep();
137 void PipelineTemplate::Pass::Loader::depth_test(Predicate pred)
139 obj.depth_test = new DepthTest(pred);
142 void PipelineTemplate::Pass::Loader::lighting_inline()
144 RefPtr<Lighting> lightn = new Lighting;
146 obj.lighting = lightn;
149 void PipelineTemplate::Pass::Loader::lighting(const string &name)
151 obj.lighting = &get_collection().get<Lighting>(name);
155 /*void PipelineTemplate::Pass::Loader::scene(const string &name)
157 obj.default_renderable = get_collection().get<Scene>(name);