1 #ifndef SEQUENCETEMPLATE_H_
2 #define SEQUENCETEMPLATE_H_
6 #include <msp/core/typeregistry.h>
7 #include <msp/datafile/objectloader.h>
10 #include "postprocessor.h"
11 #include "resources.h"
12 #include "stenciltest.h"
20 class SequenceTemplate
23 class PostProcLoader: virtual public DataFile::Loader
29 void operator()(const std::string &kw, PostProcLoader &ldr) const { ldr.add(kw, &PostProcLoader::postprocessor<T>); }
33 RefPtr<PostProcessor::Template> postproc;
38 PostProcessor::Template *get_postprocessor_template() { return postproc.release(); }
41 virtual void postprocessor_loaded() { }
47 friend class SequenceTemplate;
51 class Loader: public DataFile::CollectionObjectLoader<SequenceTemplate, Resources>, public PostProcLoader
54 Loader(SequenceTemplate &, Collection &);
56 virtual void postprocessor_loaded();
58 void multisample(unsigned);
59 void multisample_range(unsigned, unsigned);
60 void postprocessor(const std::string &);
61 void step(const std::string &);
62 void step_with_slot(const std::string &, const std::string &);
67 class Loader: public DataFile::CollectionObjectLoader<Step>
70 std::string inline_base_name;
73 Loader(Step &, Collection &);
75 void set_inline_base_name(const std::string &);
79 void blend_factors(BlendFactor, BlendFactor);
81 void depth_compare(Predicate);
82 void lighting(const std::string &);
83 void lighting_inline();
84 void object(const std::string &);
85 void scene(const std::string &);
90 const Lighting *lighting = 0;
92 StencilTest stencil_test;
94 std::string slot_name;
95 Renderable *default_renderable = 0;
100 GL::PostProcessor::Template *postprocessor_template;
101 std::string slot_name;
103 PostProcessor(GL::PostProcessor::Template * = 0);
107 class ClearLoader: public DataFile::ObjectLoader<SequenceTemplate>
110 ClearLoader(SequenceTemplate &);
113 void color(float, float, float, float);
118 typedef TypeRegistry<PostProcLoader::AddPostProc, PostProcLoader &> PostProcessorRegistry;
122 unsigned required_multisample = 0;
123 unsigned max_multisample = 0;
124 std::vector<Step> steps;
125 std::vector<PostProcessor> postprocessors;
126 bool clear_enabled = false;
127 std::vector<Color> clear_colors;
128 float clear_depth = 1.0f;
129 int clear_stencil = 0;
134 bool get_hdr() const { return hdr; }
135 bool get_alpha() const { return alpha; }
136 unsigned get_required_multisample() const { return required_multisample; }
137 unsigned get_maximum_multisample() const { return max_multisample; }
138 const std::vector<Step> &get_steps() const { return steps; }
139 const std::vector<PostProcessor> &get_postprocessors() const { return postprocessors; }
140 bool is_clear_enabled() const { return clear_enabled; }
141 const std::vector<Color> &get_clear_colors() const { return clear_colors; }
142 float get_clear_depth() const { return clear_depth; }
143 int get_clear_stencil() const { return clear_stencil; }
146 static void register_postprocessor(const std::string &);
148 static PostProcessorRegistry &get_postprocessor_registry();
152 void SequenceTemplate::register_postprocessor(const std::string &kw)
154 get_postprocessor_registry().register_type<T>(kw);
158 void SequenceTemplate::PostProcLoader::postprocessor()
161 throw std::logic_error("Only one postprocessor allowed per slot");
162 RefPtr<typename T::Template> pp = new typename T::Template;
166 postprocessor_loaded();