]> git.tdb.fi Git - libs/gl.git/commitdiff
Add keywords for light and material to Resources::Loader
authorMikko Rasa <tdb@tdb.fi>
Thu, 7 Oct 2021 12:58:53 +0000 (15:58 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 7 Oct 2021 12:58:53 +0000 (15:58 +0300)
Since they're loaded with a generic loader now, the standard keyword
mechanism can't handle them.

source/resources/resources.cpp
source/resources/resources.h

index ec5f431ddba048cf441b2024de70fc84737b92f3..12448a901fc436ce1059b7a92bc834b57f0d6166 100644 (file)
@@ -277,14 +277,17 @@ void Resources::set_debug_name(const string &name, T &item)
 Resources::Loader::Loader(Resources &r):
        DerivedObjectLoader<Resources, Collection::Loader>(r)
 {
-       add("scene", &Loader::scene);
+       add("light", &Loader::generic<Light>);
+       add("material", &Loader::generic<Material>);
+       add("scene", &Loader::generic<Scene>);
 }
 
-void Resources::Loader::scene(const string &name)
+template<typename T>
+void Resources::Loader::generic(const string &name)
 {
-       Scene::GenericLoader ldr(obj);
+       typename T::GenericLoader ldr(obj);
        load_sub_with(ldr);
-       obj.add(name, ldr.get_object());
+       ldr.store_object(obj, name);
 }
 
 } // namespace GL
index 0633f3c74c802e51c2c4d163dd5d30d382a7e378..f830faaa510ff722a7dfc485195b015217efef48 100644 (file)
@@ -28,7 +28,8 @@ public:
                Loader(Resources &);
 
        private:
-               void scene(const std::string &);
+               template<typename T>
+               void generic(const std::string &);
        };
 
 private: