summaryrefslogtreecommitdiff
path: root/gfx/gl/shader.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-02-17 01:01:55 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-17 01:01:55 +0000
commite360e95dcbdc8868e50cfb515942d796619aca21 (patch)
tree208a1c589d6ced65954ec4875b9f2ca71a6668cc /gfx/gl/shader.h
parentDisconnect camera control from shader (diff)
downloadilt-e360e95dcbdc8868e50cfb515942d796619aca21.tar.bz2
ilt-e360e95dcbdc8868e50cfb515942d796619aca21.tar.xz
ilt-e360e95dcbdc8868e50cfb515942d796619aca21.zip
Support multiple shader programs, set by model
Diffstat (limited to 'gfx/gl/shader.h')
-rw-r--r--gfx/gl/shader.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/gfx/gl/shader.h b/gfx/gl/shader.h
index a839b9b..98e0348 100644
--- a/gfx/gl/shader.h
+++ b/gfx/gl/shader.h
@@ -2,17 +2,20 @@
#define SHADER_INCLUDED_H
#include <GL/glew.h>
+#include <array>
#include <glRef.hpp>
#include <glm/glm.hpp>
#include <string_view>
class Shader {
public:
+ enum class Program { Basic = 0 };
+
Shader();
- void Bind() const;
void setView(glm::mat4 view) const;
- void setModel(glm::mat4 model) const;
+ void setModel(glm::mat4 model, Program = Program::Basic) const;
+ void setLight(glm::vec3 dir) const;
private:
class Source {
@@ -27,10 +30,16 @@ private:
static void CheckShaderError(GLuint shader, GLuint flag, bool isProgram, std::string_view errorMessage);
- using ProgramRef = glRef<GLuint, __glewCreateProgram, __glewDeleteProgram>;
+ class ProgramHandle {
+ public:
+ ProgramHandle(std::initializer_list<GLuint>);
+ using ProgramRef = glRef<GLuint, __glewCreateProgram, __glewDeleteProgram>;
+
+ ProgramRef m_program;
+ GLint viewProjection_uniform, model_uniform, lightDir_uniform;
+ };
- ProgramRef m_program;
- GLint viewProjection_uniform, model_uniform, lightDir_uniform;
+ std::array<ProgramHandle, 1> programs;
};
#endif