diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-08 13:57:15 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-08 14:42:50 +0300 |
commit | 0f500fab826a57f8aae8a3e2062a90ee9e80a199 (patch) | |
tree | 7b64795fb51efd026adf246eb1306c9da05c2892 /src/resources/resourcemanager.cpp | |
parent | e05655679e7bd9488c31169ece3d404fd9160c8d (diff) | |
download | plus-0f500fab826a57f8aae8a3e2062a90ee9e80a199.tar.gz plus-0f500fab826a57f8aae8a3e2062a90ee9e80a199.tar.bz2 plus-0f500fab826a57f8aae8a3e2062a90ee9e80a199.tar.xz plus-0f500fab826a57f8aae8a3e2062a90ee9e80a199.zip |
Add ShaderManager and Shader class.
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r-- | src/resources/resourcemanager.cpp | 28 |
1 files changed, 27 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 |