-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLight.cpp
More file actions
28 lines (22 loc) · 997 Bytes
/
Light.cpp
File metadata and controls
28 lines (22 loc) · 997 Bytes
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
#include "Light.h"
Light::Light()
{
lightColor = glm::vec3(1.0f, 1.0f, 1.0f);
ambientStrength = 1.0f;
}
Light::Light(GLfloat red, GLfloat blue, GLfloat green, GLfloat ambientStrength, glm::vec3 directionLocation, GLfloat diffuseStrength, GLfloat specularStrength)
{
lightColor = glm::vec3(red, green, blue);
this->ambientStrength = ambientStrength;
this->directionLocation = directionLocation;
this->diffuseStrength = diffuseStrength;
this->specularStrength = specularStrength;
}
void Light::useLight(GLuint colorLocation, GLuint ambientLocation, GLuint diffuseStrengthLocation, GLuint diffusePositionLocation, GLfloat specularStrengthLocation)
{
glUniform3f(colorLocation, lightColor.x, lightColor.y, lightColor.z);
glUniform1f(ambientLocation, ambientStrength);
glUniform1f(diffuseStrengthLocation, diffuseStrength);
glUniform3f(diffusePositionLocation, directionLocation.x, directionLocation.y, directionLocation.z);
glUniform1f(specularStrengthLocation, specularStrength);
}