diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-08 15:40:35 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-08 15:40:35 +0300 |
commit | 548c2b03f8184497a5306f4b4412e3120eaef211 (patch) | |
tree | a3813d15d21c320be53650e1e195b68842f12197 /src/resources | |
parent | 0f500fab826a57f8aae8a3e2062a90ee9e80a199 (diff) | |
download | manaplus-548c2b03f8184497a5306f4b4412e3120eaef211.tar.gz manaplus-548c2b03f8184497a5306f4b4412e3120eaef211.tar.bz2 manaplus-548c2b03f8184497a5306f4b4412e3120eaef211.tar.xz manaplus-548c2b03f8184497a5306f4b4412e3120eaef211.zip |
Add shaderprogram class.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/resourcemanager.cpp | 27 | ||||
-rw-r--r-- | src/resources/resourcemanager.h | 3 |
2 files changed, 30 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 diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index f7d901f09..88bae02db 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -178,6 +178,9 @@ class ResourceManager final Resource *getShader(const unsigned int type, const std::string &name) A_WARN_UNUSED; + + Resource *getShaderProgram(const std::string &vertex, + const std::string &fragment) A_WARN_UNUSED; #endif WalkLayer *getWalkLayer(const std::string &name, Map *const map); |