X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresources%2Fresources.cpp;h=66f6f082b927d2d6cdd5499a859f23bde6eadff2;hb=fcde8390ad577fe434dcd4b29e0f410d29f867c9;hp=b5093932c2516f44d7fd93c660aafe1e734eb93f;hpb=2108712bcde8b5c4573ca4d602d5f8948b810d72;p=libs%2Fgl.git diff --git a/source/resources/resources.cpp b/source/resources/resources.cpp index b5093932..66f6f082 100644 --- a/source/resources/resources.cpp +++ b/source/resources/resources.cpp @@ -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,22 +44,35 @@ Resources::Resources(): add_type().keyword("camera"); add_type().keyword("font"); add_type().suffix(".kframe").keyword("keyframe"); + add_type().keyword("light"); add_type().suffix(".lightn").keyword("lighting"); - add_type().suffix(".mat").creator(&Resources::create_material); - add_type().keyword("mesh").creator(&Resources::create_mesh); - add_type().suffix(".glsl").suffix(".spv").creator(&Resources::create_module); + add_type().suffix(".mat") + .creator(&Resources::create_material).notify(&Resources::set_debug_name); + add_type().keyword("mesh") + .creator(&Resources::create_mesh).notify(&Resources::set_debug_name); + add_type().suffix(".glsl").suffix(".spv") + .creator(&Resources::create_module); add_type().keyword("object"); add_type().suffix(".seq").keyword("sequence"); add_type().keyword("pose"); - add_type().keyword("shader").creator(&Resources::create_program); - add_type().suffix(".samp").keyword("sampler"); - add_type().suffix(".scene").creator(&Resources::create_scene); - add_type().suffix(".tech").keyword("technique"); - add_type().base().suffix(".tex1d").keyword("texture1d"); - add_type().base().suffix(".tex2d").suffix(".png").suffix(".jpg").keyword("texture2d").creator(&Resources::create_texture2d); - add_type().base().suffix(".tex3d").keyword("texture3d"); - add_type().base().suffix(".texcb").keyword("texture_cube"); - add_type().base().suffix(".tex2da").keyword("texture2d_array"); + add_type().keyword("shader") + .creator(&Resources::create_program).notify(&Resources::set_debug_name); + add_type().suffix(".samp").keyword("sampler") + .notify(&Resources::set_debug_name); + add_type().suffix(".scene") + .creator(&Resources::create_scene); + add_type().suffix(".tech").keyword("technique") + .notify(&Resources::set_debug_name); + add_type().base().suffix(".tex1d").keyword("texture1d") + .notify(&Resources::set_debug_name); + add_type().base().suffix(".tex2d").suffix(".png").suffix(".jpg").keyword("texture2d") + .creator(&Resources::create_texture2d).notify(&Resources::set_debug_name); + add_type().base().suffix(".tex3d").keyword("texture3d") + .notify(&Resources::set_debug_name); + add_type().base().suffix(".texcb").keyword("texture_cube") + .notify(&Resources::set_debug_name); + add_type().base().suffix(".tex2da").keyword("texture2d_array") + .notify(&Resources::set_debug_name); add_source(get_builtins()); } @@ -208,6 +222,15 @@ Module *Resources::create_module(const string &name) return module.release(); } } + else if(ext==".spv") + { + if((io = open_raw(FS::basepart(name)+".glsl"))) + { + RefPtr module = new SpirVModule; + module->load_source(*io, this, name); + return module.release(); + } + } return 0; } @@ -229,6 +252,14 @@ Program *Resources::create_program(const string &name) return 0; } +template +void Resources::set_debug_name(const string &name, T &item) +{ +#ifdef DEBUG + item.set_debug_name(name); +#endif +} + Resources::Loader::Loader(Resources &r): DerivedObjectLoader(r)