summaryrefslogtreecommitdiff
path: root/src/resources/resourcemanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-08 15:40:35 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-08 15:40:35 +0300
commit548c2b03f8184497a5306f4b4412e3120eaef211 (patch)
treea3813d15d21c320be53650e1e195b68842f12197 /src/resources/resourcemanager.cpp
parent0f500fab826a57f8aae8a3e2062a90ee9e80a199 (diff)
downloadmanaplus-548c2b03f8184497a5306f4b4412e3120eaef211.tar.gz
manaplus-548c2b03f8184497a5306f4b4412e3120eaef211.tar.bz2
manaplus-548c2b03f8184497a5306f4b4412e3120eaef211.tar.xz
manaplus-548c2b03f8184497a5306f4b4412e3120eaef211.zip
Add shaderprogram class.
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r--src/resources/resourcemanager.cpp27
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