6#include <brenta/renderer/phong.hpp>
7#include <brenta/renderer/opengl/shader.hpp>
11using namespace brenta;
13void PhongPointLight::apply(
int light_number)
17 glGetIntegerv(GL_CURRENT_PROGRAM, &prog);
20 auto light_array =
"point_lights[" + std::to_string(light_number) +
"]";
21 Shader::set_vec3(prog, light_array +
".position", this->position);
22 Shader::set_float(prog, light_array +
".strength", this->strength);
23 Shader::set_vec3(prog, light_array +
".ambient", this->ambient);
24 Shader::set_vec3(prog, light_array +
".diffuse", this->diffuse);
25 Shader::set_vec3(prog, light_array +
".specular", this->specular);
26 Shader::set_float(prog, light_array +
".constant", this->constant);
27 Shader::set_float(prog, light_array +
".linear", this->linear);
28 Shader::set_float(prog, light_array +
".quadratic", this->quadratic);
33 this->ambient = ambient;
39 this->diffuse = diffuse;
45 this->specular = specular;
51 this->position = position;
57 this->strength = strength;
63 this->constant = constant;
69 this->linear = linear;
75 this->quadratic = quadratic;
79void PhongDirLight::apply()
83 glGetIntegerv(GL_CURRENT_PROGRAM, &prog);
86 Shader::set_vec3(prog,
"dir_light.direction", this->direction);
87 Shader::set_float(prog,
"dir_light.strength", this->strength);
88 Shader::set_vec3(prog,
"dir_light.ambient", this->ambient);
89 Shader::set_vec3(prog,
"dir_light.diffuse", this->diffuse);
90 Shader::set_vec3(prog,
"dir_light.specular", this->specular);
92 Shader::set_bool(prog,
"use_dir_light",
true);
97 this->ambient = ambient;
103 this->diffuse = diffuse;
107PhongDirLight &PhongDirLight::set_specular(glm::vec3 specular)
109 this->specular = specular;
113PhongDirLight &PhongDirLight::set_direction(glm::vec3 direction)
115 this->direction = direction;
121 this->strength = strength;