1 #ifndef PIPELINETEMPLATE_H_
2 #define PIPELINETEMPLATE_H_
6 #include <msp/datafile/loadabletyperegistry.h>
7 #include <msp/datafile/objectloader.h>
9 #include "postprocessor.h"
10 #include "predicate.h"
18 class PipelineTemplate
21 class PostProcLoader: virtual public DataFile::Loader
27 static void add(PostProcLoader &ldr, const std::string &kw) { ldr.add(kw, &PostProcLoader::postprocessor<T>); }
31 RefPtr<PostProcessor::Template> postproc;
36 PostProcessor::Template *get_postprocessor_template() { return postproc.release(); }
39 virtual void postprocessor_loaded() { }
45 friend class PipelineTemplate;
49 class Loader: public DataFile::CollectionObjectLoader<PipelineTemplate>, public PostProcLoader
52 Loader(PipelineTemplate &);
53 Loader(PipelineTemplate &, Collection &);
57 virtual void postprocessor_loaded();
58 void multisample(unsigned);
59 void multisample_range(unsigned, unsigned);
60 void pass(const std::string &, const std::string &);
61 void postprocessor(const std::string &);
66 class Loader: public DataFile::CollectionObjectLoader<Pass>
70 Loader(Pass &, Collection &);
74 void blend(BlendFactor, BlendFactor);
75 void blend_predefined(const std::string &);
76 void depth_test(Predicate);
77 void depth_test_predefined(const std::string &);
78 void lighting(const std::string &);
79 void lighting_inline();
80 // TODO requires support for scenes in Resources
81 //void scene(const std::string &);
85 RefPtr<Lighting> lighting;
86 RefPtr<const DepthTest> depth_test;
87 RefPtr<const Blend> blend;
88 std::string renderable_name;
89 //Renderable *default_renderable;
96 GL::PostProcessor::Template *postprocessor_template;
97 std::string slot_name;
99 PostProcessor(GL::PostProcessor::Template * = 0);
102 typedef std::vector<Pass> PassArray;
103 typedef std::vector<PostProcessor> PostProcessorArray;
106 typedef DataFile::LoadableTypeRegistry<PostProcLoader, PostProcLoader::AddPostProc> PostProcessorRegistry;
110 unsigned required_multisample;
111 unsigned max_multisample;
113 PostProcessorArray postprocessors;
119 bool get_hdr() const { return hdr; }
120 bool get_alpha() const { return alpha; }
121 unsigned get_required_multisample() const { return required_multisample; }
122 unsigned get_maximum_multisample() const { return max_multisample; }
123 const PassArray &get_passes() const { return passes; }
124 const PostProcessorArray &get_postprocessors() const { return postprocessors; }
127 static void register_postprocessor(const std::string &);
129 static PostProcessorRegistry &get_postprocessor_registry();
133 void PipelineTemplate::register_postprocessor(const std::string &kw)
135 get_postprocessor_registry().register_type<T>(kw);
139 void PipelineTemplate::PostProcLoader::postprocessor()
142 throw std::logic_error("Only one postprocessor allowed per slot");
143 RefPtr<typename T::Template> pp = new typename T::Template;
147 postprocessor_loaded();