]> git.localhorst.tv Git - tacos.git/blobdiff - src/graphics/shader.hpp
the usual suspects
[tacos.git] / src / graphics / shader.hpp
diff --git a/src/graphics/shader.hpp b/src/graphics/shader.hpp
new file mode 100644 (file)
index 0000000..32369b2
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef TACOS_GRAPHICS_SHADER_HPP_
+#define TACOS_GRAPHICS_SHADER_HPP_
+
+#include <GL/glew.h>
+#include <glm/glm.hpp>
+
+
+namespace tacos {
+
+class Shader {
+
+       friend class Program;
+
+public:
+       static Shader Vertex(const GLchar *source);
+       static Shader Fragment(const GLchar *source);
+
+       ~Shader() noexcept;
+
+       Shader(Shader &&) noexcept;
+       Shader &operator =(Shader &&) noexcept;
+
+       Shader(const Shader &) = delete;
+       Shader &operator =(const Shader &) = delete;
+
+private:
+       explicit Shader(GLenum type, const GLchar *source);
+
+private:
+       GLuint shader;
+
+};
+
+
+class Program {
+
+public:
+       Program();
+       ~Program() noexcept;
+
+       Program(const Program &) = delete;
+       Program &operator =(const Program &) = delete;
+
+       void Attach(const Shader &) noexcept;
+       void Link();
+
+       void Use() noexcept;
+
+       GLint AttributeLocation(const GLchar *name) const noexcept;
+       GLint UniformLocation(const GLchar *name) const noexcept;
+
+       void Uniform(GLint, GLint) noexcept;
+       void Uniform(GLint, float) noexcept;
+       void Uniform(GLint, const glm::vec3 &) noexcept;
+       void Uniform(GLint, const glm::vec4 &) noexcept;
+       void Uniform(GLint, const glm::mat4 &) noexcept;
+
+private:
+       GLuint program;
+
+};
+
+}
+
+#endif