diff options
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r-- | src/render/draw.cc | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 2236d8c..0f39385 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -62,14 +62,25 @@ void pass_reset_lights() { // lighting settings for the default light GL_LIGHT0 GLfloat light_position[] = { 0.0, 0.0, 0.0, 1.0 }; - GLfloat ambient_light[] = { r_ambient->value(), r_ambient->value(), r_ambient->value(), 1.0f }; - GLfloat diffuse_light[] = { r_diffuse->value(), r_diffuse->value(), r_diffuse->value(), 1.0f }; - GLfloat specular_light[] = { r_specular->value(), r_specular->value(), r_specular->value(), 1.0f }; + GLfloat ambient_light[4]; + GLfloat diffuse_light[4]; + GLfloat specular_light[4]; for (size_t i = 0; i < 3; i++) { light_position[i] = Camera::eye()[i]; + ambient_light[i] = r_ambient->value(); + diffuse_light[i] = r_diffuse->value(); + specular_light[i] = r_specular->value(); } + ambient_light[3] = 1.0; + diffuse_light[3] = 1.0; + specular_light[3] = 1.0; + + glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 2); + glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 1); + glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.5); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_light); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_light); @@ -127,21 +138,28 @@ void pass_prepare(float seconds) // bright globes set level light GLfloat diffuse_light[4]; - GLfloat ambient_light[] = { 0.0f, 0.0f, 0.0f, 1.0f }; - GLfloat specular_light[] = { r_specular->value(), r_specular->value(), r_specular->value(), 1.0f }; + GLfloat ambient_light[4]; + GLfloat specular_light[4]; for (size_t i = 0; i < 3; i++) { zone_light[i] = globe->location()[i]; zone_color[i] = globe->color()[i]; - diffuse_light[i] = globe->color()[i] * (r_diffuse->value() * 2); + ambient_light[i] = globe->color()[i] * (r_ambient->value() * 0.1); + diffuse_light[i] = globe->color()[i] * (r_diffuse->value() * 0.8); + specular_light[i] = globe->color()[i] * (r_specular->value() * 0.4); } zone_light[3] = 1.0f; + ambient_light[3] = 1.0f; diffuse_light[3] = 1.0f; + specular_light[3] = 1.0f; + + glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.0001); glLightfv(GL_LIGHT1, GL_POSITION, zone_light); glLightfv(GL_LIGHT1, GL_AMBIENT, ambient_light); glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse_light); glLightfv(GL_LIGHT1, GL_SPECULAR, specular_light); + gl::enable(GL_LIGHT1); has_zone_light = true; } @@ -329,7 +347,7 @@ void draw_globe(const core::EntityGlobe* globe) gl::enable(GL_TEXTURE_2D); } - // draw the globe an apply rotation if required + // draw the globe and apply rotation if required gl::push(); gl::translate(location); gl::multmatrix(globe->axis()); |