diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/camera.cc | 1 | ||||
-rw-r--r-- | src/render/draw.cc | 50 | ||||
-rw-r--r-- | src/render/draw.h | 3 | ||||
-rw-r--r-- | src/render/state.cc | 19 | ||||
-rw-r--r-- | src/render/state.h | 2 |
5 files changed, 47 insertions, 28 deletions
diff --git a/src/render/camera.cc b/src/render/camera.cc index 3d7c452..851ad81 100644 --- a/src/render/camera.cc +++ b/src/render/camera.cc @@ -385,6 +385,7 @@ void Camera::frustum_default(float distance, float cx, float cy) gl::rotate(-90.0f, 1.0f , 0.0f, 0.0f); gl::translate(distance + 1.0f, 0.0f, 0.0f); + camera_eye.assign(-distance - 1.0f, 0.0f, 0.0f); } void Camera::ortho() diff --git a/src/render/draw.cc b/src/render/draw.cc index 6e60f86..22ff90f 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -59,21 +59,8 @@ Globes globes_list; /* ---- Prepare the renderer state --------------------------------- */ -void pass_prepare(float seconds) +void pass_reset_lights() { - using namespace model; - - // render settings for this pass_prepare - draw_lights = true; - if (r_lights && (r_lights->value() <= 0.0f)) { - draw_lights = false; - } - - draw_particles = true; - if (r_particles && (r_particles->value() <= 0.0f)) { - draw_particles = false; - } - // 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 }; @@ -94,6 +81,25 @@ void pass_prepare(float seconds) // reset light state gl::disable(GL_LIGHT1); +} + +void pass_prepare(float seconds) +{ + using namespace model; + + // render settings for this pass_prepare + draw_lights = true; + if (r_lights && (r_lights->value() <= 0.0f)) { + draw_lights = false; + } + + draw_particles = true; + if (r_particles && (r_particles->value() <= 0.0f)) { + draw_particles = false; + } + + // initialize lights + pass_reset_lights(); has_zone_light = false; zone_color.assign(1.0); @@ -1232,13 +1238,7 @@ void draw(float seconds) glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); - if (r_normalize && r_normalize->value()) { - // enable full normalization - gl::enable(GL_NORMALIZE); - } else { - // enable rescaling of normals - gl::enable(GL_RESCALE_NORMAL); - } + State::set_normalize(true); gl::enable(GL_LIGHTING); // enable lighting @@ -1250,13 +1250,7 @@ void draw(float seconds) gl::disable(GL_LIGHTING); // disable lighting - if (r_normalize && r_normalize->value()) { - // disable full normalization - gl::disable(GL_NORMALIZE); - } else { - // disable rescaling of normals - gl::disable(GL_RESCALE_NORMAL); - } + State::set_normalize(false); gl::enable(GL_BLEND); gl::depthmask(GL_FALSE); // disable depth buffer writing diff --git a/src/render/draw.h b/src/render/draw.h index 516da13..da5115f 100644 --- a/src/render/draw.h +++ b/src/render/draw.h @@ -15,6 +15,9 @@ namespace render { +/// reset lighting parameters +void pass_reset_lights(); + /// draw the world void draw(float seconds); diff --git a/src/render/state.cc b/src/render/state.cc index 293e464..fb64319 100644 --- a/src/render/state.cc +++ b/src/render/state.cc @@ -152,4 +152,23 @@ void State::clear() gl::disable(GL_TEXTURE_2D); } +void State::set_normalize(const bool enable) +{ + if (r_normalize && r_normalize->value()) { + // enable full normalization + if(enable) { + gl::enable(GL_NORMALIZE); + } else { + gl::disable(GL_NORMALIZE); + } + } else { + // enable rescaling of normals + if(enable) { + gl::enable(GL_RESCALE_NORMAL); + } else { + gl::disable(GL_RESCALE_NORMAL); + } + } +} + } // namespace render diff --git a/src/render/state.h b/src/render/state.h index 3fa3b80..6387be8 100644 --- a/src/render/state.h +++ b/src/render/state.h @@ -40,6 +40,8 @@ public: return render_vbo; } + static void set_normalize(const bool enable=true); + private: static int render_width; static int render_height; |