Implement retexturing for PCX files

This commit is contained in:
Yamagi Burmeister 2012-03-12 09:54:04 +00:00
parent d0133509e1
commit 57b06a8bcf
3 changed files with 69 additions and 6 deletions

View file

@ -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;
}

View file

@ -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 );

View file

@ -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" ) )
{