aboutsummaryrefslogtreecommitdiff
path: root/shader.h
diff options
context:
space:
mode:
Diffstat (limited to 'shader.h')
-rw-r--r--shader.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/shader.h b/shader.h
new file mode 100644
index 0000000..feb5952
--- /dev/null
+++ b/shader.h
@@ -0,0 +1,37 @@
+#ifndef SHADER_H
+#define SHADER_H
+
+#include <glad/gl.h>
+
+class Shader
+{
+public:
+ Shader(const char *vertexSrc, const char *fragmentSrc, const char *geometrySrc = nullptr);
+ ~Shader();
+
+ GLuint program() const { return m_program; }
+
+ GLint uniformLocation(const char *name) const;
+
+ void setUniform(GLint location, GLint value) const;
+ void setUniform(GLint location, GLfloat value) const;
+ void setUniform(GLint location, GLfloat mat[4][4]) const;
+ void setUniform1dArray(GLint location, const GLfloat *values, int count) const;
+ void setUniform2dArray(GLint location, const GLfloat *values, int count) const;
+ void setUniform3dArray(GLint location, const GLfloat *values, int count) const;
+
+ void setUniform(const char *name, GLint value) const;
+ void setUniform(const char *name, GLfloat value) const;
+ void setUniform(const char *name, GLfloat mat[4][4]) const;
+ void setUniform1dArray(const char *name, const GLfloat *values, int count) const;
+ void setUniform2dArray(const char *name, const GLfloat *values, int count) const;
+ void setUniform3dArray(const char *name, const GLfloat *values, int count) const;
+
+ void use() const;
+ void release() const;
+
+private:
+ GLuint m_program;
+};
+
+#endif // SHADER_H