From 45382662a6835e6d4d6000544cc32119394f49a2 Mon Sep 17 00:00:00 2001 From: Evan Goers Date: Thu, 5 Jan 2012 21:11:37 +0000 Subject: Removed camera light. Tweaked lighting more. --- src/render/draw.cc | 52 +++++++++------------------------------------------- src/render/state.cc | 2 +- 2 files changed, 10 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/render/draw.cc b/src/render/draw.cc index 0f39385..989bca7 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -60,37 +60,8 @@ Globes globes_list; 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[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); - glLightfv(GL_LIGHT0, GL_SPECULAR, specular_light); - - // GL_LIGHT0 is always enabled - gl::enable(GL_LIGHT0); - // reset light state - gl::disable(GL_LIGHT1); + gl::disable(GL_LIGHT0); } void pass_prepare(float seconds) @@ -153,14 +124,14 @@ void pass_prepare(float seconds) diffuse_light[3] = 1.0f; specular_light[3] = 1.0f; - glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.0001); + glLightf(GL_LIGHT0, 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); + glLightfv(GL_LIGHT0, GL_POSITION, zone_light); + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_light); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_light); + glLightfv(GL_LIGHT0, GL_SPECULAR, specular_light); - gl::enable(GL_LIGHT1); + gl::enable(GL_LIGHT0); has_zone_light = true; } @@ -281,9 +252,6 @@ void draw_globe(const core::EntityGlobe* globe) if (globe->flag_is_set(core::Entity::Bright)) { // bright globe, render fullbright gl::disable(GL_LIGHTING); - } else { - // disable camera light, level light only - gl::disable(GL_LIGHT0); } if (ext_render(globe)->distance() > (FARPLANE - globe->radius())) { @@ -300,7 +268,7 @@ void draw_globe(const core::EntityGlobe* globe) fake_light[i] = zone_light[i] + location[i] - globe->location()[i]; } fake_light[3] = 1.0f; - glLightfv(GL_LIGHT1, GL_POSITION, fake_light); + glLightfv(GL_LIGHT0, GL_POSITION, fake_light); } } @@ -366,14 +334,12 @@ void draw_globe(const core::EntityGlobe* globe) if (has_zone_light) { // restore zone light - glLightfv(GL_LIGHT1, GL_POSITION, zone_light); + glLightfv(GL_LIGHT0, GL_POSITION, zone_light); } } if (globe->flag_is_set(core::Entity::Bright)) { gl::enable(GL_LIGHTING); - } else { - gl::enable(GL_LIGHT0); } if (globe->texture_id()) { diff --git a/src/render/state.cc b/src/render/state.cc index 538d784..ab5eec4 100644 --- a/src/render/state.cc +++ b/src/render/state.cc @@ -137,7 +137,7 @@ void State::clear() //gl::shademodel(GL_FLAT); // lighting model - GLfloat global_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f }; + GLfloat global_ambient[] = { 0.1f, 0.1f, 0.1f, 1.0f }; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); -- cgit v1.2.3