dungeon_crawler
diff prototype/src/light.cc @ 38:862461b686f4
start work on particle systems
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 29 Aug 2012 03:22:36 +0300 |
parents | 0357994effe2 |
children | acfe0c0110fc |
line diff
1.1 --- a/prototype/src/light.cc Wed Aug 29 01:04:01 2012 +0300 1.2 +++ b/prototype/src/light.cc Wed Aug 29 03:22:36 2012 +0300 1.3 @@ -1,6 +1,8 @@ 1.4 +#include <stdlib.h> 1.5 #include "opengl.h" 1.6 #include "light.h" 1.7 #include "renderer.h" 1.8 +#include "timer.h" 1.9 1.10 Light::Light(const Color &col) 1.11 : color(col) 1.12 @@ -8,6 +10,8 @@ 1.13 intensity = 1.0; 1.14 vbo = 0; 1.15 num_faces = 0; 1.16 + 1.17 + flicker_offset = 2.0 * (float)rand() / (float)RAND_MAX; 1.18 } 1.19 1.20 Light::~Light() {} 1.21 @@ -117,7 +121,9 @@ 1.22 glUniform1f(loc, radius); 1.23 } 1.24 if((loc = glGetUniformLocation(sdr, "light_color")) != -1) { 1.25 - glUniform3f(loc, color.x, color.y, color.z); 1.26 + float t = get_time_msec() / 1000.0 + flicker_offset * 4.0; 1.27 + float intens = fbm1(t * 2.0, 2) * 0.5 + 1.0; 1.28 + glUniform3f(loc, color.x * intens, color.y * intens, color.z * intens); 1.29 } 1.30 } 1.31