forked from SurajSharma90/OpenGL-C---Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLight.h
65 lines (53 loc) · 1.18 KB
/
Light.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
#pragma once
#include"libs.h"
class Light
{
protected:
float intensity;
glm::vec3 color;
public:
Light(float intensity, glm::vec3 color)
{
this->intensity = intensity;
this->color = color;
}
~Light()
{
}
//Functions
virtual void sendToShader(Shader& program) = 0;
};
class PointLight : public Light
{
protected:
glm::vec3 position;
float constant;
float linear;
float quadratic;
public:
PointLight(glm::vec3 position, float intensity = 1.f, glm::vec3 color = glm::vec3(1.f),
float constant = 1.f, float linear = 0.045f, float quadratic = 0.0075f)
: Light(intensity, color)
{
this->position = position;
this->constant = constant;
this->linear = linear;
this->quadratic = quadratic;
}
~PointLight()
{
}
void setPosition(const glm::vec3 position)
{
this->position = position;
}
void sendToShader(Shader& program)
{
program.setVec3f(this->position, "pointLight.position");
program.set1f(this->intensity, "pointLight.intensity");
program.setVec3f(this->color, "pointLight.color");
program.set1f(this->constant, "pointLight.constant");
program.set1f(this->linear, "pointLight.linear");
program.set1f(this->quadratic, "pointLight.quadratic");
}
};