mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-17 01:21:12 +00:00
soft: add fullcolor light apply
This commit is contained in:
parent
15553b9971
commit
a6839bc584
3 changed files with 38 additions and 9 deletions
|
@ -582,12 +582,14 @@ void RE_Draw_FadeScreen (void);
|
||||||
|
|
||||||
void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height);
|
void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height);
|
||||||
|
|
||||||
|
extern byte d_8to24table[256 * 4];
|
||||||
void R_InitImages(void);
|
void R_InitImages(void);
|
||||||
void R_ShutdownImages(void);
|
void R_ShutdownImages(void);
|
||||||
image_t *R_FindImage(char *name, imagetype_t type);
|
image_t *R_FindImage(char *name, imagetype_t type);
|
||||||
byte *Get_BestImageSize(const image_t *image, int *req_width, int *req_height);
|
byte *Get_BestImageSize(const image_t *image, int *req_width, int *req_height);
|
||||||
void R_FreeUnusedImages(void);
|
void R_FreeUnusedImages(void);
|
||||||
qboolean R_ImageHasFreeSpace(void);
|
qboolean R_ImageHasFreeSpace(void);
|
||||||
|
pixel_t R_ApplyLight(pixel_t pix, const int light[3]);
|
||||||
|
|
||||||
void R_InitSkyBox(model_t *loadmodel);
|
void R_InitSkyBox(model_t *loadmodel);
|
||||||
void R_IMFlatShadedQuad( const vec3_t a, const vec3_t b, const vec3_t c, const vec3_t d, int color, float alpha );
|
void R_IMFlatShadedQuad( const vec3_t a, const vec3_t b, const vec3_t c, const vec3_t d, int color, float alpha );
|
||||||
|
|
|
@ -323,7 +323,34 @@ R_LoadWal (char *name, imagetype_t type)
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *d_16to8table = NULL; // 16 to 8 bit conversion table
|
static byte *d_16to8table = NULL; // 16 to 8 bit conversion table
|
||||||
|
|
||||||
|
pixel_t
|
||||||
|
R_ApplyLight(pixel_t pix, const int light[3])
|
||||||
|
{
|
||||||
|
pixel_t i_r, i_g, i_b;
|
||||||
|
byte b_r, b_g, b_b;
|
||||||
|
int i_c;
|
||||||
|
|
||||||
|
/* get index of color component of each component */
|
||||||
|
i_r = vid_colormap[(light[0] & 0xFF00) + pix];
|
||||||
|
i_g = vid_colormap[(light[1] & 0xFF00) + pix];
|
||||||
|
i_b = vid_colormap[(light[2] & 0xFF00) + pix];
|
||||||
|
|
||||||
|
/* get color component for each component */
|
||||||
|
b_r = d_8to24table[i_r * 4 + 0];
|
||||||
|
b_g = d_8to24table[i_g * 4 + 1];
|
||||||
|
b_b = d_8to24table[i_b * 4 + 2];
|
||||||
|
|
||||||
|
/* convert back to indexed color */
|
||||||
|
b_r = ( b_r >> 3 ) & 31;
|
||||||
|
b_g = ( b_g >> 2 ) & 63;
|
||||||
|
b_b = ( b_b >> 3 ) & 31;
|
||||||
|
|
||||||
|
i_c = b_r | ( b_g << 5 ) | ( b_b << 11 );
|
||||||
|
|
||||||
|
return d_16to8table[i_c & 0xFFFF];
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_Convert32To8bit(const unsigned char* pic_in, pixel_t* pic_out, size_t size)
|
R_Convert32To8bit(const unsigned char* pic_in, pixel_t* pic_out, size_t size)
|
||||||
|
|
|
@ -51,7 +51,7 @@ static qboolean palette_changed;
|
||||||
|
|
||||||
refimport_t ri;
|
refimport_t ri;
|
||||||
|
|
||||||
static unsigned d_8to24table[256];
|
byte d_8to24table[256 * 4];
|
||||||
|
|
||||||
char skyname[MAX_QPATH];
|
char skyname[MAX_QPATH];
|
||||||
vec3_t skyaxis;
|
vec3_t skyaxis;
|
||||||
|
@ -1230,7 +1230,7 @@ R_CalcPalette (void)
|
||||||
if (modified)
|
if (modified)
|
||||||
{ // set back to default
|
{ // set back to default
|
||||||
modified = false;
|
modified = false;
|
||||||
R_GammaCorrectAndSetPalette( ( const unsigned char * ) d_8to24table );
|
R_GammaCorrectAndSetPalette( d_8to24table );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1246,7 +1246,7 @@ R_CalcPalette (void)
|
||||||
|
|
||||||
one_minus_alpha = (1.0 - alpha);
|
one_minus_alpha = (1.0 - alpha);
|
||||||
|
|
||||||
in = (byte *)d_8to24table;
|
in = d_8to24table;
|
||||||
out = palette[0];
|
out = palette[0];
|
||||||
for (i=0 ; i<256 ; i++, in+=4, out+=4)
|
for (i=0 ; i<256 ; i++, in+=4, out+=4)
|
||||||
{
|
{
|
||||||
|
@ -1439,7 +1439,7 @@ R_InitGraphics( int width, int height )
|
||||||
|
|
||||||
R_InitCaches();
|
R_InitCaches();
|
||||||
|
|
||||||
R_GammaCorrectAndSetPalette((const unsigned char *)d_8to24table);
|
R_GammaCorrectAndSetPalette(d_8to24table);
|
||||||
}
|
}
|
||||||
|
|
||||||
static rserr_t SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen);
|
static rserr_t SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen);
|
||||||
|
@ -1466,7 +1466,7 @@ RE_BeginFrame( float camera_separation )
|
||||||
if ( vid_gamma->modified || sw_overbrightbits->modified )
|
if ( vid_gamma->modified || sw_overbrightbits->modified )
|
||||||
{
|
{
|
||||||
Draw_BuildGammaTable();
|
Draw_BuildGammaTable();
|
||||||
R_GammaCorrectAndSetPalette((const unsigned char * )d_8to24table);
|
R_GammaCorrectAndSetPalette(d_8to24table);
|
||||||
// we need redraw everything
|
// we need redraw everything
|
||||||
VID_WholeDamageBuffer();
|
VID_WholeDamageBuffer();
|
||||||
// and backbuffer should be zeroed
|
// and backbuffer should be zeroed
|
||||||
|
@ -1602,7 +1602,7 @@ RE_SetPalette(const unsigned char *palette)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_GammaCorrectAndSetPalette((const unsigned char *)d_8to24table);
|
R_GammaCorrectAndSetPalette(d_8to24table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1759,7 +1759,7 @@ Draw_GetPalette (void)
|
||||||
ri.Sys_Error (ERR_FATAL, "Couldn't load pics/colormap.pcx");
|
ri.Sys_Error (ERR_FATAL, "Couldn't load pics/colormap.pcx");
|
||||||
vid_alphamap = vid_colormap + 64*256;
|
vid_alphamap = vid_colormap + 64*256;
|
||||||
|
|
||||||
out = (byte *)d_8to24table;
|
out = d_8to24table;
|
||||||
for (i=0 ; i<256 ; i++, out+=4)
|
for (i=0 ; i<256 ; i++, out+=4)
|
||||||
{
|
{
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
|
@ -2409,7 +2409,7 @@ SWimp_CreateRender(int width, int height)
|
||||||
|
|
||||||
memset(sw_state.currentpalette, 0, sizeof(sw_state.currentpalette));
|
memset(sw_state.currentpalette, 0, sizeof(sw_state.currentpalette));
|
||||||
|
|
||||||
R_GammaCorrectAndSetPalette( ( const unsigned char * ) d_8to24table );
|
R_GammaCorrectAndSetPalette( d_8to24table );
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is only here so the functions in q_shared.c and q_shwin.c can link
|
// this is only here so the functions in q_shared.c and q_shwin.c can link
|
||||||
|
|
Loading…
Reference in a new issue