summaryrefslogtreecommitdiff
path: root/gfx/gl/shader.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl/shader.h')
-rw-r--r--gfx/gl/shader.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/gfx/gl/shader.h b/gfx/gl/shader.h
new file mode 100644
index 0000000..1a8ddef
--- /dev/null
+++ b/gfx/gl/shader.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include <GL/glew.h>
+#include <glRef.hpp>
+#include <optional>
+#include <string_view>
+
+class Shader {
+public:
+ constexpr Shader(const GLchar * text, GLint len, GLuint type) : text {text}, len {len}, type {type} { }
+
+ operator GLuint() const;
+ static void CheckShaderError(GLuint shader, GLuint flag, bool isProgram, std::string_view errorMessage);
+
+private:
+ using ShaderRef = glRef<GLuint, &__glewCreateShader, &__glewDeleteShader>;
+ const GLchar * text;
+ GLint len;
+ GLuint type;
+ mutable std::optional<ShaderRef> shader {};
+};