summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/resourcemanager.cpp27
-rw-r--r--src/resources/resourcemanager.h3
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);