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>
68 std::string inline_base_name;
72 Loader(Step &, Collection &);
77 void set_inline_base_name(const std::string &);
80 void blend(BlendFactor, BlendFactor);
81 void blend_predefined(const std::string &);
82 void depth_test(Predicate);
83 void depth_test_predefined(const std::string &);
84 void lighting(const std::string &);
85 void lighting_inline();
86 void object(const std::string &);
87 void scene(const std::string &);
91 const Lighting *lighting;
92 RefPtr<const DepthTest> depth_test;
93 RefPtr<const Blend> blend;
94 std::string slot_name;
95 Renderable *default_renderable;
102 GL::PostProcessor::Template *postprocessor_template;
103 std::string slot_name;
105 PostProcessor(GL::PostProcessor::Template * = 0);
108 typedef std::vector<PostProcessor> PostProcessorArray;
111 typedef TypeRegistry<PostProcLoader::AddPostProc, PostProcLoader &> PostProcessorRegistry;
115 unsigned required_multisample;
116 unsigned max_multisample;
117 std::vector<Step> steps;
118 PostProcessorArray postprocessors;
124 bool get_hdr() const { return hdr; }
125 bool get_alpha() const { return alpha; }
126 unsigned get_required_multisample() const { return required_multisample; }
127 unsigned get_maximum_multisample() const { return max_multisample; }
128 const std::vector<Step> &get_steps() const { return steps; }
129 const PostProcessorArray &get_postprocessors() const { return postprocessors; }
132 static void register_postprocessor(const std::string &);
134 static PostProcessorRegistry &get_postprocessor_registry();
138 void SequenceTemplate::register_postprocessor(const std::string &kw)
140 get_postprocessor_registry().register_type<T>(kw);
144 void SequenceTemplate::PostProcLoader::postprocessor()
147 throw std::logic_error("Only one postprocessor allowed per slot");
148 RefPtr<typename T::Template> pp = new typename T::Template;
152 postprocessor_loaded();