diff options
author | Adrian Kummerlaender | 2018-05-25 23:47:27 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2018-05-25 23:48:59 +0200 |
commit | f728e4c8d202de241673a13ce61570b6acb4bba7 (patch) | |
tree | a7e29c4319f0e6d667b98f359ddf089c0565c15a /src/graphic_shader.h | |
parent | 5157658ec0cc07d2c56c978ca010cbb78236439f (diff) | |
download | computicle-f728e4c8d202de241673a13ce61570b6acb4bba7.tar computicle-f728e4c8d202de241673a13ce61570b6acb4bba7.tar.gz computicle-f728e4c8d202de241673a13ce61570b6acb4bba7.tar.bz2 computicle-f728e4c8d202de241673a13ce61570b6acb4bba7.tar.lz computicle-f728e4c8d202de241673a13ce61570b6acb4bba7.tar.xz computicle-f728e4c8d202de241673a13ce61570b6acb4bba7.tar.zst computicle-f728e4c8d202de241673a13ce61570b6acb4bba7.zip |
Restructure source directory
Diffstat (limited to 'src/graphic_shader.h')
-rw-r--r-- | src/graphic_shader.h | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/src/graphic_shader.h b/src/graphic_shader.h deleted file mode 100644 index c67dc01..0000000 --- a/src/graphic_shader.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include "util.h" - -class GraphicShader { -private: - const GLuint _id; - -public: - struct Guard { - const GLuint _id; - - Guard(GLuint id): _id(id) { - glUseProgram(_id); - } - ~Guard() { - glUseProgram(0); - } - }; - - Guard use() const { - return Guard(_id); - } - - GraphicShader(const std::string& vertex, const std::string fragment): - _id(glCreateProgram()) { - glAttachShader(_id, util::compileShader(vertex, GL_VERTEX_SHADER)); - glAttachShader(_id, util::compileShader(fragment, GL_FRAGMENT_SHADER)); - glLinkProgram(_id); - }; - ~GraphicShader() { - glDeleteProgram(_id); - } - - GLuint setUniform(const std::string& name, int value) const { - GLuint id = util::getUniform(_id, name); - glUniform1i(id, value); - return id; - } - - GLuint setUniform(const std::string& name, const std::vector<GLuint>& v) const { - GLuint id = util::getUniform(_id, name); - glUniform1iv(id, v.size(), reinterpret_cast<const GLint*>(v.data())); - return id; - } - - GLuint setUniform(const std::string& name, glm::mat4& M) const { - GLuint id = util::getUniform(_id, name); - glUniformMatrix4fv(id, 1, GL_FALSE, &M[0][0]); - return id; - } -}; |