diff options
Diffstat (limited to 'src/renderer/shader.h')
-rw-r--r-- | src/renderer/shader.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/renderer/shader.h b/src/renderer/shader.h new file mode 100644 index 0000000..d2c673c --- /dev/null +++ b/src/renderer/shader.h | |||
@@ -0,0 +1,58 @@ | |||
1 | #ifndef SHADER_H_25115B63 | ||
2 | #define SHADER_H_25115B63 | ||
3 | |||
4 | #include <string> | ||
5 | #include <stdexcept> | ||
6 | #include "gl.h" | ||
7 | #include "wrappers.h" | ||
8 | |||
9 | class gl_error : public std::logic_error { | ||
10 | public: | ||
11 | |||
12 | gl_error( | ||
13 | const char* msg, | ||
14 | std::string info) : | ||
15 | std::logic_error(msg), | ||
16 | info_(std::move(info)) | ||
17 | { | ||
18 | } | ||
19 | |||
20 | gl_error( | ||
21 | std::string& msg, | ||
22 | std::string info) : | ||
23 | std::logic_error(msg), | ||
24 | info_(std::move(info)) | ||
25 | { | ||
26 | } | ||
27 | |||
28 | inline const std::string& getInfo() const | ||
29 | { | ||
30 | return info_; | ||
31 | } | ||
32 | |||
33 | private: | ||
34 | |||
35 | std::string info_; | ||
36 | }; | ||
37 | |||
38 | class Shader { | ||
39 | public: | ||
40 | |||
41 | Shader(std::string name); | ||
42 | |||
43 | inline void use() | ||
44 | { | ||
45 | glUseProgram(program_.getId()); | ||
46 | } | ||
47 | |||
48 | inline GLint getUniformLocation(const GLchar* name) | ||
49 | { | ||
50 | return glGetUniformLocation(program_.getId(), name); | ||
51 | } | ||
52 | |||
53 | private: | ||
54 | |||
55 | GLProgram program_; | ||
56 | }; | ||
57 | |||
58 | #endif /* end of include guard: SHADER_H_25115B63 */ | ||