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"
18 class SequenceTemplate
21 class PostProcLoader: virtual public DataFile::Loader
27 void operator()(const std::string &kw, PostProcLoader &ldr) const { ldr.add(kw, &PostProcLoader::postprocessor<T>); }
31 RefPtr<PostProcessor::Template> postproc;
36 PostProcessor::Template *get_postprocessor_template() { return postproc.release(); }
39 virtual void postprocessor_loaded() { }
45 friend class SequenceTemplate;
49 class Loader: public DataFile::CollectionObjectLoader<SequenceTemplate, Resources>, public PostProcLoader
52 Loader(SequenceTemplate &, Collection &);
54 virtual void postprocessor_loaded();
55 void multisample(unsigned);
56 void multisample_range(unsigned, unsigned);
57 void postprocessor(const std::string &);
58 void step(const std::string &, const std::string &);
63 class Loader: public DataFile::CollectionObjectLoader<Step>
67 Loader(Step &, Collection &);
71 void blend(BlendFactor, BlendFactor);
72 void blend_predefined(const std::string &);
73 void depth_test(Predicate);
74 void depth_test_predefined(const std::string &);
75 void lighting(const std::string &);
76 void lighting_inline();
77 // TODO requires support for scenes in Resources
78 //void scene(const std::string &);
82 RefPtr<Lighting> lighting;
83 RefPtr<const DepthTest> depth_test;
84 RefPtr<const Blend> blend;
85 std::string renderable_name;
86 //Renderable *default_renderable;
93 GL::PostProcessor::Template *postprocessor_template;
94 std::string slot_name;
96 PostProcessor(GL::PostProcessor::Template * = 0);
99 typedef std::vector<PostProcessor> PostProcessorArray;
102 typedef TypeRegistry<PostProcLoader::AddPostProc, PostProcLoader &> PostProcessorRegistry;
104 Resources *resources;
107 unsigned required_multisample;
108 unsigned max_multisample;
109 std::vector<Step> steps;
110 PostProcessorArray postprocessors;
116 Resources &get_resources() const;
117 bool get_hdr() const { return hdr; }
118 bool get_alpha() const { return alpha; }
119 unsigned get_required_multisample() const { return required_multisample; }
120 unsigned get_maximum_multisample() const { return max_multisample; }
121 const std::vector<Step> &get_steps() const { return steps; }
122 const PostProcessorArray &get_postprocessors() const { return postprocessors; }
125 static void register_postprocessor(const std::string &);
127 static PostProcessorRegistry &get_postprocessor_registry();
131 void SequenceTemplate::register_postprocessor(const std::string &kw)
133 get_postprocessor_registry().register_type<T>(kw);
137 void SequenceTemplate::PostProcLoader::postprocessor()
140 throw std::logic_error("Only one postprocessor allowed per slot");
141 RefPtr<typename T::Template> pp = new typename T::Template;
145 postprocessor_loaded();