7 changed files with 98 additions and 44 deletions
@ -0,0 +1,54 @@
|
||||
|
||||
#include "lights.h" |
||||
|
||||
|
||||
light_group* |
||||
lightsInit(uint max_lights) |
||||
{ |
||||
light_group* lg = UTIL_ALLOC(1, light_group); |
||||
lg->lights = UTIL_ALLOC(max_lights, point_light); |
||||
return lg; |
||||
} |
||||
|
||||
void |
||||
lightsOut(light_group* lights) |
||||
{ |
||||
utilSafeFree(lights->lights); |
||||
utilSafeFree(lights); |
||||
} |
||||
|
||||
bool |
||||
lightsAdd(light_group* lights, glm::vec3 pos, glm::vec3 color, float intensity) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
void |
||||
lightsUpdate(light_group* lights, shader_program* shader) |
||||
{ |
||||
// set shader max_lights uniform to match..
|
||||
} |
||||
|
||||
#if 0 |
||||
#include <sstream> |
||||
|
||||
inline void |
||||
updateLights(shader_program& shader, point_light* lights, uint num_lights) |
||||
{ |
||||
// 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, num_lights); |
||||
|
||||
for (uint i = 0; i < num_lights; i++) { |
||||
// TODO: don't do this every frame * every render_group
|
||||
std::stringstream ss; |
||||
ss << "lights[" << i << "].position"; |
||||
int light_pos_loc = glGetUniformLocation(shader.program_id, ss.str().c_str()); |
||||
|
||||
glUniform3fv(light_pos_loc, 1, &lights[i].position[0]); |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
Loading…
Reference in new issue