From 9ea060555804465c497ae772c3d3e0b6821a9eeb Mon Sep 17 00:00:00 2001 From: Joseph Carter Date: Fri, 6 Apr 2001 02:12:19 +0000 Subject: [PATCH] reverting this for Mercury --- nq/include/glquake.h | 2 +- nq/source/gl_draw.c | 33 +++++++++++++++-------------- nq/source/gl_part.c | 4 ++-- nq/source/gl_rlight.c | 2 +- nq/source/gl_rmain.c | 5 +++-- nq/source/gl_rsurf.c | 12 ++++++----- nq/source/gl_screen.c | 15 ++++++++++++-- nq/source/gl_warp.c | 5 +++-- qw/include/glquake.h | 4 ++-- qw/source/gl_draw.c | 45 ++++++++++++++++++++-------------------- qw/source/gl_dyn_fires.c | 4 ++-- qw/source/gl_dyn_part.c | 6 ++++-- qw/source/gl_ngraph.c | 3 ++- qw/source/gl_rlight.c | 7 ++++--- qw/source/gl_rmain.c | 13 ++++++------ qw/source/gl_rsurf.c | 29 ++++++++++++-------------- qw/source/gl_screen.c | 21 +++++++++++++++---- qw/source/gl_sky.c | 5 +++-- qw/source/gl_sky_clip.c | 6 +++--- 19 files changed, 127 insertions(+), 94 deletions(-) diff --git a/nq/include/glquake.h b/nq/include/glquake.h index b6b36920a..4a962a0b5 100644 --- a/nq/include/glquake.h +++ b/nq/include/glquake.h @@ -206,7 +206,6 @@ extern cvar_t *gl_particles; extern cvar_t *gl_fires; extern cvar_t *gl_fb_models; extern cvar_t *gl_fb_bmodels; -extern cvar_t *gl_lightmode; extern int gl_lightmap_format; extern int gl_solid_format; @@ -220,6 +219,7 @@ extern cvar_t *gl_skymultipass; extern int mirrortexturenum; // quake texturenum, not gltexturenum extern qboolean mirror; +extern qboolean lighthalf; extern mplane_t *mirror_plane; extern float r_world_matrix[16]; diff --git a/nq/source/gl_draw.c b/nq/source/gl_draw.c index 25c6b8ca3..5013b4b97 100644 --- a/nq/source/gl_draw.c +++ b/nq/source/gl_draw.c @@ -63,6 +63,7 @@ static int GL_LoadPicTexture (qpic_t *pic); extern byte *host_basepal; extern unsigned char d_15to8table[65536]; extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor; +extern qboolean lighthalf; cvar_t *gl_nobind; cvar_t *gl_max_size; @@ -400,7 +401,6 @@ Draw_TextureMode_f (void) } } -extern void R_ForceLightUpdate (cvar_t *gl_lightmode); extern void glrmain_init (); extern void glrsurf_init (); @@ -415,9 +415,8 @@ Draw_Init (void) int i; // LordHavoc: lighting mode - gl_lightmode = Cvar_Get ("gl_lightmode", "0", CVAR_ARCHIVE, - R_ForceLightUpdate, - "Lighting mode (0 = GLQuake style, 1 = new style)"); + gl_lightmode = Cvar_Get ("gl_lightmode", "0", CVAR_ARCHIVE, 0, + "Lighting mode (0 = GLQuake style, 1 = new style)"); gl_nobind = Cvar_Get ("gl_nobind", "0", CVAR_NONE, 0, "whether or not to inhibit texture binding"); gl_max_size = Cvar_Get ("gl_max_size", "1024", CVAR_NONE, 0, "None"); // CVAR_FIXME @@ -453,6 +452,8 @@ Draw_Init (void) // lightmode 1 if (!strncasecmp ((char *) gl_renderer, "3dfx", 4)) Cvar_Set (gl_lightmode, "0"); + lighthalf = gl_lightmode->int_val != 0; // to avoid re-rendering all + // lightmaps on first frame Cmd_AddCommand ("gl_texturemode", &Draw_TextureMode_f, "No Description"); @@ -535,7 +536,7 @@ Draw_Character8 (int x, int y, int num) glBindTexture (GL_TEXTURE_2D, char_texture); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.5, 0.5, 0.5); else glColor3f (1, 1, 1); @@ -594,7 +595,7 @@ Draw_Crosshair (void) pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->int_val]; - if (gl_lightmode->int_val) + if (lighthalf) glColor4ub ((byte) ((int) pColor[0] >> 1), (byte) ((int) pColor[1] >> 1), (byte) ((int) pColor[2] >> 1), pColor[3]); @@ -634,7 +635,7 @@ Draw_Pic (int x, int y, qpic_t *pic) Scrap_Upload (); #endif gl = (glpic_t *) pic->data; - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.4, 0.4, 0.4); else glColor3f (0.8, 0.8, 0.8); @@ -674,7 +675,7 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, newtl = gl->tl + (srcy * oldglheight) / pic->height; newth = newtl + (height * oldglheight) / pic->height; - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.4, 0.4, 0.4); else glColor3f (0.8, 0.8, 0.8); @@ -746,7 +747,7 @@ Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation) glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.4, 0.4, 0.4); else glColor3f (0.8, 0.8, 0.8); @@ -813,7 +814,7 @@ Draw_ConsoleBackground (int lines) alpha = (float) (gl_conalpha->value * lines) / y; } - if (gl_lightmode->int_val) + if (lighthalf) glColor4f (0.4, 0.4, 0.4, alpha); else glColor4f (0.8, 0.8, 0.8, alpha); @@ -833,7 +834,7 @@ Draw_ConsoleBackground (int lines) // turn off alpha blending if (alpha < 1.0) { - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.4, 0.4, 0.4); else glColor3f (0.8, 0.8, 0.8); @@ -858,7 +859,7 @@ refresh window. void Draw_TileClear (int x, int y, int w, int h) { - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.4, 0.4, 0.4); else glColor3f (0.8, 0.8, 0.8); @@ -887,7 +888,7 @@ void Draw_Fill (int x, int y, int w, int h, int c) { glDisable (GL_TEXTURE_2D); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (host_basepal[c * 3] / 510.0, host_basepal[c * 3 + 1] / 510.0, host_basepal[c * 3 + 2] / 510.0); else @@ -902,7 +903,7 @@ Draw_Fill (int x, int y, int w, int h, int c) glVertex2f (x, y + h); glEnd (); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.5, 0.5, 0.5); else glColor3f (1, 1, 1); @@ -929,7 +930,7 @@ Draw_FadeScreen (void) glVertex2f (0, vid.height); glEnd (); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.5, 0.5, 0.5); else glColor3f (1, 1, 1); @@ -993,7 +994,7 @@ GL_Set2D (void) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.5, 0.5, 0.5); else glColor3f (1, 1, 1); diff --git a/nq/source/gl_part.c b/nq/source/gl_part.c index dee1b5668..c54021ffb 100644 --- a/nq/source/gl_part.c +++ b/nq/source/gl_part.c @@ -125,7 +125,7 @@ R_DrawParticles (void) theAlpha = 255 * (6 - p->ramp) / 6; else theAlpha = 255; - if (gl_lightmode->int_val) + if (lighthalf) glColor4ub ((byte) ((int) at[0] >> 1), (byte) ((int) at[1] >> 1), (byte) ((int) at[2] >> 1), theAlpha); else @@ -319,7 +319,7 @@ R_DrawFire (fire_t *f) } // we're not - draw it glBegin (GL_TRIANGLE_FAN); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (f->color[0] * 0.5, f->color[1] * 0.5, f->color[2] * 0.5); else glColor3fv (f->color); diff --git a/nq/source/gl_rlight.c b/nq/source/gl_rlight.c index 3978a1f2f..83e959578 100644 --- a/nq/source/gl_rlight.c +++ b/nq/source/gl_rlight.c @@ -129,7 +129,7 @@ R_RenderDlight (dlight_t *light) glBegin (GL_TRIANGLE_FAN); // glColor3f (0.2,0.1,0.0); // glColor3f (0.2,0.1,0.05); // changed dimlight effect - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (light->color[0] * 0.5, light->color[1] * 0.5, light->color[2] * 0.5); else diff --git a/nq/source/gl_rmain.c b/nq/source/gl_rmain.c index 2fd15c01d..d7ab854d8 100644 --- a/nq/source/gl_rmain.c +++ b/nq/source/gl_rmain.c @@ -141,6 +141,7 @@ cvar_t *gl_fb_bmodels; extern cvar_t *scr_fov; extern byte gammatable[256]; +extern qboolean lighthalf; static float vid_gamma = 1.0; // LordHavoc: place for gl_rmain setup code @@ -305,7 +306,7 @@ R_DrawSpriteModel (entity_t *e) right = vright; } - if (gl_lightmode->int_val) + if (lighthalf) glColor4f (0.5, 0.5, 0.5, 1); else glColor4f (1, 1, 1, 1); @@ -389,7 +390,7 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb) if (fb) glColor3f (1, 1, 1); - else if (gl_lightmode->int_val) + else if (lighthalf) shadelight *= 2; while (1) { // get the vertex count and primitive type diff --git a/nq/source/gl_rsurf.c b/nq/source/gl_rsurf.c index bd32f639c..dded7e424 100644 --- a/nq/source/gl_rsurf.c +++ b/nq/source/gl_rsurf.c @@ -96,6 +96,8 @@ byte *lightmaps[MAX_LIGHTMAPS]; msurface_t *waterchain = NULL; +extern qboolean lighthalf; + // LordHavoc: place for gl_rsurf setup code void glrsurf_init () @@ -120,7 +122,7 @@ recursivelightupdate (mnode_t *node) // LordHavoc: function to force all lightmaps to be updated void -R_ForceLightUpdate (cvar_t *gl_lightmode) +R_ForceLightUpdate () { if (cl.worldmodel && cl.worldmodel->nodes && cl.worldmodel->nodes->contents >= 0) @@ -310,7 +312,7 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride) if (gl_colorlights->int_val) { stride -= smax * 3; bl = blocklights; - if (gl_lightmode->int_val) { + if (lighthalf) { for (i = 0; i < tmax; i++, dest += stride) for (j = 0; j < smax; j++) { t = (int) *bl++ >> 8; @@ -334,7 +336,7 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride) } else { stride -= smax; bl = blocklights; - if (gl_lightmode->int_val) { + if (lighthalf) { for (i = 0; i < tmax; i++, dest += stride) for (j = 0; j < smax; j++) { t = (int) *bl++ >> 8; @@ -656,7 +658,7 @@ GL_WaterSurface (msurface_t *s) int i; glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - if (gl_lightmode->int_val) + if (lighthalf) glColor4f (0.5, 0.5, 0.5, r_wateralpha->value); else glColor4f (1, 1, 1, r_wateralpha->value); @@ -690,7 +692,7 @@ R_DrawWaterSurfaces (void) glLoadMatrixf (r_world_matrix); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - if (gl_lightmode->int_val) + if (lighthalf) glColor4f (0.5, 0.5, 0.5, r_wateralpha->value); else glColor4f (1, 1, 1, r_wateralpha->value); diff --git a/nq/source/gl_screen.c b/nq/source/gl_screen.c index 7684194f6..a0af08d16 100644 --- a/nq/source/gl_screen.c +++ b/nq/source/gl_screen.c @@ -918,6 +918,9 @@ SCR_TileClear (void) } float oldsbar = 0; +extern void R_ForceLightUpdate (); +qboolean lighthalf; +extern cvar_t *gl_lightmode; /* ================== @@ -983,6 +986,12 @@ SCR_UpdateScreen (void) // do 3D refresh drawing, and then update the screen // + // LordHavoc: set lighthalf based on gl_lightmode cvar + if (lighthalf != (gl_lightmode->int_val != 0)) { + lighthalf = gl_lightmode->int_val != 0; + R_ForceLightUpdate (); + } + SCR_SetUpToDrawConsole (); V_RenderView (); @@ -1034,8 +1043,10 @@ SCR_UpdateScreen (void) glDisable (GL_TEXTURE_2D); glEnable (GL_BLEND); Cvar_SetValue (brightness, bound (1, brightness->value, 5)); - if (gl_lightmode->int_val) // LordHavoc: render was done at half - // brightness + if (lighthalf) // LordHavoc: render was done at half + // + // + // brightness f = brightness->value * 2; else f = brightness->value; diff --git a/nq/source/gl_warp.c b/nq/source/gl_warp.c index 6011f31c3..f473fa4a7 100644 --- a/nq/source/gl_warp.c +++ b/nq/source/gl_warp.c @@ -49,6 +49,7 @@ extern double realtime; extern model_t *loadmodel; extern int skytexturenum; +extern qboolean lighthalf; int solidskytexture; int alphaskytexture; @@ -579,7 +580,7 @@ R_DrawSkyBox (void) // glDisable (GL_BLEND); // glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glDepthRange (gldepthmax, gldepthmax); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.5, 0.5, 0.5); else glColor3f (1, 1, 1); @@ -655,7 +656,7 @@ R_DrawSkyDome (void) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthRange (gldepthmax, gldepthmax); glDisable (GL_BLEND); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.5, 0.5, 0.5); else glColor3f (1, 1, 1); diff --git a/qw/include/glquake.h b/qw/include/glquake.h index ff2e7883b..cd283edc3 100644 --- a/qw/include/glquake.h +++ b/qw/include/glquake.h @@ -177,7 +177,6 @@ extern cvar_t *r_skyname; extern cvar_t *gl_skymultipass; extern cvar_t *gl_sky_clip; extern cvar_t *gl_sky_divide; -extern cvar_t *gl_lightmode; extern int gl_lightmap_format; extern int gl_solid_format; @@ -278,7 +277,8 @@ void R_StoreEfrags (efrag_t **ppefrag); // gl_screen.c // -extern unsigned char white_v[3]; +extern qboolean lighthalf; +extern unsigned char lighthalf_v[3]; // // gl_rsurf.c diff --git a/qw/source/gl_draw.c b/qw/source/gl_draw.c index 75b3e2474..70f5a9d68 100644 --- a/qw/source/gl_draw.c +++ b/qw/source/gl_draw.c @@ -248,7 +248,6 @@ Draw_TextBox (int x, int y, int width, int lines) } -extern void R_ForceLightUpdate (cvar_t *gl_lightmode); extern void glrmain_init (void); extern void glrsurf_init (void); extern void GL_TextureMode_f (void); @@ -267,10 +266,13 @@ Draw_Init (void) Cvar_Set (gl_lightmode, "0"); } - if (gl_lightmode->int_val) { - white_v[0] = white_v[1] = white_v[2] = 128; + lighthalf = gl_lightmode->int_val != 0; // to avoid re-rendering all + // lightmaps on first frame + + if (lighthalf) { + lighthalf_v[0] = lighthalf_v[1] = lighthalf_v[2] = 128; } else { - white_v[0] = white_v[1] = white_v[2] = 255; + lighthalf_v[0] = lighthalf_v[1] = lighthalf_v[2] = 255; } Cmd_AddCommand ("gl_texturemode", &GL_TextureMode_f, "Texture mipmap quality."); @@ -307,9 +309,8 @@ Draw_Init (void) void Draw_Init_Cvars (void) { - gl_lightmode = Cvar_Get ("gl_lightmode", "1", CVAR_ARCHIVE, - R_ForceLightUpdate, - "Lighting mode (0 = GLQuake style, 1 = new style)"); + gl_lightmode = Cvar_Get ("gl_lightmode", "1", CVAR_ARCHIVE, 0, + "Lighting mode (0 = GLQuake style, 1 = new style)"); gl_max_size = Cvar_Get ("gl_max_size", "1024", CVAR_NONE, 0, "Texture dimension"); gl_picmip = Cvar_Get ("gl_picmip", "0", CVAR_NONE, 0, "Dimensions of displayed textures. 0 is normal, 1 is half, 2 is 1/4"); gl_constretch = Cvar_Get ("gl_constretch", "0", CVAR_ARCHIVE, 0, @@ -411,7 +412,7 @@ Draw_Crosshair (void) y = scr_vrect.y + scr_vrect.height / 2 - 3 + cl_crossy->int_val; pColor = (unsigned char *) &d_8to24table[crosshaircolor->int_val]; - if (gl_lightmode->int_val) + if (lighthalf) glColor4ub ((byte) ((int) pColor[0] >> 1), (byte) ((int) pColor[1] >> 1), (byte) ((int) pColor[2] >> 1), pColor[3]); @@ -429,7 +430,7 @@ Draw_Crosshair (void) glTexCoord2f (0, 1); glVertex2f (x - 4, y + 12); glEnd (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); break; } } @@ -475,7 +476,7 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, newtl = gl->tl + (srcy * oldglheight) / pic->height; newth = newtl + (height * oldglheight) / pic->height; - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.4, 0.4, 0.4); else glColor3f (0.8, 0.8, 0.8); @@ -490,7 +491,7 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, glTexCoord2f (newsl, newth); glVertex2f (x, y + height); glEnd (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } @@ -531,7 +532,7 @@ Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation) glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.4, 0.4, 0.4); else glColor3f (0.8, 0.8, 0.8); @@ -545,7 +546,7 @@ Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation) glTexCoord2f (0, 1); glVertex2f (x, y + pic->height); glEnd (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } @@ -599,7 +600,7 @@ Draw_ConsoleBackground (int lines) alpha = (float) (gl_conalpha->value * lines) / y; } - if (gl_lightmode->int_val) + if (lighthalf) glColor4f (0.4, 0.4, 0.4, alpha); else glColor4f (0.8, 0.8, 0.8, alpha); @@ -619,7 +620,7 @@ Draw_ConsoleBackground (int lines) // turn off alpha blending if (alpha < 1.0) { - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.4, 0.4, 0.4); else glColor3f (0.8, 0.8, 0.8); @@ -634,7 +635,7 @@ Draw_ConsoleBackground (int lines) if (!cls.download) Draw_AltString8 (vid.conwidth - strlen (cl_verstring->string) * 8 - 11, lines - 14, cl_verstring->string); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } @@ -647,7 +648,7 @@ Draw_ConsoleBackground (int lines) void Draw_TileClear (int x, int y, int w, int h) { - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (0.4, 0.4, 0.4); else glColor3f (0.8, 0.8, 0.8); @@ -662,7 +663,7 @@ Draw_TileClear (int x, int y, int w, int h) glTexCoord2f (x / 64.0, (y + h) / 64.0); glVertex2f (x, y + h); glEnd (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } @@ -675,7 +676,7 @@ void Draw_Fill (int x, int y, int w, int h, int c) { glDisable (GL_TEXTURE_2D); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (host_basepal[c * 3] / 510.0, host_basepal[c * 3 + 1] / 510.0, host_basepal[c * 3 + 2] / 510.0); else @@ -690,7 +691,7 @@ Draw_Fill (int x, int y, int w, int h, int c) glVertex2f (x, y + h); glEnd (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); glEnable (GL_TEXTURE_2D); } @@ -712,7 +713,7 @@ Draw_FadeScreen (void) glVertex2f (0, vid.height); glEnd (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); glEnable (GL_TEXTURE_2D); Sbar_Changed (); @@ -764,5 +765,5 @@ GL_Set2D (void) glDisable (GL_DEPTH_TEST); glDisable (GL_CULL_FACE); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } diff --git a/qw/source/gl_dyn_fires.c b/qw/source/gl_dyn_fires.c index ea149b104..7219e7053 100644 --- a/qw/source/gl_dyn_fires.c +++ b/qw/source/gl_dyn_fires.c @@ -146,7 +146,7 @@ R_DrawFire (fire_t *f) } // we're not - draw it glBegin (GL_TRIANGLE_FAN); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (f->color[0] * 0.5, f->color[1] * 0.5, f->color[2] * 0.5); else glColor3fv (f->color); @@ -170,7 +170,7 @@ R_DrawFire (fire_t *f) b_cos += 2; } glEnd (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } /* diff --git a/qw/source/gl_dyn_part.c b/qw/source/gl_dyn_part.c index e04e82ca4..e2435a8b6 100644 --- a/qw/source/gl_dyn_part.c +++ b/qw/source/gl_dyn_part.c @@ -70,6 +70,8 @@ typedef struct particle_s { static particle_t *particles, **freeparticles; static short r_numparticles, numparticles; +extern qboolean lighthalf; + extern cvar_t *cl_max_particles; extern int part_tex_smoke[8]; @@ -590,7 +592,7 @@ R_DrawParticles (void) at = (byte *) & d_8to24table[(byte) part->color]; alpha = part->alpha; - if (gl_lightmode->int_val) + if (lighthalf) glColor4ub ((byte) ((int) at[0] >> 1), (byte) ((int) at[1] >> 1), (byte) ((int) at[2] >> 1), alpha); @@ -701,6 +703,6 @@ R_DrawParticles (void) } numparticles = activeparticles; - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); glDepthMask (GL_TRUE); } diff --git a/qw/source/gl_ngraph.c b/qw/source/gl_ngraph.c index fa9f3a3ba..785e4b8b3 100644 --- a/qw/source/gl_ngraph.c +++ b/qw/source/gl_ngraph.c @@ -45,6 +45,7 @@ #include "sbar.h" extern byte *draw_chars; // 8*8 graphic characters +extern qboolean lighthalf; extern cvar_t *r_netgraph; extern cvar_t *r_netgraph_alpha; @@ -173,5 +174,5 @@ R_NetGraph (void) glVertex2f (x, y + NET_GRAPHHEIGHT); glEnd (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } diff --git a/qw/source/gl_rlight.c b/qw/source/gl_rlight.c index 80340427b..372e2769a 100644 --- a/qw/source/gl_rlight.c +++ b/qw/source/gl_rlight.c @@ -42,6 +42,7 @@ #include "glquake.h" int r_dlightframecount; +extern qboolean lighthalf; /* @@ -125,7 +126,7 @@ R_RenderDlight (dlight_t *light) glBegin (GL_TRIANGLE_FAN); - if (gl_lightmode->int_val) + if (lighthalf) glColor3f (light->color[0] * 0.5, light->color[1] * 0.5, light->color[2] * 0.5); else @@ -151,7 +152,7 @@ R_RenderDlight (dlight_t *light) glEnd (); - // Don't glColor3ubv(white_v), as we reset in the function which + // Don't glColor3ubv(lighthalf_v), as we reset in the function which // calls this one, because this is called in a big loop. } @@ -183,7 +184,7 @@ R_RenderDlights (void) if (!gl_dlight_smooth->int_val) glShadeModel (GL_FLAT); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); glEnable (GL_TEXTURE_2D); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask (GL_TRUE); diff --git a/qw/source/gl_rmain.c b/qw/source/gl_rmain.c index 281fb448f..73122f6f4 100644 --- a/qw/source/gl_rmain.c +++ b/qw/source/gl_rmain.c @@ -136,6 +136,7 @@ cvar_t *brighten; extern cvar_t *scr_fov; extern byte gammatable[256]; +extern qboolean lighthalf; // LordHavoc: place for gl_rmain setup code void @@ -370,7 +371,7 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb) glDepthMask (GL_FALSE); if (fb) { // don't do this in the loop, it doesn't change - if (gl_lightmode->int_val) + if (lighthalf) glColor4f (0.5, 0.5, 0.5, modelalpha); else glColor4f (1, 1, 1, modelalpha); @@ -409,7 +410,7 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb) if (modelalpha != 1.0) glDepthMask (GL_TRUE); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } /* @@ -442,7 +443,7 @@ GL_DrawAliasBlendedFrame (aliashdr_t *paliashdr, int pose1, int pose2, float ble glDepthMask (GL_FALSE); if (fb) { // don't do this in the loop, it doesn't change - if (gl_lightmode->int_val) + if (lighthalf) glColor4f (0.5, 0.5, 0.5, modelalpha); else glColor4f (1, 1, 1, modelalpha); @@ -485,7 +486,7 @@ GL_DrawAliasBlendedFrame (aliashdr_t *paliashdr, int pose1, int pose2, float ble if (modelalpha != 1.0) glDepthMask (GL_TRUE); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } @@ -729,7 +730,7 @@ R_DrawAliasModel (entity_t *e) shadecolor[0] = currententity->colormod[0]; shadecolor[1] = currententity->colormod[1]; shadecolor[2] = currententity->colormod[2]; - if (!gl_lightmode->int_val) { + if (!lighthalf) { shadecolor[0] *= 2.0; shadecolor[1] *= 2.0; shadecolor[2] *= 2.0; @@ -889,7 +890,7 @@ R_DrawAliasModel (entity_t *e) } glEnable (GL_TEXTURE_2D); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); glPopMatrix (); } } diff --git a/qw/source/gl_rsurf.c b/qw/source/gl_rsurf.c index 6d2e94349..cb79f6ea3 100644 --- a/qw/source/gl_rsurf.c +++ b/qw/source/gl_rsurf.c @@ -85,6 +85,8 @@ byte *lightmaps[MAX_LIGHTMAPS]; msurface_t *waterchain = NULL; msurface_t *sky_chain; +extern qboolean lighthalf; + // LordHavoc: place for gl_rsurf setup code void glrsurf_init (void) @@ -109,16 +111,11 @@ R_RecursiveLightUpdate (mnode_t *node) // LordHavoc: function to force all lightmaps to be updated void -R_ForceLightUpdate (cvar_t *gl_lightmode) +R_ForceLightUpdate (void) { if (cl.worldmodel && cl.worldmodel->nodes && cl.worldmodel->nodes->contents >= 0) R_RecursiveLightUpdate (cl.worldmodel->nodes); - if (gl_lightmode->int_val) { - white_v[0] = white_v[1] = white_v[2] = 128; - } else { - white_v[0] = white_v[1] = white_v[2] = 255; - } } /* @@ -270,7 +267,7 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride) bl = blocklights; switch (lightmap_bytes) { case 4: - if (gl_lightmode->int_val) { + if (lighthalf) { for (i = 0; i < tmax; i++, dest += stride) { for (j = 0; j < smax; j++) { t = (int) *bl++ >> 8; @@ -297,7 +294,7 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride) } break; case 3: - if (gl_lightmode->int_val) { + if (lighthalf) { for (i = 0; i < tmax; i++, dest += stride) { for (j = 0; j < smax; j++) { t = (int) *bl++ >> 8; @@ -322,7 +319,7 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride) } break; case 1: - if (gl_lightmode->int_val) { + if (lighthalf) { for (i = 0; i < tmax; i++, dest += stride) { for (j = 0; j < smax; j++) { t = (int) *bl++ >> 8; @@ -474,7 +471,7 @@ R_DrawMultitexturePoly (msurface_t *s) s->polys->fb_chain = fullbright_polys[texture->gl_fb_texturenum]; fullbright_polys[texture->gl_fb_texturenum] = s->polys; } - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } @@ -517,7 +514,7 @@ R_BlendLightmaps (void) } // Return to normal blending --KB - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask (GL_TRUE); // back to normal Z buffering @@ -623,7 +620,7 @@ R_RenderBrushPoly (msurface_t *fa) R_BuildLightMap (fa, base, BLOCK_WIDTH * lightmap_bytes); } } - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } void @@ -635,13 +632,13 @@ GL_WaterSurface (msurface_t *s) glBindTexture (GL_TEXTURE_2D, i); if (r_wateralpha->value < 1.0) { glDepthMask (GL_FALSE); - if (gl_lightmode->int_val) { + if (lighthalf) { glColor4f (0.5, 0.5, 0.5, r_wateralpha->value); } else { glColor4f (1, 1, 1, r_wateralpha->value); } EmitWaterPolys (s); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); glDepthMask (GL_TRUE); } else EmitWaterPolys (s); @@ -665,7 +662,7 @@ R_DrawWaterSurfaces (void) if (r_wateralpha->value < 1.0) { glDepthMask (GL_FALSE); - if (gl_lightmode->int_val) { + if (lighthalf) { glColor4f (0.5, 0.5, 0.5, r_wateralpha->value); } else { glColor4f (1, 1, 1, r_wateralpha->value); @@ -685,7 +682,7 @@ R_DrawWaterSurfaces (void) if (r_wateralpha->value < 1.0) { glDepthMask (GL_TRUE); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } } diff --git a/qw/source/gl_screen.c b/qw/source/gl_screen.c index 3f45755a9..b7505734a 100644 --- a/qw/source/gl_screen.c +++ b/qw/source/gl_screen.c @@ -906,8 +906,12 @@ SCR_TileClear (void) } } +extern void R_ForceLightUpdate (void); + int oldviewsize = 0; -unsigned char white_v[3]; +unsigned char lighthalf_v[3]; +qboolean lighthalf; +extern cvar_t *gl_lightmode; extern cvar_t *brightness; /* SCR_UpdateScreen @@ -972,6 +976,15 @@ SCR_UpdateScreen (void) // do 3D refresh drawing, and then update the screen + if (lighthalf != gl_lightmode->int_val) { + lighthalf = gl_lightmode->int_val; + if (lighthalf) + lighthalf_v[0] = lighthalf_v[1] = lighthalf_v[2] = 128; + else + lighthalf_v[0] = lighthalf_v[1] = lighthalf_v[2] = 255; + R_ForceLightUpdate (); + } + SCR_SetUpToDrawConsole (); V_RenderView (); @@ -1011,7 +1024,7 @@ SCR_UpdateScreen (void) glDisable (GL_TEXTURE_2D); Cvar_SetValue (brightness, bound (1, brightness->value, 5)); - if (gl_lightmode->int_val) // LordHavoc: render was done at half + if (lighthalf) // LordHavoc: render was done at half // // brightness f = brightness->value * 2; @@ -1033,7 +1046,7 @@ SCR_UpdateScreen (void) f *= 0.5; } glEnd (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } @@ -1047,7 +1060,7 @@ SCR_UpdateScreen (void) glVertex2f (0, vid.height); glEnd (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } glEnable (GL_TEXTURE_2D); diff --git a/qw/source/gl_sky.c b/qw/source/gl_sky.c index 533ce8e5d..119f1df52 100644 --- a/qw/source/gl_sky.c +++ b/qw/source/gl_sky.c @@ -45,6 +45,7 @@ extern double realtime; extern model_t *loadmodel; extern int skytexturenum; +extern qboolean lighthalf; int solidskytexture; int alphaskytexture; @@ -259,14 +260,14 @@ R_DrawSky (void) { float l = 1 / (256 * brightness->value); - glColor3f (white_v[0] * l, white_v[1] * l, white_v[2] * l); + glColor3f (lighthalf_v[0] * l, lighthalf_v[1] * l, lighthalf_v[2] * l); if (skyloaded) R_DrawSkyBox (); else R_DrawSkyDome (); - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); } diff --git a/qw/source/gl_sky_clip.c b/qw/source/gl_sky_clip.c index 4a1357b45..673839122 100644 --- a/qw/source/gl_sky_clip.c +++ b/qw/source/gl_sky_clip.c @@ -662,7 +662,7 @@ R_DrawSkyChain (msurface_t *sky_chain) msurface_t *sc = sky_chain; float l = 1 / (256 * brightness->value); - glColor3f (white_v[0] * l, white_v[1] * l, white_v[2] * l); + glColor3f (lighthalf_v[0] * l, lighthalf_v[1] * l, lighthalf_v[2] * l); if (skyloaded) { glDepthRange (gldepthmax, gldepthmax); while (sc) { @@ -710,7 +710,7 @@ R_DrawSkyChain (msurface_t *sky_chain) sc = sc->texturechain; } #endif - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); #if 0 glDisable (GL_TEXTURE_2D); sc = sky_chain; @@ -768,7 +768,7 @@ R_DrawSkyChain (msurface_t *sky_chain) glEnd (); } } - glColor3ubv (white_v); + glColor3ubv (lighthalf_v); glEnable (GL_TEXTURE_2D); #endif }