]> git.tdb.fi Git - libs/gl.git/commitdiff
Make Scenes loadable from collection files too
authorMikko Rasa <tdb@tdb.fi>
Thu, 15 Apr 2021 17:57:51 +0000 (20:57 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 15 Apr 2021 21:31:36 +0000 (00:31 +0300)
source/resources/resources.cpp
source/resources/resources.h

index e83f33eb529078f80c1bd08d426c40dc49a9a08e..b5093932c2516f44d7fd93c660aafe1e734eb93f 100644 (file)
@@ -229,5 +229,19 @@ Program *Resources::create_program(const string &name)
        return 0;
 }
 
+
+Resources::Loader::Loader(Resources &r):
+       DerivedObjectLoader<Resources, Collection::Loader>(r)
+{
+       add("scene", &Loader::scene);
+}
+
+void Resources::Loader::scene(const string &name)
+{
+       Scene::GenericLoader ldr(obj);
+       load_sub_with(ldr);
+       obj.add(name, ldr.get_scene());
+}
+
 } // namespace GL
 } // namespace Msp
index abda5cde7b29f8ee0756536e9acf918510a5333f..5861bbfb41259a8a910e87f55a2ad78498706c81 100644 (file)
@@ -21,6 +21,16 @@ application-specific collection.
 */
 class Resources: virtual public DataFile::Collection
 {
+public:
+       class Loader: public DataFile::DerivedObjectLoader<Resources, Collection::Loader>
+       {
+       public:
+               Loader(Resources &);
+
+       private:
+               void scene(const std::string &);
+       };
+
 private:
        TextureFilter default_tex_filter;
        float default_tex_anisotropy;