Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-03-22 19:56:35 +0000
committerStijn Buys <ingar@osirion.org>2012-03-22 19:56:35 +0000
commit75fd54748dd65b25f25f84a0bbdc25d6b7d4eb67 (patch)
tree9ba4ad39b8c3ed7615260bd451e54ba9d41614e9 /src/render/draw.cc
parent2bb4648c0a92244d98a3dd0995e912eba80c4450 (diff)
Cleaned up lighting related variable names.
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r--src/render/draw.cc46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 71b8631..5d960fe 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -46,8 +46,10 @@ math::Vector3f v6(-1, 1, -1);
math::Vector3f v7(-1, -1, -1);
core::Zone *zone = 0;
-float zone_light[] = { 0.0f, 0.0f, 0.0f, 1.0f }; // location of the zone light
-math::Color zone_color; // color of the zone light
+
+math::Vector3f zone_light_location; // location of the zone light
+math::Color zone_light_color; // color of the zone light
+
bool has_zone_light = false;
bool draw_particles = true;
@@ -66,14 +68,17 @@ Globes globes_list;
/* ---- Prepare the renderer state --------------------------------- */
void pass_reset_lights()
-{
+{
// reset light state
+ has_zone_light = false;
+ zone_light_color.assign(1.0);
+
for (size_t i = 0; i < max_lights; i++)
gl::disable(GL_LIGHT0 + i);
}
-// Lights
-int add_light(float* location, float attenuation, math::Color color)
+// setup an OpenGL light
+int add_light(const math::Vector3f & location, float attenuation, const math::Color & color)
{
int gllight;
@@ -135,8 +140,6 @@ void pass_prepare(float seconds)
// initialize lights
pass_reset_lights();
- has_zone_light = false;
- zone_color.assign(1.0);
// clear current list of globes
globes_list.clear();
@@ -166,14 +169,13 @@ void pass_prepare(float seconds)
globes_list[ext_render(globe)->distance()] = globe;
}
- // add level lights
-
+ // add zone lights
if (globe->flag_is_set(core::Entity::Bright)) {
for (size_t i = 0; i < 3; i++) {
- zone_light[i] = globe->location()[i];
- zone_color[i] = globe->color()[i];
+ zone_light_location[i] = globe->location()[i];
+ zone_light_color[i] = globe->color()[i];
}
- GLenum zone_gllight = add_light(zone_light, 0.00025f, globe->color());
+ GLenum zone_gllight = add_light(zone_light_location, 0.00025f, globe->color());
gl::enable(zone_gllight);
has_zone_light = true;
}
@@ -268,7 +270,7 @@ void draw_pass_sky()
/* ---- Globes ----------------------------------------------------- */
-void draw_sphere(math::Color const & color, float radius)
+void draw_sphere(const math::Color & color, float radius)
{
gl::scale(radius, radius, radius);
gl::color(color);
@@ -345,13 +347,14 @@ void draw_pass_globes()
gl::depthmask(GL_FALSE);
if (has_zone_light) {
- // move zone light
- float fake_light[4];
+ // nudge zone light
+ // FIXME doesn't work correctly with multiple zone lights
+ float fake_light_location[4];
for (size_t i = 0; i < 3; i++) {
- fake_light[i] = zone_light[i] + location[i] - globe->location()[i];
+ fake_light_location[i] = zone_light_location[i] + location[i] - globe->location()[i];
}
- fake_light[3] = 1.0f;
- glLightfv(zone_gllight, GL_POSITION, fake_light);
+ fake_light_location[3] = 1.0f;
+ glLightfv(zone_gllight, GL_POSITION, fake_light_location);
}
}
@@ -398,7 +401,7 @@ void draw_pass_globes()
if (has_zone_light) {
// restore zone light
- glLightfv(zone_gllight, GL_POSITION, zone_light);
+ glLightfv(zone_gllight, GL_POSITION, zone_light_location.ptr());
}
}
}
@@ -1222,7 +1225,7 @@ void draw(float seconds)
draw_pass_spacegrid(); // draw the blue spacegrid
if (!core::localplayer()->view()) {
- Dust::draw(zone_color); // draw spacedust
+ Dust::draw(zone_light_color); // draw spacedust
}
// draw entity lights, flares and particles
@@ -1282,6 +1285,9 @@ void draw(float seconds)
// GL_BLEND and GL_COLOR_MATERIAL must be enabled for the GUI
//gl::disable(GL_COLOR_MATERIAL); // disable color tracking
+
+ // reset light state
+ pass_reset_lights();
}
// draw HUD target world space geometry, like dock indicators