1 #ifndef SEQUENCETEMPLATE_H_
2 #define SEQUENCETEMPLATE_H_
6 #include <msp/core/typeregistry.h>
7 #include <msp/datafile/objectloader.h>
9 #include "postprocessor.h"
10 #include "predicate.h"
19 class SequenceTemplate
22 class PostProcLoader: virtual public DataFile::Loader
28 void operator()(const std::string &kw, PostProcLoader &ldr) const { ldr.add(kw, &PostProcLoader::postprocessor<T>); }
32 RefPtr<PostProcessor::Template> postproc;
37 PostProcessor::Template *get_postprocessor_template() { return postproc.release(); }
40 virtual void postprocessor_loaded() { }
46 friend class SequenceTemplate;
50 class Loader: public DataFile::CollectionObjectLoader<SequenceTemplate, Resources>, public PostProcLoader
53 Loader(SequenceTemplate &, Collection &);
55 virtual void postprocessor_loaded();
56 void multisample(unsigned);
57 void multisample_range(unsigned, unsigned);
58 void postprocessor(const std::string &);
59 void step(const std::string &);
60 void step_with_slot(const std::string &, const std::string &);
65 class Loader: public DataFile::CollectionObjectLoader<Step>
69 Loader(Step &, Collection &);
73 void blend(BlendFactor, BlendFactor);
74 void blend_predefined(const std::string &);
75 void depth_test(Predicate);
76 void depth_test_predefined(const std::string &);
77 void lighting(const std::string &);
78 void lighting_inline();
79 void object(const std::string &);
80 void scene(const std::string &);
84 RefPtr<Lighting> lighting;
85 RefPtr<const DepthTest> depth_test;
86 RefPtr<const Blend> blend;
87 std::string slot_name;
88 Renderable *default_renderable;
95 GL::PostProcessor::Template *postprocessor_template;
96 std::string slot_name;
98 PostProcessor(GL::PostProcessor::Template * = 0);
101 typedef std::vector<PostProcessor> PostProcessorArray;
104 typedef TypeRegistry<PostProcLoader::AddPostProc, PostProcLoader &> PostProcessorRegistry;
106 Resources *resources;
109 unsigned required_multisample;
110 unsigned max_multisample;
111 std::vector<Step> steps;
112 PostProcessorArray postprocessors;
118 Resources &get_resources() const;
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 std::vector<Step> &get_steps() const { return steps; }
124 const PostProcessorArray &get_postprocessors() const { return postprocessors; }
127 static void register_postprocessor(const std::string &);
129 static PostProcessorRegistry &get_postprocessor_registry();
133 void SequenceTemplate::register_postprocessor(const std::string &kw)
135 get_postprocessor_registry().register_type<T>(kw);
139 void SequenceTemplate::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();