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, Resources>, public PostProcLoader
52 Loader(PipelineTemplate &, Collection &);
54 virtual void postprocessor_loaded();
55 void multisample(unsigned);
56 void multisample_range(unsigned, unsigned);
57 void pass(const std::string &, const std::string &);
58 void postprocessor(const std::string &);
63 class Loader: public DataFile::CollectionObjectLoader<Pass>
67 Loader(Pass &, Collection &);
71 void blend(BlendFactor, BlendFactor);
72 void blend_predefined(const std::string &);
73 void depth_test(Predicate);
74 void depth_test_predefined(const std::string &);
75 void lighting(const std::string &);
76 void lighting_inline();
77 // TODO requires support for scenes in Resources
78 //void scene(const std::string &);
82 RefPtr<Lighting> lighting;
83 RefPtr<const DepthTest> depth_test;
84 RefPtr<const Blend> blend;
85 std::string renderable_name;
86 //Renderable *default_renderable;
93 GL::PostProcessor::Template *postprocessor_template;
94 std::string slot_name;
96 PostProcessor(GL::PostProcessor::Template * = 0);
99 typedef std::vector<Pass> PassArray;
100 typedef std::vector<PostProcessor> PostProcessorArray;
103 typedef DataFile::LoadableTypeRegistry<PostProcLoader, PostProcLoader::AddPostProc> PostProcessorRegistry;
105 Resources *resources;
108 unsigned required_multisample;
109 unsigned max_multisample;
111 PostProcessorArray postprocessors;
117 Resources &get_resources() const;
118 bool get_hdr() const { return hdr; }
119 bool get_alpha() const { return alpha; }
120 unsigned get_required_multisample() const { return required_multisample; }
121 unsigned get_maximum_multisample() const { return max_multisample; }
122 const PassArray &get_passes() const { return passes; }
123 const PostProcessorArray &get_postprocessors() const { return postprocessors; }
126 static void register_postprocessor(const std::string &);
128 static PostProcessorRegistry &get_postprocessor_registry();
132 void PipelineTemplate::register_postprocessor(const std::string &kw)
134 get_postprocessor_registry().register_type<T>(kw);
138 void PipelineTemplate::PostProcLoader::postprocessor()
141 throw std::logic_error("Only one postprocessor allowed per slot");
142 RefPtr<typename T::Template> pp = new typename T::Template;
146 postprocessor_loaded();