mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-25 22:10:59 +00:00
vid: cache colormap
This commit is contained in:
parent
4268fedce0
commit
bcda8cccaf
3 changed files with 51 additions and 7 deletions
|
@ -48,6 +48,8 @@ qboolean VID_HasRenderer(const char *renderer);
|
|||
void VID_Init(void);
|
||||
void VID_Shutdown(void);
|
||||
void VID_CheckChanges(void);
|
||||
void VID_ImageInit(void);
|
||||
void VID_ImageDestroy(void);
|
||||
|
||||
void VID_MenuInit(void);
|
||||
void VID_MenuDraw(void);
|
||||
|
|
|
@ -112,6 +112,10 @@ static unsigned char quitscreenfix[] = {
|
|||
1,40,4,4,40,4,29,28,31,45,47,28,47,47,4,40,28,28
|
||||
};
|
||||
|
||||
static byte *colormap_cache = NULL;
|
||||
static unsigned d_8to24table_cache[256];
|
||||
|
||||
|
||||
static void
|
||||
fixQuitScreen(byte* px)
|
||||
{
|
||||
|
@ -353,13 +357,8 @@ GenerateColormap(const byte *palette, byte *out_colormap)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
VID_GetPalette
|
||||
===============
|
||||
*/
|
||||
void
|
||||
VID_GetPalette(byte **colormap, unsigned *d_8to24table)
|
||||
static void
|
||||
LoadPalette(byte **colormap, unsigned *d_8to24table)
|
||||
{
|
||||
const char * filename;
|
||||
int bytesPerPixel;
|
||||
|
@ -470,6 +469,44 @@ VID_GetPalette(byte **colormap, unsigned *d_8to24table)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
VID_GetPalette
|
||||
===============
|
||||
*/
|
||||
void
|
||||
VID_GetPalette(byte **colormap, unsigned *d_8to24table)
|
||||
{
|
||||
if (!colormap_cache)
|
||||
{
|
||||
LoadPalette(&colormap_cache, d_8to24table_cache);
|
||||
}
|
||||
|
||||
if (!colormap_cache)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
*colormap = malloc(256 * 320);
|
||||
memcpy(*colormap, colormap_cache, 256 * 320);
|
||||
memcpy(d_8to24table, d_8to24table_cache, sizeof(d_8to24table_cache));
|
||||
}
|
||||
|
||||
void
|
||||
VID_ImageInit(void)
|
||||
{
|
||||
colormap_cache = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
VID_ImageDestroy(void)
|
||||
{
|
||||
if (colormap_cache)
|
||||
{
|
||||
free(colormap_cache);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VID_GetPalette24to8(const byte *d_8to24table, byte** d_16to8table)
|
||||
{
|
||||
|
|
|
@ -602,6 +602,8 @@ VID_Init(void)
|
|||
Com_Error(ERR_FATAL, "Couldn't initialize the graphics subsystem!\n");
|
||||
}
|
||||
|
||||
VID_ImageInit();
|
||||
|
||||
// Load the renderer and get things going.
|
||||
VID_CheckChanges();
|
||||
}
|
||||
|
@ -613,6 +615,9 @@ void
|
|||
VID_Shutdown(void)
|
||||
{
|
||||
VID_ShutdownRenderer();
|
||||
|
||||
VID_ImageDestroy();
|
||||
|
||||
GLimp_Shutdown();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue