Scale the replacement textures to the size of the original texture

This commit is contained in:
Yamagi Burmeister 2012-03-12 08:53:22 +00:00
parent 9edf27f103
commit 43fcc8eb99
4 changed files with 24 additions and 10 deletions

View file

@ -34,7 +34,7 @@ LoadWal ( char *origname )
height = LittleLong( mt->height );
ofs = LittleLong( mt->offsets [ 0 ] );
image = R_LoadPic( name, (byte *) mt + ofs, width, height, it_wall, 8 );
image = R_LoadPic( name, (byte *) mt + ofs, width, 0, height, 0, it_wall, 8 );
ri.FS_FreeFile( (void *) mt );

View file

@ -317,7 +317,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 );
image_t *R_LoadPic ( char *name, byte *pic, int width, int height, imagetype_t type, int bits );
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 );
void R_ImageList_f ( void );

View file

@ -895,7 +895,7 @@ R_Upload8 ( byte *data, int width, int height, qboolean mipmap, qboolean is_sky
* This is also used as an entry point for the generated r_notexture
*/
image_t *
R_LoadPic ( char *name, byte *pic, int width, int height, imagetype_t type, int bits )
R_LoadPic ( char *name, byte *pic, int width, int realwidth, int height, int realheight, imagetype_t type, int bits )
{
image_t *image;
int i;
@ -994,6 +994,20 @@ R_LoadPic ( char *name, byte *pic, int width, int height, imagetype_t type, int
image->upload_width = upload_width; /* after power of 2 and scales */
image->upload_height = upload_height;
image->paletted = uploaded_paletted;
if ( realwidth && realheight )
{
if ( ( realwidth <= image->width ) && ( realheight <= image->height ) )
{
image->width = realwidth;
image->height = realheight;
}
else
{
ri.Con_Printf( PRINT_DEVELOPER, "Warning, image '%s' has hi-res replacement smaller than the original! (%d x %d) < (%d x %d)\n", name, image->width, image->height, realwidth, realheight );
}
}
image->sl = 0;
image->sh = 1;
image->tl = 0;
@ -1062,7 +1076,7 @@ R_FindImage ( char *name, imagetype_t type )
return ( NULL );
}
image = R_LoadPic( name, pic, width, height, type, 8 );
image = R_LoadPic( name, pic, width, 0, height, 0, type, 8 );
}
else if ( !strcmp( name + len - 4, ".wal" ) )
{
@ -1080,7 +1094,7 @@ R_FindImage ( char *name, imagetype_t type )
else
{
/* Upload TGA */
image = R_LoadPic( name, pic, width, height, type, 32 );
image = R_LoadPic( name, pic, width, realwidth, height, realheight, type, 32 );
}
if( !pic )
@ -1091,7 +1105,7 @@ R_FindImage ( char *name, imagetype_t type )
else
{
/* Upload JPEG */
image = R_LoadPic( name, pic, width, height, type, 32 );
image = R_LoadPic( name, pic, width, realwidth, height, realheight, type, 32 );
}
if ( !image )
@ -1103,12 +1117,12 @@ R_FindImage ( char *name, imagetype_t type )
else if ( !strcmp( name + len - 4, ".tga" ) )
{
LoadTGA( name, &pic, &width, &height );
image = R_LoadPic( name, pic, width, height, type, 32 );
image = R_LoadPic( name, pic, width, realwidth, height, realwidth, type, 32 );
}
else if ( !strcmp( name + len - 4, ".jpg" ) )
{
LoadJPG( name, &pic, &width, &height );
image = R_LoadPic( name, pic, width, height, type, 32 );
image = R_LoadPic( name, pic, width, realwidth, height, realheight, type, 32 );
}
else
{

View file

@ -64,7 +64,7 @@ R_InitParticleTexture ( void )
}
}
r_particletexture = R_LoadPic( "***particle***", (byte *) data, 8, 8, it_sprite, 32 );
r_particletexture = R_LoadPic( "***particle***", (byte *) data, 8, 0, 8, 0, it_sprite, 32 );
/* also use this for bad textures, but without alpha */
for ( x = 0; x < 8; x++ )
@ -78,7 +78,7 @@ R_InitParticleTexture ( void )
}
}
r_notexture = R_LoadPic( "***r_notexture***", (byte *) data, 8, 8, it_wall, 32 );
r_notexture = R_LoadPic( "***r_notexture***", (byte *) data, 8, 0, 8, 0, it_wall, 32 );
}
void