mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 12:41:21 +00:00
Implement retexturing for PCX files
This commit is contained in:
parent
d0133509e1
commit
57b06a8bcf
3 changed files with 69 additions and 6 deletions
|
@ -142,3 +142,24 @@ LoadPCX ( char *origname, byte **pic, byte **palette, int *width, int *height )
|
|||
|
||||
ri.FS_FreeFile( pcx );
|
||||
}
|
||||
|
||||
qboolean
|
||||
GetPCXInfo (char *filename, int *width, int *height)
|
||||
{
|
||||
pcx_t *pcx;
|
||||
byte *raw;
|
||||
|
||||
ri.FS_LoadFile (filename, (void **)&raw);
|
||||
if (!raw)
|
||||
return false;
|
||||
|
||||
pcx = (pcx_t *)raw;
|
||||
|
||||
*width = pcx->xmax + 1;
|
||||
*height = pcx->ymax + 1;
|
||||
|
||||
ri.FS_FreeFile (raw);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -319,6 +319,7 @@ image_t *LoadWal ( char *name );
|
|||
void LoadJPG ( char *origname, byte **pic, int *width, int *height );
|
||||
void LoadTGA ( char *origname, byte **pic, int *width, int *height );
|
||||
qboolean GetWalInfo ( char *name, int *width, int *height );
|
||||
qboolean GetPCXInfo ( char *filename, int *width, int *height );
|
||||
image_t *R_LoadPic ( char *name, byte *pic, int width, int realwidth, int height, int realheight, imagetype_t type, int bits );
|
||||
image_t *R_FindImage ( char *name, imagetype_t type );
|
||||
void R_TextureMode ( char *string );
|
||||
|
|
|
@ -1069,14 +1069,55 @@ R_FindImage ( char *name, imagetype_t type )
|
|||
|
||||
if ( !strcmp( name + len - 4, ".pcx" ) )
|
||||
{
|
||||
LoadPCX( name, &pic, &palette, &width, &height );
|
||||
|
||||
if ( !pic )
|
||||
if (gl_retexturing->value)
|
||||
{
|
||||
return ( NULL );
|
||||
}
|
||||
GetPCXInfo( name, &realwidth, &realheight );
|
||||
|
||||
image = R_LoadPic( name, pic, width, 0, height, 0, type, 8 );
|
||||
/* Try to load a TGA */
|
||||
LoadTGA( namewe, &pic, &width, &height );
|
||||
|
||||
if ( !pic )
|
||||
{
|
||||
/* JPEG if no TGA available */
|
||||
LoadJPG( namewe, &pic, &width, &height);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Upload TGA */
|
||||
image = R_LoadPic( name, pic, width, realwidth, height, realheight, type, 32 );
|
||||
}
|
||||
|
||||
if( !pic )
|
||||
{
|
||||
/* PCX if no JPEG available (exists always) */
|
||||
LoadPCX( name, &pic, &palette, &width, &height );
|
||||
|
||||
if ( !pic )
|
||||
{
|
||||
/* No texture found */
|
||||
return ( NULL );
|
||||
}
|
||||
|
||||
/* Upload the PCX */
|
||||
image = R_LoadPic( name, pic, width, 0, height, 0, type, 8 );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Upload JPEG */
|
||||
image = R_LoadPic( name, pic, width, realwidth, height, realheight, type, 32 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadPCX( name, &pic, &palette, &width, &height );
|
||||
|
||||
if ( !pic )
|
||||
{
|
||||
return ( NULL );
|
||||
}
|
||||
|
||||
image = R_LoadPic( name, pic, width, 0, height, 0, type, 8 );
|
||||
}
|
||||
}
|
||||
else if ( !strcmp( name + len - 4, ".wal" ) )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue