From e087bfd5a9a850db30c399e95ef3fd8ab48005d1 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 6 Oct 2021 00:05:53 +0300 Subject: [PATCH] Adjust creator and notify functions in Resources --- source/resources/resources.cpp | 32 ++++++++++++++++++-------------- source/resources/resources.h | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/source/resources/resources.cpp b/source/resources/resources.cpp index 80a19e7c..63a72404 100644 --- a/source/resources/resources.cpp +++ b/source/resources/resources.cpp @@ -43,39 +43,43 @@ Resources::Resources(bool set_as_global): add_type().suffix(".anim").keyword("animation"); add_type().suffix(".arma").keyword("armature"); add_type().keyword("camera") - .notify(&Resources::set_debug_name); + .notify(&set_debug_name); add_type().keyword("font"); add_type().suffix(".kframe").keyword("keyframe"); add_type().keyword("light"); add_type().suffix(".lightn").keyword("lighting") - .notify(&Resources::set_debug_name); + .notify(&set_debug_name); add_type().suffix(".mat") - .creator(&Resources::create_generic).notify(&Resources::set_debug_name); + .creator([this](const string &n){ return create_generic(n); }) + .notify(&set_debug_name); add_type().keyword("mesh") - .creator(&Resources::create_mesh).notify(&Resources::set_debug_name); + .creator([this](const string &n){ return create_mesh(n); }) + .notify(&set_debug_name); add_type().suffix(".glsl").suffix(".spv") - .creator(&Resources::create_module); + .creator([this](const string &n){ return create_module(n); }); add_type().keyword("object"); add_type().suffix(".seq").keyword("sequence"); add_type().keyword("pose"); add_type().keyword("shader") - .creator(&Resources::create_program).notify(&Resources::set_debug_name); + .creator([this](const string &n){ return create_program(n); }) + .notify(&set_debug_name); add_type().suffix(".samp").keyword("sampler") - .notify(&Resources::set_debug_name); + .notify(&set_debug_name); add_type().suffix(".scene") - .creator(&Resources::create_generic); + .creator([this](const string &n){ return create_generic(n); }); add_type().suffix(".tech").keyword("technique") - .notify(&Resources::set_debug_name); + .notify(&set_debug_name); add_type().base().suffix(".tex1d").keyword("texture1d") - .notify(&Resources::set_debug_name); + .notify(&set_debug_name); add_type().base().suffix(".tex2d").suffix(".png").suffix(".jpg").keyword("texture2d") - .creator(&Resources::create_texture2d).notify(&Resources::set_debug_name); + .creator([this](const string &n){ return create_texture2d(n); }) + .notify(&set_debug_name); add_type().base().suffix(".tex3d").keyword("texture3d") - .notify(&Resources::set_debug_name); + .notify(&set_debug_name); add_type().base().suffix(".texcb").keyword("texture_cube") - .notify(&Resources::set_debug_name); + .notify(&set_debug_name); add_type().base().suffix(".tex2da").keyword("texture2d_array") - .notify(&Resources::set_debug_name); + .notify(&set_debug_name); add_source(get_builtins()); diff --git a/source/resources/resources.h b/source/resources/resources.h index 293670f9..0633f3c7 100644 --- a/source/resources/resources.h +++ b/source/resources/resources.h @@ -62,7 +62,7 @@ protected: Program *create_program(const std::string &); template - void set_debug_name(const std::string &, T &); + static void set_debug_name(const std::string &, T &); }; } // namespace GL -- 2.43.0