summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-08 13:57:15 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-08 14:42:50 +0300
commit0f500fab826a57f8aae8a3e2062a90ee9e80a199 (patch)
tree7b64795fb51efd026adf246eb1306c9da05c2892 /src/resources
parente05655679e7bd9488c31169ece3d404fd9160c8d (diff)
downloadmanaplus-0f500fab826a57f8aae8a3e2062a90ee9e80a199.tar.gz
manaplus-0f500fab826a57f8aae8a3e2062a90ee9e80a199.tar.bz2
manaplus-0f500fab826a57f8aae8a3e2062a90ee9e80a199.tar.xz
manaplus-0f500fab826a57f8aae8a3e2062a90ee9e80a199.zip
Add ShaderManager and Shader class.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/resourcemanager.cpp28
-rw-r--r--src/resources/resourcemanager.h3
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);