-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirectionalLight.h
73 lines (65 loc) · 1.47 KB
/
directionalLight.h
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef directionalLight_h
#define directionalLight_h
#include <glad/glad.h>
#include <glm/glm.hpp>
#include "shader.h"
class DirectionalLight {
public:
glm::vec3 direction;
glm::vec3 ambient;
glm::vec3 diffuse;
glm::vec3 specular;
DirectionalLight(glm::vec3 dir, glm::vec3 amb, glm::vec3 diff, glm::vec3 spec)
{
direction = dir;
ambient = amb;
diffuse = diff;
specular = spec;
}
void setUpLight(Shader& lightingShader)
{
lightingShader.use();
lightingShader.setVec3("directionalLight.ambient", ambient * ambientOn * isOn);
lightingShader.setVec3("directionalLight.diffuse", diffuse * diffuseOn * isOn);
lightingShader.setVec3("directionalLight.specular", specular * specularOn * isOn);
lightingShader.setVec3("directionalLight.direction", direction);
}
void turnOff()
{
isOn = 0.0;
}
void turnOn()
{
isOn = 1.0;
}
void turnAmbientOn()
{
ambientOn = 1.0;
}
void turnAmbientOff()
{
ambientOn = 0.0;
}
void turnDiffuseOn()
{
diffuseOn = 1.0;
}
void turnDiffuseOff()
{
diffuseOn = 0.0;
}
void turnSpecularOn()
{
specularOn = 1.0;
}
void turnSpecularOff()
{
specularOn = 0.0;
}
private:
float ambientOn = 1.0;
float diffuseOn = 1.0;
float specularOn = 1.0;
float isOn = 0.0;
};
#endif /* directionalLight_h */