summary refs log tree commit diff stats
path: root/src/renderer/shader.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-16 16:04:32 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-16 16:04:32 -0500
commited08b673c50b076042d8f0c49501372168142764 (patch)
tree18ecda99942ef11ce4023c3ad4437976f96b75da /src/renderer/shader.h
parent224645d1071c14b4829dbb3ae35870868fcff85a (diff)
downloadtherapy-ed08b673c50b076042d8f0c49501372168142764.tar.gz
therapy-ed08b673c50b076042d8f0c49501372168142764.tar.bz2
therapy-ed08b673c50b076042d8f0c49501372168142764.zip
Refactored renderer
Renderer is basically now more C++'y, as it makes more use of classes (a lot of GL types have been wrapped), and the renderer itself is now a class. The monitor mesh is also now indexed.

Tweaked the NTSC artifacting after inadvertently fixing a bug with the way the image was loaded.
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 */