1 #ifndef SEQUENCETEMPLATE_H_
2 #define SEQUENCETEMPLATE_H_
6 #include <msp/core/typeregistry.h>
7 #include <msp/datafile/dynamicobjectloader.h>
8 #include <msp/datafile/objectloader.h>
11 #include "postprocessor.h"
12 #include "resources.h"
13 #include "stenciltest.h"
21 class SequenceTemplate
25 class TemplateLoader: public DataFile::DynamicObjectLoader<typename T::Template>
27 friend class SequenceTemplate;
30 TemplateLoader(typename DataFile::DynamicObjectLoader<typename T::Template>::Collection &c): DataFile::DynamicObjectLoader<typename T::Template>(&c) { }
33 virtual typename DataFile::DynamicObjectLoader<typename T::Template>::TypeRegistry &get_type_registry() const { return get_registry<T>(); }
37 using TemplateRegistry = typename TemplateLoader<T>::TypeRegistry;
40 class Loader: public DataFile::CollectionObjectLoader<SequenceTemplate>
43 static ActionMap shared_actions;
46 Loader(SequenceTemplate &, Collection &);
48 virtual void init_actions();
51 void effect(const std::string &);
52 void multisample(unsigned);
53 void multisample_range(unsigned, unsigned);
55 void postprocessor_with_slot(const std::string &);
56 void renderable(const std::string &);
57 void renderable_with_default(const std::string &, const std::string &);
58 void sequence(const std::string &, const std::string &);
59 void step(const std::string &, const std::string &);
64 Effect::Template *effect_template = 0;
65 GL::Renderable *renderable = 0;
66 SequenceTemplate *sequence_template = 0;
67 std::map<std::string, std::string> sequence_renderables;
68 std::string slot_name;
73 class Loader: public DataFile::CollectionObjectLoader<Step>
76 std::string inline_base_name;
78 static ActionMap shared_actions;
81 Loader(Step &, Collection &);
83 virtual void init_actions();
86 void set_inline_base_name(const std::string &);
90 void depth_compare(Predicate);
91 void lighting(const std::string &);
92 void lighting_inline();
97 const Lighting *lighting = 0;
99 StencilTest stencil_test;
100 std::string renderable_name;
105 GL::PostProcessor::Template *postprocessor_template;
106 std::string slot_name;
108 PostProcessor(GL::PostProcessor::Template * = 0);
112 class ClearLoader: public DataFile::ObjectLoader<SequenceTemplate>
115 static ActionMap shared_actions;
118 ClearLoader(SequenceTemplate &);
120 virtual void init_actions();
122 void color(float, float, float, float);
127 class SequenceLoader: public DataFile::ObjectLoader<Renderable>
130 static ActionMap shared_actions;
133 SequenceLoader(Renderable &);
135 virtual void init_actions();
137 void renderable(const std::string &, const std::string &);
141 unsigned required_multisample = 0;
142 unsigned max_multisample = 0;
143 std::vector<Renderable> renderables;
144 std::vector<Step> steps;
145 std::vector<PostProcessor> postprocessors;
146 bool clear_enabled = false;
147 std::vector<Color> clear_colors;
148 float clear_depth = 1.0f;
149 int clear_stencil = 0;
154 bool get_hdr() const { return hdr; }
155 unsigned get_required_multisample() const { return required_multisample; }
156 unsigned get_maximum_multisample() const { return max_multisample; }
157 const std::vector<Renderable> &get_renderables() const { return renderables; }
158 const std::vector<Step> &get_steps() const { return steps; }
159 const std::vector<PostProcessor> &get_postprocessors() const { return postprocessors; }
160 bool is_clear_enabled() const { return clear_enabled; }
161 const std::vector<Color> &get_clear_colors() const { return clear_colors; }
162 float get_clear_depth() const { return clear_depth; }
163 int get_clear_stencil() const { return clear_stencil; }
166 static void register_effect(const std::string &);
169 static void register_postprocessor(const std::string &);
173 static TemplateRegistry<T> &get_registry();
177 void SequenceTemplate::register_effect(const std::string &kw)
179 get_registry<Effect>().register_type<typename T::Template>(kw);
183 void SequenceTemplate::register_postprocessor(const std::string &kw)
185 get_registry<GL::PostProcessor>().register_type<typename T::Template>(kw);