diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-11-03 19:47:46 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-11-03 19:48:31 +0000 |
commit | c3eea71370eb94cff1fd96185458643fab6eb2c5 (patch) | |
tree | cb331dd81d9cb36d69e1b659353796ec170a78e4 /gfx/gl/shader.h | |
parent | Rename Shader to SceneShader (diff) | |
download | ilt-c3eea71370eb94cff1fd96185458643fab6eb2c5.tar.bz2 ilt-c3eea71370eb94cff1fd96185458643fab6eb2c5.tar.xz ilt-c3eea71370eb94cff1fd96185458643fab6eb2c5.zip |
Restructure how shaders are worked with
Needs a tidy-up
Diffstat (limited to 'gfx/gl/shader.h')
-rw-r--r-- | gfx/gl/shader.h | 21 |
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 {}; +}; |