Allow loading textures not aligned to 16 pixels

This fixes the mg1/horde2 loading error

(taken from quakespasm-gl4 fork.)
This commit is contained in:
Andrei Drexler 2021-12-04 11:11:10 +03:00 committed by Ozkan Sezer
parent a4dcdda3d9
commit eeda766f12
3 changed files with 3 additions and 6 deletions

View File

@ -489,18 +489,16 @@ void Mod_LoadTextures (lump_t *l)
if ( (mt->width & 15) || (mt->height & 15) )
{
if (loadmodel->bspversion != BSPVERSION_QUAKE64)
Sys_Error ("Texture %s is not 16 aligned", mt->name);
Con_Warning ("Texture %s (%d x %d) is not 16 aligned\n", mt->name, mt->width, mt->height);
}
pixels = mt->width*mt->height/64*85;
pixels = mt->width*mt->height; // only copy the first mip, the rest are auto-generated
tx = (texture_t *) Hunk_AllocName (sizeof(texture_t) +pixels, loadname );
loadmodel->textures[i] = tx;
memcpy (tx->name, mt->name, sizeof(tx->name));
tx->width = mt->width;
tx->height = mt->height;
for (j=0 ; j<MIPLEVELS ; j++)
tx->offsets[j] = mt->offsets[j] + sizeof(texture_t) - sizeof(miptex_t);
// the pixels immediately follow the structures
// ericw -- check for pixels extending past the end of the lump.

View File

@ -96,7 +96,6 @@ typedef struct texture_s
int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence
struct texture_s *alternate_anims; // bmodels in frmae 1 use these
unsigned offsets[MIPLEVELS]; // four mip maps stored
} texture_t;

View File

@ -101,7 +101,7 @@ void Sky_LoadTexture (texture_t *mt)
static byte back_data[128*128]; //FIXME: Hunk_Alloc
unsigned *rgba;
src = (byte *)mt + mt->offsets[0];
src = (byte *)(mt + 1);
// extract back layer and upload
for (i=0 ; i<128 ; i++)