From 05928e35b08a47f5c80b7aa9a5b391a0c1d76ad5 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 14 Aug 2009 11:58:20 +0000 Subject: implemented r_normalize cvar --- src/render/draw.cc | 52 +++++++++++++++++++++++++++++++++++++++++----------- src/render/render.cc | 6 +++++- src/render/render.h | 2 ++ 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/render/draw.cc b/src/render/draw.cc index a48908f..0b6fba2 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -1115,9 +1115,6 @@ void draw_pass_model_fx(float elapsed) void draw_pass_model_radius() { - if (!(r_radius && r_radius->value())) - return; - for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { core::Entity *entity = (*it); @@ -1213,7 +1210,13 @@ void draw(float seconds) gl::enable(GL_COLOR_MATERIAL); // enable color tracking gl::enable(GL_LIGHTING); // enable lighting - gl::enable(GL_NORMALIZE); // enable rescaling of normals + if (r_normalize && r_normalize->value()) { + // enable full normalization + gl::enable(GL_NORMALIZE); + } else { + // enable rescaling of normals + gl::enable(GL_RESCALE_NORMAL); + } draw_pass_globes(); // draw globes @@ -1221,7 +1224,13 @@ void draw(float seconds) draw_pass_model_fragments(); - gl::disable(GL_NORMALIZE); // disable resaling of normals + if (r_normalize && r_normalize->value()) { + // disable full normalization + gl::disable(GL_NORMALIZE); + } else { + // disable resaling of normals + gl::disable(GL_RESCALE_NORMAL); + } gl::disable(GL_LIGHTING); // disable lighting gl::enable(GL_BLEND); @@ -1233,19 +1242,40 @@ void draw(float seconds) Dust::draw(zone_color); // draw spacedust } - draw_pass_model_fx(seconds); // draw entity lights and engines + // draw entity lights, flares and particles + draw_pass_model_fx(seconds); + + // draw entity radius globe + if (r_radius && r_radius->value()) { - gl::enable(GL_LIGHTING); - gl::enable(GL_RESCALE_NORMAL); + if (r_normalize && r_normalize->value()) { + // enable full normalization + gl::enable(GL_NORMALIZE); + } else { + // enable rescaling of normals + gl::enable(GL_RESCALE_NORMAL); + } - draw_pass_model_radius(); // draw entity radius + gl::enable(GL_LIGHTING); + + draw_pass_model_radius(); + + gl::disable(GL_LIGHTING); + + if (r_normalize && r_normalize->value()) { + // disable full normalization + gl::disable(GL_NORMALIZE); + } else { + // disable resaling of normals + gl::disable(GL_RESCALE_NORMAL); + } + } glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - gl::disable(GL_RESCALE_NORMAL); - gl::disable(GL_LIGHTING); + gl::disable(GL_COLOR_MATERIAL); // disable color tracking gl::disable(GL_CULL_FACE); // disable culling diff --git a/src/render/render.cc b/src/render/render.cc index e37f5f2..27204f6 100644 --- a/src/render/render.cc +++ b/src/render/render.cc @@ -35,6 +35,7 @@ core::Cvar *r_wireframe = 0; core::Cvar *r_mipmap = 0; core::Cvar *r_collision = 0; core::Cvar *r_normals = 0; +core::Cvar *r_normalize = 0; void func_list_textures(std::string const &args) { @@ -72,6 +73,9 @@ void init(int width, int height) r_normals = core::Cvar::get("r_normals", "0", core::Cvar::Archive); r_normals->set_info("[bool] render face normals"); + r_normalize = core::Cvar::get("r_normalize", "0", core::Cvar::Archive); + r_normalize->set_info("[bool] use GL_NORMALIZE instead of GL_RESCALE_NORMAL"); + r_grid = core::Cvar::get("r_grid", "0", core::Cvar::Archive); r_grid->set_info("[bool] render the space grid"); @@ -94,7 +98,7 @@ void init(int width, int height) Screenshot::screenshotquality->set_info("[int] screenshot jpg quality"); // hardware generate mipmaps - r_mipmap = core::Cvar::get("r_mipmap", "0", core::Cvar::Archive); + r_mipmap = core::Cvar::get("r_mipmap", "1", core::Cvar::Archive); r_mipmap->set_info("[bool] use hardware generated mipmaps"); if (!State::has_generate_mipmaps()) { con_print << " no hardware generated mipmap support" << std::endl; diff --git a/src/render/render.h b/src/render/render.h index 3d07796..0073f57 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -54,6 +54,8 @@ namespace render { extern core::Cvar *r_collision; /// use hardware generated mipmaps (requires OpenGL 1.4, does not work on all cards) extern core::Cvar *r_mipmap; + /// use GL_NORMALIZE instead of GL_RESCALE_NORMAL + extern core::Cvar *r_normalize; inline RenderExt *ext_render(core::Entity *entity) { return static_cast(entity->extension((size_t)core::Extension::Render)); } } -- cgit v1.2.3