summaryrefslogtreecommitdiff
path: root/gfx/gl/shader.h
blob: c1e39813a82d3b978285b20498210b7a9acc4389 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pragma once

#include <GL/glew.h>
#include <glRef.hpp>
#include <optional>
#include <string_view>

class Shader {
public:
	using ShaderRef = glRef<GLuint, &__glewCreateShader, &__glewDeleteShader>;
	constexpr Shader(const GLchar * text, GLint len, GLuint type) : text {text}, len {len}, type {type} { }

	[[nodiscard]] ShaderRef compile() const;
	static void CheckShaderError(GLuint shader, GLuint flag, bool isProgram, std::string_view errorMessage);

private:
	const GLchar * text;
	GLint len;
	GLuint type;
};