diff options
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r-- | src/resources/resourcemanager.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 8bce250fb..9fd445ffc 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -44,6 +44,7 @@ #include "utils/sdlcheckutils.h" #include "render/shaders/shader.h" +#include "render/shaders/shaderprogram.h" #include "render/shaders/shadersmanager.h" #include <SDL_image.h> @@ -732,6 +733,32 @@ Resource *ResourceManager::getShader(const unsigned int type, ShaderLoader rl = { name, type }; return get("shader_" + name, &ShaderLoader::load, &rl); } + +struct ShaderProgramLoader final +{ + const std::string vertex; + const std::string fragment; + + static Resource *load(const void *const v) + { + if (!v) + return nullptr; + + const ShaderProgramLoader *const rl + = static_cast<const ShaderProgramLoader *const>(v); + ShaderProgram *const resource = shaders.createProgram( + rl->vertex, rl->fragment); + return resource; + } +}; + +Resource *ResourceManager::getShaderProgram(const std::string &vertex, + const std::string &fragment) +{ + ShaderProgramLoader rl = { vertex, fragment }; + return get("program_" + vertex + " + " + fragment, + &ShaderProgramLoader::load, &rl); +} #endif struct WalkLayerLoader final |