-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuniform.hpp
59 lines (42 loc) · 1 KB
/
uniform.hpp
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
59
#ifndef UNIFORM_HPP
#define UNIFORM_HPP
#include <string>
#include <glm/glm.hpp>
namespace plush {
class ShaderProgram;
/**
* Base class for uniforms.
*/
class Uniform {
protected:
/// Name of the uniform.
std::string m_name;
/// Program-specific numeric index of the uniform (0 is valid, -1 isn't).
int m_index;
public:
Uniform(const std::string &name);
/// Returns the index of the uniform (-1 if invalid).
int index() const { return m_index; }
/// Finds the uniform in the current program and stores its index (-1 if not found).
bool find();
};
/**
* A uniform that uses 3-element vectors.
*/
class UniformVec3 : public Uniform
{
public:
UniformVec3(const std::string &name) : Uniform(name) { }
void set(const glm::vec3 &v);
};
/**
* A uniform that uses 4x4 matrices.
*/
class UniformMat4 : public Uniform
{
public:
UniformMat4(const std::string &name) : Uniform(name) { }
void set(const glm::mat4 &v);
};
} // namespace
#endif