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 "predicate.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();
57 void multisample(unsigned);
58 void multisample_range(unsigned, unsigned);
59 void postprocessor(const std::string &);
60 void step(const std::string &);
61 void step_with_slot(const std::string &, const std::string &);
66 class Loader: public DataFile::CollectionObjectLoader<Step>
69 std::string inline_base_name;
73 Loader(Step &, Collection &);
78 void set_inline_base_name(const std::string &);
82 void blend_factors(BlendFactor, BlendFactor);
84 void depth_compare(Predicate);
85 void lighting(const std::string &);
86 void lighting_inline();
87 void object(const std::string &);
88 void scene(const std::string &);
93 const Lighting *lighting;
95 StencilTest stencil_test;
97 std::string slot_name;
98 Renderable *default_renderable;
105 GL::PostProcessor::Template *postprocessor_template;
106 std::string slot_name;
108 PostProcessor(GL::PostProcessor::Template * = 0);
112 typedef TypeRegistry<PostProcLoader::AddPostProc, PostProcLoader &> PostProcessorRegistry;
116 unsigned required_multisample;
117 unsigned max_multisample;
118 std::vector<Step> steps;
119 std::vector<PostProcessor> postprocessors;
125 bool get_hdr() const { return hdr; }
126 bool get_alpha() const { return alpha; }
127 unsigned get_required_multisample() const { return required_multisample; }
128 unsigned get_maximum_multisample() const { return max_multisample; }
129 const std::vector<Step> &get_steps() const { return steps; }
130 const std::vector<PostProcessor> &get_postprocessors() const { return postprocessors; }
133 static void register_postprocessor(const std::string &);
135 static PostProcessorRegistry &get_postprocessor_registry();
139 void SequenceTemplate::register_postprocessor(const std::string &kw)
141 get_postprocessor_registry().register_type<T>(kw);
145 void SequenceTemplate::PostProcLoader::postprocessor()
148 throw std::logic_error("Only one postprocessor allowed per slot");
149 RefPtr<typename T::Template> pp = new typename T::Template;
153 postprocessor_loaded();