diff options
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/resourcemanager.cpp | 28 | ||||
-rw-r--r-- | src/resources/resourcemanager.h | 3 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index bf7b09897..8bce250fb 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -43,6 +43,9 @@ #include "utils/physfsrwops.h" #include "utils/sdlcheckutils.h" +#include "render/shaders/shader.h" +#include "render/shaders/shadersmanager.h" + #include <SDL_image.h> #include <sys/time.h> @@ -703,9 +706,32 @@ Resource *ResourceManager::getAtlas(const std::string &name, const StringVect &files) { AtlasLoader rl = { name, &files }; - return get("atlas_" + name, &AtlasLoader::load, &rl); } + +struct ShaderLoader final +{ + const std::string name; + const unsigned int type; + + static Resource *load(const void *const v) + { + if (!v) + return nullptr; + + const ShaderLoader *const rl + = static_cast<const ShaderLoader *const>(v); + Shader *const resource = shaders.createShader(rl->type, rl->name); + return resource; + } +}; + +Resource *ResourceManager::getShader(const unsigned int type, + const std::string &name) +{ + ShaderLoader rl = { name, type }; + return get("shader_" + name, &ShaderLoader::load, &rl); +} #endif struct WalkLayerLoader final diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 16640c7fd..f7d901f09 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -175,6 +175,9 @@ class ResourceManager final #ifdef USE_OPENGL Resource *getAtlas(const std::string &name, const StringVect &files) A_WARN_UNUSED; + + Resource *getShader(const unsigned int type, + const std::string &name) A_WARN_UNUSED; #endif WalkLayer *getWalkLayer(const std::string &name, Map *const map); |