mirror of
https://github.com/yquake2/ref_vk.git
synced 2024-11-22 12:01:37 +00:00
Images: Get rid of custom Draw_GetPalette and move to pcx.c
This commit is contained in:
parent
3da1dd3a8d
commit
d6b350572a
4 changed files with 42 additions and 41 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
/build/
|
||||
/release/
|
||||
*.orig
|
||||
*.rej
|
||||
|
|
|
@ -60,6 +60,8 @@ typedef enum
|
|||
|
||||
extern void R_Printf(int level, const char* msg, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
/* Shared images load */
|
||||
extern void GetPCXPalette (byte **colormap, unsigned *d_8to24table);
|
||||
extern void LoadPCX(char *origname, byte **pic, byte **palette, int *width, int *height);
|
||||
extern void GetPCXInfo(char *filename, int *width, int *height);
|
||||
|
||||
|
|
|
@ -315,3 +315,38 @@ GetPCXInfo(char *filename, int *width, int *height)
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
GetPCXPalette
|
||||
===============
|
||||
*/
|
||||
void
|
||||
GetPCXPalette (byte **colormap, unsigned *d_8to24table)
|
||||
{
|
||||
byte *pal;
|
||||
int i;
|
||||
|
||||
/* get the palette and colormap */
|
||||
LoadPCX ("pics/colormap.pcx", colormap, &pal, NULL, NULL);
|
||||
if (!colormap)
|
||||
{
|
||||
ri.Sys_Error (ERR_FATAL, "Couldn't load pics/colormap.pcx");
|
||||
}
|
||||
|
||||
for (i=0 ; i<256 ; i++)
|
||||
{
|
||||
unsigned v;
|
||||
int r, g, b;
|
||||
|
||||
r = pal[i*3+0];
|
||||
g = pal[i*3+1];
|
||||
b = pal[i*3+2];
|
||||
|
||||
v = (255<<24) + (r<<0) + (g<<8) + (b<<16);
|
||||
d_8to24table[i] = LittleLong(v);
|
||||
}
|
||||
|
||||
d_8to24table[255] &= LittleLong(0xffffff); // 255 is transparent
|
||||
|
||||
free (pal);
|
||||
}
|
||||
|
|
|
@ -1598,46 +1598,6 @@ void Vk_FreeUnusedImages (void)
|
|||
vulkan_memory_free_unused();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
Draw_GetPalette
|
||||
===============
|
||||
*/
|
||||
static int Draw_GetPalette (void)
|
||||
{
|
||||
int i;
|
||||
byte *pic, *pal;
|
||||
int width, height;
|
||||
|
||||
// get the palette
|
||||
|
||||
LoadPCX ("pics/colormap.pcx", &pic, &pal, &width, &height);
|
||||
if (!pal)
|
||||
ri.Sys_Error (ERR_FATAL, "Couldn't load pics/colormap.pcx");
|
||||
|
||||
for (i=0 ; i<256 ; i++)
|
||||
{
|
||||
unsigned v;
|
||||
int r, g, b;
|
||||
|
||||
r = pal[i*3+0];
|
||||
g = pal[i*3+1];
|
||||
b = pal[i*3+2];
|
||||
|
||||
v = (255u<<24) + (r<<0) + (g<<8) + (b<<16);
|
||||
d_8to24table[i] = LittleLong(v);
|
||||
}
|
||||
|
||||
d_8to24table[255] &= LittleLong(0xffffff); // 255 is transparent
|
||||
|
||||
free (pic);
|
||||
free (pal);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
Vk_InitImages
|
||||
|
@ -1647,6 +1607,7 @@ void Vk_InitImages (void)
|
|||
{
|
||||
int i;
|
||||
float overbright;
|
||||
byte *colormap;
|
||||
|
||||
numvktextures = 0;
|
||||
img_loaded = 0;
|
||||
|
@ -1671,7 +1632,8 @@ void Vk_InitImages (void)
|
|||
intensitytable[i] = j;
|
||||
}
|
||||
|
||||
Draw_GetPalette();
|
||||
GetPCXPalette (&colormap, d_8to24table);
|
||||
free(colormap);
|
||||
|
||||
overbright = vk_overbrightbits->value;
|
||||
|
||||
|
|
Loading…
Reference in a new issue