mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-17 01:21:12 +00:00
soft: move light code to separate function
This commit is contained in:
parent
a58fb0ed01
commit
afc892001d
3 changed files with 65 additions and 46 deletions
|
@ -770,7 +770,7 @@ R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel)
|
|||
// set up the skin and verify it exists
|
||||
if ( !R_AliasSetupSkin(currententity, currentmodel) )
|
||||
{
|
||||
R_Printf( PRINT_ALL, "R_AliasDrawModel %s: NULL skin found\n",
|
||||
R_Printf(PRINT_ALL, "R_AliasDrawModel %s: NULL skin found\n",
|
||||
currentmodel->name);
|
||||
aliasxscale = oldAliasxscale;
|
||||
aliasyscale = oldAliasyscale;
|
||||
|
|
|
@ -2332,7 +2332,7 @@ SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen )
|
|||
|
||||
if ((mode >= 0) && !ri.Vid_GetModeInfo( pwidth, pheight, mode ) )
|
||||
{
|
||||
R_Printf( PRINT_ALL, " invalid mode\n" );
|
||||
R_Printf(PRINT_ALL, " invalid mode\n");
|
||||
return rserr_invalid_mode;
|
||||
}
|
||||
|
||||
|
@ -2341,7 +2341,7 @@ SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen )
|
|||
{
|
||||
if(!ri.GLimp_GetDesktopMode(pwidth, pheight))
|
||||
{
|
||||
R_Printf( PRINT_ALL, " can't detect mode\n" );
|
||||
R_Printf(PRINT_ALL, " can't detect mode\n");
|
||||
return rserr_invalid_mode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,66 @@ R_GreyscaledLight(const light3_t light)
|
|||
return LIGHTMASK;
|
||||
}
|
||||
|
||||
static void
|
||||
R_DrawSurfaceBlock_Light (pixel_t *prowdest, pixel_t *psource, size_t size,
|
||||
int level, light3_t lightleft, light3_t lightright)
|
||||
{
|
||||
int light_masked_right, light_masked_left;
|
||||
|
||||
light_masked_right = R_GreyscaledLight(lightright);
|
||||
if (light_masked_right != LIGHTMASK)
|
||||
{
|
||||
light_masked_left = R_GreyscaledLight(lightleft);
|
||||
}
|
||||
|
||||
// Full same light from both side
|
||||
if (light_masked_right != LIGHTMASK && light_masked_left == light_masked_right)
|
||||
{
|
||||
pixel_t *dest, *dest_max, *src;
|
||||
|
||||
dest = prowdest;
|
||||
dest_max = prowdest + size;
|
||||
src = psource;
|
||||
|
||||
while (dest < dest_max)
|
||||
{
|
||||
*dest = vid_colormap[*src + light_masked_right];
|
||||
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// same color light shades
|
||||
{
|
||||
int b, j;
|
||||
light3_t lightstep, light;
|
||||
|
||||
for(j=0; j<3; j++)
|
||||
{
|
||||
int lighttemp;
|
||||
|
||||
lighttemp = lightleft[j] - lightright[j];
|
||||
lightstep[j] = lighttemp >> level;
|
||||
}
|
||||
|
||||
memcpy(light, lightright, sizeof(light3_t));
|
||||
|
||||
for (b=(size-1); b>=0; b--)
|
||||
{
|
||||
pixel_t pix;
|
||||
pix = psource[b];
|
||||
prowdest[b] = R_ApplyLight(pix, light);
|
||||
|
||||
for(j=0; j<3; j++)
|
||||
light[j] += lightstep[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
R_DrawSurfaceBlock8_anymip
|
||||
|
@ -91,7 +151,7 @@ static void
|
|||
R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes)
|
||||
{
|
||||
int v, i, size;
|
||||
unsigned char *psource, *prowdest;
|
||||
pixel_t *psource, *prowdest;
|
||||
|
||||
size = 1 << level;
|
||||
psource = pbasesource;
|
||||
|
@ -116,48 +176,7 @@ R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes)
|
|||
{
|
||||
int j;
|
||||
|
||||
int light_masked = R_GreyscaledLight(lightright);
|
||||
if (light_masked != LIGHTMASK && R_GreyscaledLight(lightleft) == light_masked )
|
||||
{
|
||||
pixel_t *dest, *dest_max, *src;
|
||||
|
||||
dest = prowdest;
|
||||
dest_max = prowdest + size;
|
||||
src = psource;
|
||||
|
||||
while (dest < dest_max)
|
||||
{
|
||||
*dest = vid_colormap[*src + light_masked];
|
||||
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int b;
|
||||
light3_t lightstep, light;
|
||||
|
||||
for(j=0; j<3; j++)
|
||||
{
|
||||
int lighttemp;
|
||||
|
||||
lighttemp = lightleft[j] - lightright[j];
|
||||
lightstep[j] = lighttemp >> level;
|
||||
}
|
||||
|
||||
memcpy(light, lightright, sizeof(light3_t));
|
||||
|
||||
for (b=(size-1); b>=0; b--)
|
||||
{
|
||||
pixel_t pix;
|
||||
pix = psource[b];
|
||||
prowdest[b] = R_ApplyLight(pix, light);
|
||||
|
||||
for(j=0; j<3; j++)
|
||||
light[j] += lightstep[j];
|
||||
}
|
||||
}
|
||||
R_DrawSurfaceBlock_Light(prowdest, psource, size, level, lightleft, lightright);
|
||||
|
||||
psource += sourcetstep;
|
||||
|
||||
|
|
Loading…
Reference in a new issue