mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-09 23:02:02 +00:00
renders: simplify swl/pcx load code
This commit is contained in:
parent
dec5897052
commit
829b1a014e
5 changed files with 34 additions and 112 deletions
5
Makefile
5
Makefile
|
@ -1100,7 +1100,6 @@ REFGL1_OBJS_ := \
|
|||
src/client/refresh/files/maps.o \
|
||||
src/client/refresh/files/models.o \
|
||||
src/client/refresh/files/models_md5.o \
|
||||
src/client/refresh/files/pcx.o \
|
||||
src/client/refresh/files/stb.o \
|
||||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/warp.o \
|
||||
|
@ -1140,7 +1139,6 @@ REFGL3_OBJS_ := \
|
|||
src/client/refresh/files/maps.o \
|
||||
src/client/refresh/files/models.o \
|
||||
src/client/refresh/files/models_md5.o \
|
||||
src/client/refresh/files/pcx.o \
|
||||
src/client/refresh/files/stb.o \
|
||||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/warp.o \
|
||||
|
@ -1186,7 +1184,6 @@ REFGL4_OBJS_ := \
|
|||
src/client/refresh/files/maps.o \
|
||||
src/client/refresh/files/models.o \
|
||||
src/client/refresh/files/models_md5.o \
|
||||
src/client/refresh/files/pcx.o \
|
||||
src/client/refresh/files/stb.o \
|
||||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/warp.o \
|
||||
|
@ -1233,7 +1230,6 @@ REFSOFT_OBJS_ := \
|
|||
src/client/refresh/files/maps.o \
|
||||
src/client/refresh/files/models.o \
|
||||
src/client/refresh/files/models_md5.o \
|
||||
src/client/refresh/files/pcx.o \
|
||||
src/client/refresh/files/stb.o \
|
||||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/warp.o \
|
||||
|
@ -1280,7 +1276,6 @@ REFVK_OBJS_ := \
|
|||
src/client/refresh/files/maps.o \
|
||||
src/client/refresh/files/models.o \
|
||||
src/client/refresh/files/models_md5.o \
|
||||
src/client/refresh/files/pcx.o \
|
||||
src/client/refresh/files/stb.o \
|
||||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/warp.o \
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* The PCX file format
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
#include "../ref_shared.h"
|
||||
|
||||
void
|
||||
LoadPCX(const char *origname, byte **pic, byte **palette, int *width, int *height)
|
||||
{
|
||||
char filename[256];
|
||||
int bytesPerPixel;
|
||||
|
||||
FixFileExt(origname, "pcx", filename, sizeof(filename));
|
||||
|
||||
*pic = NULL;
|
||||
|
||||
if (palette)
|
||||
{
|
||||
*palette = NULL;
|
||||
}
|
||||
|
||||
ri.VID_ImageDecode(filename, pic, palette, width, height, &bytesPerPixel);
|
||||
|
||||
if (!(*pic))
|
||||
{
|
||||
R_Printf(PRINT_DEVELOPER, "Bad pcx file %s\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GetPCXInfo(const char *origname, int *width, int *height)
|
||||
{
|
||||
const pcx_t *pcx;
|
||||
byte *raw;
|
||||
char filename[256];
|
||||
|
||||
FixFileExt(origname, "pcx", filename, sizeof(filename));
|
||||
|
||||
ri.FS_LoadFile(filename, (void **)&raw);
|
||||
|
||||
if (!raw)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pcx = (pcx_t *)raw;
|
||||
|
||||
*width = pcx->xmax + 1;
|
||||
*height = pcx->ymax + 1;
|
||||
|
||||
ri.FS_FreeFile(raw);
|
||||
|
||||
return;
|
||||
}
|
|
@ -505,18 +505,18 @@ LoadImage_Ext(const char *name, const char* namewe, const char *ext, imagetype_t
|
|||
int width = 0, height = 0, realwidth = 0, realheight = 0;
|
||||
byte *pic = NULL;
|
||||
byte *palette = NULL;
|
||||
char filename[256];
|
||||
int bytesPerPixel;
|
||||
|
||||
if (!strcmp(ext, "pcx"))
|
||||
{
|
||||
LoadPCX (namewe, &pic, &palette, &width, &height);
|
||||
}
|
||||
else if (!strcmp(ext, "swl"))
|
||||
{
|
||||
LoadSWL (namewe, &pic, &palette, &width, &height);
|
||||
}
|
||||
/* name could not be used here as could have different extension
|
||||
* originaly */
|
||||
FixFileExt(namewe, ext, filename, sizeof(filename));
|
||||
|
||||
ri.VID_ImageDecode(filename, &pic, &palette, &width, &height, &bytesPerPixel);
|
||||
|
||||
if (!pic)
|
||||
{
|
||||
R_Printf(PRINT_DEVELOPER, "Bad %s file %s\n", ext, filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -209,27 +209,6 @@ LoadM8(const char *origname, const char *namewe, imagetype_t type,
|
|||
return image;
|
||||
}
|
||||
|
||||
void
|
||||
LoadSWL(const char *origname, byte **pic, byte **palette, int *width, int *height)
|
||||
{
|
||||
int bytesPerPixel;
|
||||
char name[256];
|
||||
|
||||
FixFileExt(origname, "swl", name, sizeof(name));
|
||||
|
||||
if (palette)
|
||||
{
|
||||
*palette = NULL;
|
||||
}
|
||||
|
||||
ri.VID_ImageDecode(name, pic, palette, width, height, &bytesPerPixel);
|
||||
|
||||
if (!(*pic))
|
||||
{
|
||||
R_Printf(PRINT_DEVELOPER, "Bad swl file %s\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GetWalInfo(const char *origname, int *width, int *height)
|
||||
{
|
||||
|
@ -362,3 +341,29 @@ GetSWLInfo(const char *origname, int *width, int *height)
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
GetPCXInfo(const char *origname, int *width, int *height)
|
||||
{
|
||||
const pcx_t *pcx;
|
||||
byte *raw;
|
||||
char filename[256];
|
||||
|
||||
FixFileExt(origname, "pcx", filename, sizeof(filename));
|
||||
|
||||
ri.FS_LoadFile(filename, (void **)&raw);
|
||||
|
||||
if (!raw)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pcx = (pcx_t *)raw;
|
||||
|
||||
*width = pcx->xmax + 1;
|
||||
*height = pcx->ymax + 1;
|
||||
|
||||
ri.FS_FreeFile(raw);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -100,9 +100,7 @@ extern struct image_s* LoadWal(const char *origname, const char *namewe, imagety
|
|||
loadimage_t load_image);
|
||||
extern struct image_s* LoadM8(const char *origname, const char *namewe, imagetype_t type,
|
||||
loadimage_t load_image);
|
||||
extern void LoadSWL(const char *origname, byte **pic, byte **palette, int *width, int *height);
|
||||
extern void FixFileExt(const char *origname, const char *ext, char *filename, size_t size);
|
||||
extern void LoadPCX(const char *origname, byte **pic, byte **palette, int *width, int *height);
|
||||
extern void GetPCXInfo(const char *origname, int *width, int *height);
|
||||
extern void GetWalInfo(const char *name, int *width, int *height);
|
||||
extern void GetM8Info(const char *name, int *width, int *height);
|
||||
|
|
Loading…
Reference in a new issue