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

#include <glRef.h>
#include <glad/gl.h>
#include <string_view>

class Shader {
public:
	using ShaderRef = glRef<GLuint, &glCreateShader, &glDeleteShader>;

	constexpr Shader(const GLchar * text, GLuint type) : text {text}, type {type} { }

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

private:
	const std::basic_string_view<GLchar> text;
	GLuint type;
};