summary refs log tree commit diff stats
path: root/src/renderer/shader.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-05-17 15:55:37 -0400
committerGitHub <noreply@github.com>2018-05-17 15:55:37 -0400
commit90aadf3844386824140a20d7fbb847bc16009a94 (patch)
tree6f83fce90e71abb22b1a8f3e09c79963b2a34d5d /src/renderer/shader.h
parentbc63fa57ced1c7329f7fdcfd168eaf7e290158bc (diff)
parent86f0106d0523825549f1e74b835688c78a10cf6c (diff)
downloadtherapy-90aadf3844386824140a20d7fbb847bc16009a94.tar.gz
therapy-90aadf3844386824140a20d7fbb847bc16009a94.tar.bz2
therapy-90aadf3844386824140a20d7fbb847bc16009a94.zip
Merge pull request #7 from hatkirby/es-rewrite
The ECS rewrite exceeds the original branch in functionality, so it is time to merge it in.
Diffstat (limited to 'src/renderer/shader.h')
-rw-r--r--src/renderer/shader.h58
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
9class gl_error : public std::logic_error {
10public:
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
33private:
34
35 std::string info_;
36};
37
38class Shader {
39public:
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
53private:
54
55 GLProgram program_;
56};
57
58#endif /* end of include guard: SHADER_H_25115B63 */