X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fmaterials%2Fmaterial.h;h=77e7d44ec29bdedf174d393d5f505aba0cfeb18f;hp=ea02df6b1e00dad8d0dc5275399a55104c5086d5;hb=9813f8711628a0fbe786406e974dc33546dc9cee;hpb=ae45c0397e2cb8f0a01f2f31d01c95ff3870271e diff --git a/source/materials/material.h b/source/materials/material.h index ea02df6b..77e7d44e 100644 --- a/source/materials/material.h +++ b/source/materials/material.h @@ -1,8 +1,8 @@ #ifndef MSP_GL_MATERIAL_H_ #define MSP_GL_MATERIAL_H_ -#include #include +#include #include #include "color.h" #include "programdata.h" @@ -56,37 +56,17 @@ protected: }; public: - class GenericLoader: public DataFile::Loader + class GenericLoader: public DataFile::DynamicObjectLoader { - private: - template - struct CreateMaterial - { - void operator()(const std::string &, GenericLoader &) const; - }; - - DataFile::Collection &coll; - Material *material; - Loader *mat_loader; - - static ActionMap shared_actions; + friend class Material; public: - GenericLoader(DataFile::Collection &); - ~GenericLoader(); + GenericLoader(Collection &c): DynamicObjectLoader(&c) { } - Material *get_object() { Material *m = material; material = 0; return m; } - private: - virtual void init_actions(); - - void type(const DataFile::Symbol &); - - friend class Material; + protected: + virtual const TypeRegistry &get_type_registry() const { return get_material_registry(); } }; -private: - typedef TypeRegistry MaterialRegistry; - protected: const Sampler *sampler; ProgramData shdata; @@ -112,7 +92,7 @@ public: template static void register_type(const std::string &); private: - static MaterialRegistry &get_material_registry(); + static GenericLoader::TypeRegistry &get_material_registry(); }; template @@ -188,19 +168,6 @@ void Material::PropertyLoader::property_texture(void (C::*set_texture)(const (static_cast(obj).*set_texture)(&static_cast(get_collection()).get(name)); } - -template -void Material::GenericLoader::CreateMaterial::operator()(const std::string &, GenericLoader &ldr) const -{ - if(ldr.material) - throw std::logic_error("Material type was already specified"); - - T *mat = new T; - ldr.material = mat; - ldr.mat_loader = new typename T::Loader(*mat, ldr.coll); - ldr.add_auxiliary_loader(*ldr.mat_loader); -} - } // namespace GL } // namespace Msp