X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fbuilders%2Fsequencetemplate.h;fp=source%2Fbuilders%2Fsequencetemplate.h;h=6b943dd1499f962bea05968643a936d01e16a8f9;hp=acc852d4fa0ef0113e4a79a6ab6f46ffbead7087;hb=f44366c8785eb7a88755cd71250a8b85289eeed2;hpb=508475b76a5e8fbdd51f57d6587bbf9a2999682b diff --git a/source/builders/sequencetemplate.h b/source/builders/sequencetemplate.h index acc852d4..6b943dd1 100644 --- a/source/builders/sequencetemplate.h +++ b/source/builders/sequencetemplate.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "depthtest.h" #include "postprocessor.h" @@ -19,47 +20,42 @@ class Renderable; class SequenceTemplate { private: - class PostProcLoader: virtual public DataFile::Loader + template + class TemplateLoader: public DataFile::DynamicObjectLoader { - private: - template - struct AddPostProc - { - void operator()(const std::string &kw, PostProcLoader &ldr) const { ldr.add(kw, &PostProcLoader::postprocessor); } - }; - - protected: - RefPtr postproc; + friend class SequenceTemplate; public: - PostProcLoader(); - - PostProcessor::Template *get_postprocessor_template() { return postproc.release(); } - - protected: - virtual void postprocessor_loaded() { } + TemplateLoader(typename DataFile::DynamicObjectLoader::Collection &c): DataFile::DynamicObjectLoader(&c) { } private: - template - void postprocessor(); - - friend class SequenceTemplate; + virtual typename DataFile::DynamicObjectLoader::TypeRegistry &get_type_registry() const { return get_registry(); } }; + template + using TemplateRegistry = typename TemplateLoader::TypeRegistry; + public: - class Loader: public DataFile::CollectionObjectLoader, public PostProcLoader + class Loader: public DataFile::CollectionObjectLoader { public: Loader(SequenceTemplate &, Collection &); private: - virtual void postprocessor_loaded(); void clear(); void multisample(unsigned); void multisample_range(unsigned, unsigned); - void postprocessor(const std::string &); - void step(const std::string &); - void step_with_slot(const std::string &, const std::string &); + void postprocessor(); + void postprocessor_with_slot(const std::string &); + void renderable(const std::string &); + void renderable_with_default(const std::string &, const std::string &); + void step(const std::string &, const std::string &); + }; + + struct Renderable + { + GL::Renderable *renderable = 0; + std::string slot_name; }; struct Step @@ -79,8 +75,6 @@ public: void depth_compare(Predicate); void lighting(const std::string &); void lighting_inline(); - void object(const std::string &); - void scene(const std::string &); void stencil_test(); }; @@ -88,8 +82,7 @@ public: const Lighting *lighting = 0; DepthTest depth_test; StencilTest stencil_test; - std::string slot_name; - Renderable *default_renderable = 0; + std::string renderable_name; }; struct PostProcessor @@ -112,12 +105,11 @@ private: void stencil(int); }; - typedef TypeRegistry PostProcessorRegistry; - bool hdr = false; bool alpha = false; unsigned required_multisample = 0; unsigned max_multisample = 0; + std::vector renderables; std::vector steps; std::vector postprocessors; bool clear_enabled = false; @@ -132,6 +124,7 @@ public: bool get_alpha() const { return alpha; } unsigned get_required_multisample() const { return required_multisample; } unsigned get_maximum_multisample() const { return max_multisample; } + const std::vector &get_renderables() const { return renderables; } const std::vector &get_steps() const { return steps; } const std::vector &get_postprocessors() const { return postprocessors; } bool is_clear_enabled() const { return clear_enabled; } @@ -141,26 +134,16 @@ public: template static void register_postprocessor(const std::string &); + private: - static PostProcessorRegistry &get_postprocessor_registry(); + template + static TemplateRegistry &get_registry(); }; template void SequenceTemplate::register_postprocessor(const std::string &kw) { - get_postprocessor_registry().register_type(kw); -} - -template -void SequenceTemplate::PostProcLoader::postprocessor() -{ - if(postproc) - throw std::logic_error("Only one postprocessor allowed per slot"); - RefPtr pp = new typename T::Template; - load_sub(*pp); - postproc = pp; - pp = 0; - postprocessor_loaded(); + get_registry().register_type(kw); } } // namespace GL