From 2bb4648c0a92244d98a3dd0995e912eba80c4450 Mon Sep 17 00:00:00 2001 From: Evan Goers Date: Wed, 21 Mar 2012 14:01:06 +0000 Subject: Changed create_light() to add_light(). De-duplicated some magic numbers. --- src/render/draw.cc | 14 +++++++++----- src/render/draw.h | 2 +- src/ui/modelview.cc | 10 ++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/render/draw.cc b/src/render/draw.cc index 3b7acad..71b8631 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -54,6 +54,10 @@ bool draw_particles = true; bool draw_lights = true; size_t max_lights = 8; +float ambient_light_intensity = 0.1f; +float diffuse_light_intensity = 0.75f; +float specular_light_intensity = 0.75f; + GLenum zone_gllight = GL_LIGHT0; typedef std::map Globes; @@ -69,7 +73,7 @@ void pass_reset_lights() } // Lights -int create_light(float* location, float attenuation, math::Color color) +int add_light(float* location, float attenuation, math::Color color) { int gllight; @@ -93,9 +97,9 @@ int create_light(float* location, float attenuation, math::Color color) for (size_t i = 0; i < 3; i++) { gllight_location[i] = location[i]; - ambient_light[i] = color[i] * 0.1; - diffuse_light[i] = color[i] * 0.75; - specular_light[i] = color[i] * 0.75; + ambient_light[i] = color[i] * ambient_light_intensity; + diffuse_light[i] = color[i] * diffuse_light_intensity; + specular_light[i] = color[i] * specular_light_intensity; } gllight_location[3] = 1.0f; ambient_light[3] = 1.0f; @@ -169,7 +173,7 @@ void pass_prepare(float seconds) zone_light[i] = globe->location()[i]; zone_color[i] = globe->color()[i]; } - GLenum zone_gllight = create_light(zone_light, 0.00025f, globe->color()); + GLenum zone_gllight = add_light(zone_light, 0.00025f, globe->color()); gl::enable(zone_gllight); has_zone_light = true; } diff --git a/src/render/draw.h b/src/render/draw.h index e35c7c5..59a5b4a 100644 --- a/src/render/draw.h +++ b/src/render/draw.h @@ -27,7 +27,7 @@ void draw_target(const core::Entity *entity); void reset(); /// create light -int create_light(float* location, float attenuation, math::Color color); +int add_light(float* location, float attenuation, math::Color color); /// draw a sphere void draw_sphere(math::Color const & color, float radius); diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc index e3a3c79..303f8e2 100755 --- a/src/ui/modelview.cc +++ b/src/ui/modelview.cc @@ -20,6 +20,8 @@ namespace ui { GLenum modelview_gllight = GL_LIGHT0; +float modelview_light_distance = -10.0f; +float modelview_light_attenuation = 0.05f; ModelView::ModelView(Widget *parent) : Widget(parent) { @@ -204,10 +206,10 @@ void ModelView::draw_globe() glEnableClientState(GL_NORMAL_ARRAY); // we set up the light in camera space - float modelview_light_location[] = {-10.0f * reference_radius, 0, 0}; + float modelview_light_location[] = {modelview_light_distance * reference_radius, 0, 0}; math::Color modelview_light_color; modelview_light_color.assign(1.0); - modelview_gllight = render::create_light(modelview_light_location, 0.05f, modelview_light_color); + modelview_gllight = render::add_light(modelview_light_location, modelview_light_attenuation, modelview_light_color); gl::enable(modelview_gllight); @@ -304,10 +306,10 @@ void ModelView::draw_model() glEnableClientState(GL_NORMAL_ARRAY); // we set up the light in camera space - float modelview_light_location[] = {-10.0f * reference_radius, 0, 0}; + float modelview_light_location[] = {modelview_light_distance * reference_radius, 0, 0}; math::Color modelview_light_color; modelview_light_color.assign(1.0); - modelview_gllight = render::create_light(modelview_light_location, 0.05f, modelview_light_color); + modelview_gllight = render::add_light(modelview_light_location, modelview_light_attenuation, modelview_light_color); gl::enable(modelview_gllight); -- cgit v1.2.3