|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <sstream> // stringstream |
|
|
|
|
|
|
|
|
|
|
|
#include "lights.h" |
|
|
|
#include "lights.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -34,22 +36,16 @@ lightsAdd(light_group* lights, glm::vec3 pos, glm::vec3 color, float intensity) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#include <sstream> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
lightsUpdate(light_group* lights, shader_program* shader) |
|
|
|
lightsUpdate(light_group* lights, shader_program* shader) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// set shader max_lights uniform to match..
|
|
|
|
|
|
|
|
// TODO: use Uniform Buffer Objects to update light data
|
|
|
|
|
|
|
|
// https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_uniform_buffer_object.txt
|
|
|
|
|
|
|
|
// https://www.khronos.org/opengl/wiki/Uniform_Buffer_Objects
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glUniform1ui(shader->num_lights_id, lights->num_lights); |
|
|
|
glUniform1ui(shader->num_lights_id, lights->num_lights); |
|
|
|
|
|
|
|
|
|
|
|
for (uint i = 0; i < lights->num_lights; i++) { |
|
|
|
for (uint i = 0; i < lights->num_lights; i++) { |
|
|
|
std::stringstream ss; |
|
|
|
std::stringstream ss; |
|
|
|
ss << "lights[" << i << "].position"; |
|
|
|
ss << "lights[" << i << "].position"; |
|
|
|
int light_pos_loc = glGetUniformLocation(shader->program_id, ss.str().c_str()); |
|
|
|
int light_pos_loc = |
|
|
|
|
|
|
|
glGetUniformLocation(shader->program_id, ss.str().c_str()); |
|
|
|
|
|
|
|
|
|
|
|
glUniform3fv(light_pos_loc, 1, &lights->lights[i].position[0]); |
|
|
|
glUniform3fv(light_pos_loc, 1, &lights->lights[i].position[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
|