dungeon_crawler
diff prototype/src/light.cc @ 77:d89b403f630b
added gamma correction (without dialing the lighting down yet)
fixed the incorrect PointLight sphere radius
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 26 Oct 2012 03:03:52 +0300 |
parents | f55ddab0f3a4 |
children | 12a1dcfe91fa |
line diff
1.1 --- a/prototype/src/light.cc Tue Oct 23 14:57:08 2012 +0300 1.2 +++ b/prototype/src/light.cc Fri Oct 26 03:03:52 2012 +0300 1.3 @@ -5,6 +5,7 @@ 1.4 #include "timer.h" 1.5 1.6 unsigned int PointLight::sph_vbo = 0; 1.7 +int PointLight::subdiv = 8; 1.8 1.9 Light::Light(const Color &col) 1.10 : color(col) 1.11 @@ -137,7 +138,11 @@ 1.12 glMatrixMode(GL_MODELVIEW); 1.13 glPushMatrix(); 1.14 glTranslatef(pos.x, pos.y, pos.z); 1.15 - glScalef(radius, radius, radius); 1.16 + 1.17 + // scale by the hypotenuse of the triangle with adjacent side: radius 1.18 + // and angle M_PI / subdiv 1.19 + float s = radius / cos(M_PI / subdiv); 1.20 + glScalef(s, s, s); 1.21 1.22 Light::draw(); 1.23 1.24 @@ -168,8 +173,8 @@ 1.25 1.26 printf("building sphere mesh for point light drawing\n"); 1.27 1.28 - const static int udiv = 8; 1.29 - const static int vdiv = 4; 1.30 + const static int udiv = subdiv; 1.31 + const static int vdiv = udiv / 2; 1.32 1.33 int nquads = udiv * vdiv; 1.34 num_faces = nquads * 2;