+template<typename T>
+void Material::register_type(const std::string &kw)
+{
+ get_material_registry().register_type<T>(kw);
+}
+
+
+template<typename C>
+void Material::LoaderBase<C>::add_property(const std::string &kw, void (C::*set_value)(float), void (C::*set_texture)(const Texture *))
+{
+ add(kw, &LoaderBase<C>::property_value_scalar, set_value);
+ add(kw+"_map", &LoaderBase<C>::property_texture, set_texture);
+}
+
+template<typename C>
+void Material::LoaderBase<C>::add_property(const std::string &kw, void (C::*set_value)(const Color &), void (C::*set_texture)(const Texture *), bool allow_alpha)
+{
+ add(kw, &LoaderBase<C>::property_value_rgb, set_value);
+ add(kw+"_srgb", &LoaderBase<C>::property_value_srgb, set_value);
+ if(allow_alpha)
+ {
+ add(kw, &LoaderBase<C>::property_value_rgba, set_value);
+ add(kw+"_srgb", &LoaderBase<C>::property_value_srgb_alpha, set_value);
+ }
+ add(kw+"_map", &LoaderBase<C>::property_texture, set_texture);
+}
+
+template<typename C>
+void Material::LoaderBase<C>::add_property(const std::string &kw, void (C::*set_texture)(const Texture *))
+{
+ add(kw+"_map", &LoaderBase<C>::property_texture, set_texture);
+}
+
+template<typename C>
+void Material::LoaderBase<C>::property_value_scalar(void (C::*set_value)(float), float value)
+{
+ (static_cast<C &>(obj).*set_value)(value);
+}
+
+template<typename C>
+void Material::LoaderBase<C>::property_value_rgb(void (C::*set_value)(const Color &), float r, float g, float b)
+{
+ (static_cast<C &>(obj).*set_value)(Color(r, g, b));
+}
+
+template<typename C>
+void Material::LoaderBase<C>::property_value_rgba(void (C::*set_value)(const Color &), float r, float g, float b, float a)
+{
+ (static_cast<C &>(obj).*set_value)(Color(r, g, b, a));
+}
+
+template<typename C>
+void Material::LoaderBase<C>::property_value_srgb(void (C::*set_value)(const Color &), float r, float g, float b)
+{
+ (static_cast<C &>(obj).*set_value)(Color(r, g, b).to_linear());
+}
+
+template<typename C>
+void Material::LoaderBase<C>::property_value_srgb_alpha(void (C::*set_value)(const Color &), float r, float g, float b, float a)
+{
+ (static_cast<C &>(obj).*set_value)(Color(r, g, b, a).to_linear());
+}
+
+template<typename C>
+void Material::LoaderBase<C>::property_texture(void (C::*set_texture)(const Texture *), const std::string &name)
+{
+ (static_cast<C &>(obj).*set_texture)(&get_collection().get<GL::Texture>(name));
+}
+
+
+template<typename T>
+void Material::GenericLoader::typed_material()
+{
+ if(material)
+ throw std::logic_error("Material was already loaded");
+ RefPtr<T> mat = new T;
+ if(coll)
+ load_sub(*mat, *coll);
+ else
+ load_sub(*mat);
+ material = mat;
+}
+