Add point lights
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "Shader.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
Shader::Shader(const char* vertexCode, const char* fragmentCode) {
|
||||
Id vertex, fragment;
|
||||
int success;
|
||||
@@ -82,6 +84,16 @@ void Shader::UpdateDirectionalLight(DirectionalLight directionalLight) {
|
||||
glUniform1f(glGetUniformLocation(id, "directionalLight.specular"), directionalLight.GetSpecular());
|
||||
}
|
||||
|
||||
void Shader::UpdatePointLights(PointLightList pointLights) {
|
||||
for (int i = 0; i < pointLights.size() and i < NUM_POINT_LIGHTS; i++) {
|
||||
glUniform3fv(glGetUniformLocation(id, Util::ShaderArrayName("pointLights", i, "pos").c_str()), 1, glm::value_ptr(pointLights[i]->GetTransform().position));
|
||||
glUniform3fv(glGetUniformLocation(id, Util::ShaderArrayName("pointLights", i, "color").c_str()), 1, glm::value_ptr(pointLights[i]->GetColor()));
|
||||
|
||||
glUniform1f(glGetUniformLocation(id, Util::ShaderArrayName("pointLights", i, "radius").c_str()), pointLights[i]->GetRadius());
|
||||
glUniform1f(glGetUniformLocation(id, Util::ShaderArrayName("pointLights", i, "ambient").c_str()), pointLights[i]->GetAmbient());
|
||||
}
|
||||
}
|
||||
|
||||
Name Shader::GetName() const {
|
||||
return "Unnamed Shader";
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "../Material.h"
|
||||
#include "../Light.h"
|
||||
|
||||
#define NUM_POINT_LIGHTS 4
|
||||
|
||||
class Shader {
|
||||
public:
|
||||
Id id;
|
||||
@@ -21,6 +23,7 @@ public:
|
||||
void UpdateMaterial(Material material);
|
||||
|
||||
void UpdateDirectionalLight(DirectionalLight directionalLight);
|
||||
void UpdatePointLights(PointLightList pointLights);
|
||||
|
||||
virtual Name GetName() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user