From e82a8ac9aad4ed5e3c7cc715c6e8a16ce7726fe6 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Sat, 11 Mar 2006 18:33:56 +0000 Subject: [PATCH] add gl_lightmap_shift (needs to handle renderer swap), fix linux building git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2086 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/renderer.c | 3 ++ engine/gl/gl_rsurf.c | 59 ++++++++++++++++++++++------------------ engine/sw/vid_x.c | 1 + 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 8ee202d32..45d6ce728 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -246,6 +246,7 @@ cvar_t r_menutint = SCVAR("r_menutint", "0.68 0.4 0.13"); cvar_t gl_schematics = SCVAR("gl_schematics","0"); cvar_t gl_ztrick = SCVAR("gl_ztrick","0"); cvar_t gl_lerpimages = SCVAR("gl_lerpimages", "1"); +cvar_t gl_lightmap_shift = SCVARF("gl_lightmap_shift", "0", CVAR_ARCHIVE | CVAR_LATCH); extern cvar_t r_waterlayers; cvar_t gl_triplebuffer = SCVARF("gl_triplebuffer", "1", CVAR_ARCHIVE); cvar_t vid_hardwaregamma = SCVARF("vid_hardwaregamma", "1", CVAR_ARCHIVE); @@ -364,6 +365,8 @@ void GLRenderer_Init(void) Cvar_Register (&gl_mylumassuck, GLRENDEREROPTIONS); + Cvar_Register (&gl_lightmap_shift, GLRENDEREROPTIONS); + R_BloomRegister(); } #endif diff --git a/engine/gl/gl_rsurf.c b/engine/gl/gl_rsurf.c index 5cc263a59..fbf07d068 100644 --- a/engine/gl/gl_rsurf.c +++ b/engine/gl/gl_rsurf.c @@ -724,6 +724,7 @@ void GLR_BuildLightMap (msurface_t *surf, qbyte *dest, qbyte *deluxdest, stmap * unsigned *bl; qboolean isstained; extern cvar_t r_ambient; + extern cvar_t gl_lightmap_shift; #ifdef PEXT_LIGHTSTYLECOL unsigned *blg; unsigned *blb; @@ -732,6 +733,14 @@ void GLR_BuildLightMap (msurface_t *surf, qbyte *dest, qbyte *deluxdest, stmap * int cr, cg, cb; #endif int stride = LMBLOCK_WIDTH*lightmap_bytes; + int shift; + + if (gl_lightmap_shift.value >= 2) + shift = 9; + else if (gl_lightmap_shift.value == 1) + shift = 8; + else + shift = 7; surf->cached_dlight = (surf->dlightframe == r_framecount); @@ -1000,14 +1009,13 @@ store: for (j=0 ; j>= 7; - g = *blg++; - g >>= 7; - b = *blb++; - b >>= 7; - + + r >>= shift; + g >>= shift; + b >>= shift; + if (isstained) // merge in stain { r = (127+r*(*stain++)) >> 8; @@ -1158,13 +1166,12 @@ store: for (j=0 ; j>= 7; - g = *blg++; - g >>= 7; - b = *blb++; - b >>= 7; + + r >>= shift; + g >>= shift; + b >>= shift; if (isstained) // merge in stain { @@ -1263,7 +1270,7 @@ store: for (j=0 ; j>= 7; + t >>= shift; if (t > 255) t = 255; dest[3] = 255-t; @@ -1281,7 +1288,7 @@ store: for (j=0 ; j>= 7; + t >>= shift; if (t > 255) t = 255; dest[j] = 255-t; @@ -1353,14 +1360,13 @@ store: for (j=0 ; j>= 7; - g = *blg++; - g >>= 7; - b = *blb++; - b >>= 7; - + + r >>= shift; + g >>= shift; + b >>= shift; + if (isstained) // merge in stain { r = (127+r*(*stain++)) >> 8; @@ -1511,14 +1517,13 @@ store: for (j=0 ; j>= 7; - g = *blg++; - g >>= 7; - b = *blb++; - b >>= 7; - + + r >>= shift; + g >>= shift; + b >>= shift; + if (isstained) // merge in stain { r = (127+r*(*stain++)) >> 8; @@ -1616,7 +1621,7 @@ store: for (j=0 ; j>= 7; + t >>= shift; if (t > 255) t = 255; dest[3] = t; @@ -1634,7 +1639,7 @@ store: for (j=0 ; j>= 7; + t >>= shift; if (t > 255) t = 255; dest[j] = t; diff --git a/engine/sw/vid_x.c b/engine/sw/vid_x.c index 39916d354..c1bc988f8 100644 --- a/engine/sw/vid_x.c +++ b/engine/sw/vid_x.c @@ -691,6 +691,7 @@ printf("%8x\n", (int)vid_dpy); extern qbyte gammatable[256]; int j, i; float f; + int r, g, b; unsigned short *data; unsigned char *pal = host_basepal;