]> git.tdb.fi Git - libs/gl.git/blobdiff - source/resources/resources.cpp
Compile SPIR-V modules from GLSL if needed
[libs/gl.git] / source / resources / resources.cpp
index e83f33eb529078f80c1bd08d426c40dc49a9a08e..11dc2d329dd29cfca2ec9385b72361f6260e54b8 100644 (file)
@@ -5,6 +5,7 @@
 #include "camera.h"
 #include "font.h"
 #include "keyframe.h"
+#include "light.h"
 #include "lighting.h"
 #include "material.h"
 #include "mesh.h"
@@ -43,6 +44,7 @@ Resources::Resources():
        add_type<Camera>().keyword("camera");
        add_type<Font>().keyword("font");
        add_type<KeyFrame>().suffix(".kframe").keyword("keyframe");
+       add_type<Light>().keyword("light");
        add_type<Lighting>().suffix(".lightn").keyword("lighting");
        add_type<Material>().suffix(".mat").creator(&Resources::create_material);
        add_type<Mesh>().keyword("mesh").creator(&Resources::create_mesh);
@@ -208,6 +210,15 @@ Module *Resources::create_module(const string &name)
                        return module.release();
                }
        }
+       else if(ext==".spv")
+       {
+               if((io = open_raw(FS::basepart(name)+".glsl")))
+               {
+                       RefPtr<SpirVModule> module = new SpirVModule;
+                       module->load_source(*io, this, name);
+                       return module.release();
+               }
+       }
 
        return 0;
 }
@@ -229,5 +240,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