mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-10 09:41:09 +00:00
convert our GL_RGB lightmaps to GL_RGBA which gives considerable
performance boost on some systems. add GL_BGRA as an option, thanks to Kristian Duske. the format is hardcoded as GL_RGBA for now, need a way to make it configurable later. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@813 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
00a3f7659b
commit
204c6290b2
1 changed files with 46 additions and 12 deletions
|
@ -884,13 +884,17 @@ void GL_BuildLightmaps (void)
|
||||||
lightmap_textures[i] = NULL;
|
lightmap_textures[i] = NULL;
|
||||||
//johnfitz
|
//johnfitz
|
||||||
|
|
||||||
gl_lightmap_format = GL_RGB; //johnfitz
|
gl_lightmap_format = GL_RGBA; //johnfitz
|
||||||
|
|
||||||
//johnfitz -- only support GL_RGB lightmaps
|
//johnfitz -- only support GL_RGB lightmaps
|
||||||
|
//kristian -- now with GL_BGRA support
|
||||||
switch (gl_lightmap_format)
|
switch (gl_lightmap_format)
|
||||||
{
|
{
|
||||||
case GL_RGB:
|
case GL_RGBA:
|
||||||
lightmap_bytes = 3;
|
lightmap_bytes = 4;
|
||||||
|
break;
|
||||||
|
case GL_BGRA:
|
||||||
|
lightmap_bytes = 4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Sys_Error ("GL_BuildLightmaps: bad lightmap format");
|
Sys_Error ("GL_BuildLightmaps: bad lightmap format");
|
||||||
|
@ -1040,7 +1044,7 @@ Combine and scale multiple lightmaps into the 8.8 format in blocklights
|
||||||
void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
|
void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
|
||||||
{
|
{
|
||||||
int smax, tmax;
|
int smax, tmax;
|
||||||
int t;
|
int r,g,b;
|
||||||
int i, j, size;
|
int i, j, size;
|
||||||
byte *lightmap;
|
byte *lightmap;
|
||||||
unsigned scale;
|
unsigned scale;
|
||||||
|
@ -1093,8 +1097,8 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
|
||||||
//johnfitz -- only support GL_RGB lightmaps
|
//johnfitz -- only support GL_RGB lightmaps
|
||||||
switch (gl_lightmap_format)
|
switch (gl_lightmap_format)
|
||||||
{
|
{
|
||||||
case GL_RGB:
|
case GL_RGBA:
|
||||||
stride -= smax * 3;
|
stride -= smax * 4;
|
||||||
bl = blocklights;
|
bl = blocklights;
|
||||||
for (i=0 ; i<tmax ; i++, dest += stride)
|
for (i=0 ; i<tmax ; i++, dest += stride)
|
||||||
{
|
{
|
||||||
|
@ -1102,16 +1106,46 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
|
||||||
{
|
{
|
||||||
if (gl_overbright.value)
|
if (gl_overbright.value)
|
||||||
{
|
{
|
||||||
t = *bl++ >> 8;if (t > 255) t = 255;*dest++ = t;
|
r = *bl++ >> 8;
|
||||||
t = *bl++ >> 8;if (t > 255) t = 255;*dest++ = t;
|
g = *bl++ >> 8;
|
||||||
t = *bl++ >> 8;if (t > 255) t = 255;*dest++ = t;
|
b = *bl++ >> 8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = *bl++ >> 7;if (t > 255) t = 255;*dest++ = t;
|
r = *bl++ >> 7;
|
||||||
t = *bl++ >> 7;if (t > 255) t = 255;*dest++ = t;
|
g = *bl++ >> 7;
|
||||||
t = *bl++ >> 7;if (t > 255) t = 255;*dest++ = t;
|
b = *bl++ >> 7;
|
||||||
}
|
}
|
||||||
|
if (r > 255) r = 255; *dest++ = r;
|
||||||
|
if (g > 255) g = 255; *dest++ = g;
|
||||||
|
if (b > 255) b = 255; *dest++ = b;
|
||||||
|
*dest++ = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GL_BGRA:
|
||||||
|
stride -= smax * 4;
|
||||||
|
bl = blocklights;
|
||||||
|
for (i=0 ; i<tmax ; i++, dest += stride)
|
||||||
|
{
|
||||||
|
for (j=0 ; j<smax ; j++)
|
||||||
|
{
|
||||||
|
if (gl_overbright.value)
|
||||||
|
{
|
||||||
|
r = *bl++ >> 8;
|
||||||
|
g = *bl++ >> 8;
|
||||||
|
b = *bl++ >> 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r = *bl++ >> 7;
|
||||||
|
g = *bl++ >> 7;
|
||||||
|
b = *bl++ >> 7;
|
||||||
|
}
|
||||||
|
if (b > 255) b = 255; *dest++ = b;
|
||||||
|
if (g > 255) g = 255; *dest++ = g;
|
||||||
|
if (r > 255) r = 255; *dest++ = r;
|
||||||
|
*dest++ = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue