summary refs log tree commit diff stats
path: root/src/renderer/shader.h
blob: d2c673cae1e81fb5e867b5fb0cd1800e69383879 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef SHADER_H_25115B63
#define SHADER_H_25115B63

#include <string>
#include <stdexcept>
#include "gl.h"
#include "wrappers.h"

class gl_error : public std::logic_error {
public:

  gl_error(
    const char* msg,
    std::string info) :
      std::logic_error(msg),
      info_(std::move(info))
  {
  }

  gl_error(
    std::string& msg,
    std::string info) :
      std::logic_error(msg),
      info_(std::move(info))
  {
  }

  inline const std::string& getInfo() const
  {
    return info_;
  }

private:

  std::string info_;
};

class Shader {
public:

  Shader(std::string name);

  inline void use()
  {
    glUseProgram(program_.getId());
  }

  inline GLint getUniformLocation(const GLchar* name)
  {
    return glGetUniformLocation(program_.getId(), name);
  }

private:

  GLProgram program_;
};

#endif /* end of include guard: SHADER_H_25115B63 */