- Applied patch from Steven Winston for m32 format texture

support.
This commit is contained in:
Jamie Wilkinson 2003-02-23 12:26:59 +00:00
parent 53a863747f
commit 4884d09e9a
3 changed files with 88 additions and 25 deletions

View File

@ -1354,6 +1354,35 @@ image_t *GL_LoadWal (char *name)
return image;
}
/* .M32 Support */
/*
* ==============
* GL_LoadWal32
* ==============
*/
image_t *GL_LoadWal32 (char *name)
{
miptex32_t *mt;
int width, height, ofs;
image_t *image;
ri.FS_LoadFile (name, (void **)&mt);
if (!mt)
{
ri.Con_Printf (PRINT_ALL, "GL_FindImage: Can't Load %s\n", name);
return r_notexture;
}
width = LittleLong (mt->width[0]);
height = LittleLong (mt->height[0]);
ofs = LittleLong (mt->offsets[0]);
image = GL_LoadPic (name, (byte *)mt + ofs, width, height, it_wall, 32);
ri.FS_FreeFile ((void *)mt);
return image;
}
/*
===============
GL_FindImage
@ -1406,8 +1435,9 @@ image_t *GL_FindImage (char *name, imagetype_t type)
if (!pic)
return NULL; // ri.Sys_Error (ERR_DROP, "GL_FindImage: can't load %s", name);
image = GL_LoadPic (name, pic, width, height, type, 32);
}
else
} else if (!strcmp(name+len-4, ".m32")) {
image = GL_LoadWal32 (name);
} else
return NULL; // ri.Sys_Error (ERR_DROP, "GL_FindImage: bad extension on: %s", name);

View File

@ -1,23 +1,25 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/* $Id$
*
* model loading and caching
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2003 The Quakeforge Project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// models.c -- model loading and caching
#include "gl_local.h"
@ -470,12 +472,15 @@ void Mod_LoadTexinfo (lump_t *l)
Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);
out->image = GL_FindImage (name, it_wall);
if (!out->image)
{
if (!out->image || out->image == r_notexture) {
Com_sprintf (name, sizeof(name), "textures/%s.m32", in->texture);
out->image = GL_FindImage (name, it_wall);
if (!out->image) {
ri.Con_Printf (PRINT_ALL, "Couldn't load %s\n", name);
out->image = r_notexture;
}
}
}
// count animation frames
for (i=0 ; i<count ; i++)

View File

@ -232,7 +232,35 @@ typedef struct miptex_s
int value;
} miptex_t;
/*
==============================================================================
.M32 texture File Format
==============================================================================
*/
typedef struct miptex32_s {
int version;
char name[128];
char altname[128]; /* texture substitution */
char animname[128]; /* next frame in animation chain */
char damagename[128]; /* image that should be shown when damaged */
unsigned width[16], height[16];
unsigned offsets[16];
int flags;
int contents;
int value;
float scale_x, scale_y;
int mip_scale;
/* detail texturing info */
char dt_name[128]; /* detailed texture name */
float dt_scale_x, dt_scale_y;
float dt_u, dt_v;
float dt_alpha;
int dt_src_blend_mode, dt_dst_blend_mode;
int flags2;
float damage_health;
int unused[18];
} miptex32_t;
/*
==============================================================================