mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2024-11-22 11:51:17 +00:00
I think this works, but maybe not.. skins will be very broken if I didn't
but I'll undo this mess if that happens.
This commit is contained in:
parent
76c3e731c1
commit
75001e947c
6 changed files with 43 additions and 68 deletions
|
@ -42,6 +42,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include <cmd.h>
|
#include <cmd.h>
|
||||||
#include <cvar.h>
|
#include <cvar.h>
|
||||||
#include <qstructs.h>
|
#include <qstructs.h>
|
||||||
|
#include <image.h>
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -594,24 +595,6 @@ void CL_InitCam(void);
|
||||||
// skin.c
|
// skin.c
|
||||||
//
|
//
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
char manufacturer;
|
|
||||||
char version;
|
|
||||||
char encoding;
|
|
||||||
char bits_per_pixel;
|
|
||||||
unsigned short xmin,ymin,xmax,ymax;
|
|
||||||
unsigned short hres,vres;
|
|
||||||
unsigned char palette[48];
|
|
||||||
char reserved;
|
|
||||||
char color_planes;
|
|
||||||
unsigned short bytes_per_line;
|
|
||||||
unsigned short palette_type;
|
|
||||||
char filler[58];
|
|
||||||
unsigned char data; // unbounded
|
|
||||||
} pcx_t;
|
|
||||||
|
|
||||||
|
|
||||||
void Skin_Find (player_info_t *sc);
|
void Skin_Find (player_info_t *sc);
|
||||||
byte *Skin_Cache (skin_t *skin);
|
byte *Skin_Cache (skin_t *skin);
|
||||||
void Skin_Skins_f (void);
|
void Skin_Skins_f (void);
|
||||||
|
|
|
@ -296,17 +296,6 @@ EmitBothSkyLayers ( msurface_t *fa ) {
|
||||||
glDisable (GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
R_DrawSkyChain
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
R_DrawSkyChain ( msurface_t *s ) {
|
|
||||||
|
|
||||||
msurface_t *fa;
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Quake 2 sky rendering ("skyboxes")
|
Quake 2 sky rendering ("skyboxes")
|
||||||
|
@ -314,24 +303,20 @@ R_DrawSkyChain ( msurface_t *s ) {
|
||||||
|
|
||||||
#define SKY_TEX 2000
|
#define SKY_TEX 2000
|
||||||
|
|
||||||
/*
|
#if 0
|
||||||
PCX Loading
|
|
||||||
*/
|
|
||||||
|
|
||||||
byte *pcx_rgb;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
LoadPCX
|
LoadPCX
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
LoadPCX (QFile *f) {
|
LoadPCX (QFile *f, byte **pcx_rgb)
|
||||||
|
{
|
||||||
|
|
||||||
pcx_t *pcx, pcxbuf;
|
pcx_t *pcx, pcxbuf;
|
||||||
byte palette[768];
|
byte palette[768];
|
||||||
byte *pix;
|
byte *pix;
|
||||||
int x, y;
|
int x, y;
|
||||||
int dataByte, runLength;
|
int dataByte, runLength;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Parse PCX file
|
Parse PCX file
|
||||||
|
@ -354,10 +339,10 @@ LoadPCX (QFile *f) {
|
||||||
Qseek (f, sizeof(pcxbuf) - 4, SEEK_SET);
|
Qseek (f, sizeof(pcxbuf) - 4, SEEK_SET);
|
||||||
|
|
||||||
count = (pcx->xmax+1) * (pcx->ymax+1);
|
count = (pcx->xmax+1) * (pcx->ymax+1);
|
||||||
pcx_rgb = malloc( count * 4);
|
*pcx_rgb = malloc( count * 4);
|
||||||
|
|
||||||
for (y=0 ; y<=pcx->ymax ; y++) {
|
for (y=0 ; y<=pcx->ymax ; y++) {
|
||||||
pix = pcx_rgb + 4*y*(pcx->xmax+1);
|
pix = *pcx_rgb + 4*y*(pcx->xmax+1);
|
||||||
for (x=0 ; x<=pcx->ymax ; ) {
|
for (x=0 ; x<=pcx->ymax ; ) {
|
||||||
dataByte = Qgetc(f);
|
dataByte = Qgetc(f);
|
||||||
|
|
||||||
|
@ -379,6 +364,7 @@ LoadPCX (QFile *f) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TARGA LOADING
|
TARGA LOADING
|
||||||
|
@ -392,8 +378,6 @@ typedef struct _TargaHeader {
|
||||||
unsigned char pixel_size, attributes;
|
unsigned char pixel_size, attributes;
|
||||||
} TargaHeader;
|
} TargaHeader;
|
||||||
|
|
||||||
TargaHeader targa_header;
|
|
||||||
byte *targa_rgba;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
QgetLittleShort ( QFile *f ) {
|
QgetLittleShort ( QFile *f ) {
|
||||||
|
@ -423,11 +407,12 @@ QgetLittleLong (QFile *f) {
|
||||||
LoadTGA
|
LoadTGA
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
LoadTGA (QFile *fin) {
|
LoadTGA (QFile *fin, byte **targa_rgba) {
|
||||||
|
|
||||||
int columns, rows, numPixels;
|
int columns, rows, numPixels;
|
||||||
byte *pixbuf;
|
byte *pixbuf;
|
||||||
int row, column;
|
int row, column;
|
||||||
|
TargaHeader targa_header;
|
||||||
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
|
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
|
||||||
|
|
||||||
targa_header.id_length = Qgetc(fin);
|
targa_header.id_length = Qgetc(fin);
|
||||||
|
@ -456,14 +441,14 @@ LoadTGA (QFile *fin) {
|
||||||
rows = targa_header.height;
|
rows = targa_header.height;
|
||||||
numPixels = columns * rows;
|
numPixels = columns * rows;
|
||||||
|
|
||||||
targa_rgba = malloc (numPixels*4);
|
*targa_rgba = malloc (numPixels*4);
|
||||||
|
|
||||||
if (targa_header.id_length != 0)
|
if (targa_header.id_length != 0)
|
||||||
Qseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
|
Qseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
|
||||||
|
|
||||||
if (targa_header.image_type==2) { // Uncompressed, RGB images
|
if (targa_header.image_type==2) { // Uncompressed, RGB images
|
||||||
for(row=rows-1; row>=0; row--) {
|
for(row=rows-1; row>=0; row--) {
|
||||||
pixbuf = targa_rgba + row*columns*4;
|
pixbuf = *targa_rgba + row*columns*4;
|
||||||
for(column=0; column<columns; column++) {
|
for(column=0; column<columns; column++) {
|
||||||
switch (targa_header.pixel_size) {
|
switch (targa_header.pixel_size) {
|
||||||
case 24:
|
case 24:
|
||||||
|
@ -493,7 +478,7 @@ LoadTGA (QFile *fin) {
|
||||||
else if (targa_header.image_type==10) { // Runlength encoded RGB images
|
else if (targa_header.image_type==10) { // Runlength encoded RGB images
|
||||||
unsigned char packetHeader,packetSize,j;
|
unsigned char packetHeader,packetSize,j;
|
||||||
for(row=rows-1; row>=0; row--) {
|
for(row=rows-1; row>=0; row--) {
|
||||||
pixbuf = targa_rgba + row*columns*4;
|
pixbuf = *targa_rgba + row*columns*4;
|
||||||
for(column=0; column<columns; ) {
|
for(column=0; column<columns; ) {
|
||||||
packetHeader=Qgetc(fin);
|
packetHeader=Qgetc(fin);
|
||||||
packetSize = 1 + (packetHeader & 0x7f);
|
packetSize = 1 + (packetHeader & 0x7f);
|
||||||
|
@ -525,7 +510,7 @@ LoadTGA (QFile *fin) {
|
||||||
row--;
|
row--;
|
||||||
else
|
else
|
||||||
goto breakOut;
|
goto breakOut;
|
||||||
pixbuf = targa_rgba + row*columns*4;
|
pixbuf = *targa_rgba + row*columns*4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -559,7 +544,7 @@ LoadTGA (QFile *fin) {
|
||||||
row--;
|
row--;
|
||||||
else
|
else
|
||||||
goto breakOut;
|
goto breakOut;
|
||||||
pixbuf = targa_rgba + row*columns*4;
|
pixbuf = *targa_rgba + row*columns*4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,6 +566,7 @@ R_LoadSkys ( void ) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
QFile *f;
|
QFile *f;
|
||||||
|
byte *skyimage = NULL;
|
||||||
char name[64];
|
char name[64];
|
||||||
|
|
||||||
for (i=0 ; i<6 ; i++) {
|
for (i=0 ; i<6 ; i++) {
|
||||||
|
@ -592,14 +578,14 @@ R_LoadSkys ( void ) {
|
||||||
Con_Printf ("Couldn't load %s\n", name);
|
Con_Printf ("Couldn't load %s\n", name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LoadTGA (f);
|
LoadTGA (f, &skyimage);
|
||||||
// LoadPCX (f);
|
// LoadPCX (f, &skyimage);
|
||||||
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, targa_rgba);
|
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, skyimage);
|
||||||
// glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, pcx_rgb);
|
// glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, pcx_rgb);
|
||||||
|
|
||||||
free (targa_rgba);
|
// free (targa_rgba);
|
||||||
// free (pcx_rgb);
|
free (skyimage);
|
||||||
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
|
@ -298,7 +298,7 @@ QFile *COM_OpenRead(const char *path, int offs, int len)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===========
|
===========
|
||||||
COM_FindFile
|
COM_FOpenFile
|
||||||
|
|
||||||
Finds the file in the search path.
|
Finds the file in the search path.
|
||||||
Sets com_filesize and one of handle or file
|
Sets com_filesize and one of handle or file
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/*
|
||||||
|
skin.c - player skins
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
||||||
Portions Copyright (C) 1999,2000 Nelson Rush.
|
Portions Copyright (C) 1999,2000 Nelson Rush.
|
||||||
|
@ -104,12 +105,13 @@ Returns a pointer to the skin bitmap, or NULL to use the default
|
||||||
byte *Skin_Cache (skin_t *skin)
|
byte *Skin_Cache (skin_t *skin)
|
||||||
{
|
{
|
||||||
char name[1024];
|
char name[1024];
|
||||||
byte *raw;
|
// byte *raw;
|
||||||
byte *out, *pix;
|
byte *out;//, *pix;
|
||||||
pcx_t *pcx;
|
// pcx_t *pcx;
|
||||||
int x, y;
|
// int x, y;
|
||||||
int dataByte;
|
// int dataByte;
|
||||||
int runLength;
|
// int runLength;
|
||||||
|
QFile *f;
|
||||||
|
|
||||||
if (cls.downloadtype == dl_skin)
|
if (cls.downloadtype == dl_skin)
|
||||||
return NULL; // use base until downloaded
|
return NULL; // use base until downloaded
|
||||||
|
@ -128,19 +130,23 @@ byte *Skin_Cache (skin_t *skin)
|
||||||
// load the pic from disk
|
// load the pic from disk
|
||||||
//
|
//
|
||||||
snprintf(name, sizeof(name), "skins/%s.pcx", skin->name);
|
snprintf(name, sizeof(name), "skins/%s.pcx", skin->name);
|
||||||
raw = COM_LoadTempFile (name);
|
// raw = COM_LoadTempFile (name);
|
||||||
if (!raw)
|
COM_FOpenFile (name, &f);
|
||||||
|
if (f == NULL)
|
||||||
{
|
{
|
||||||
Con_Printf ("Couldn't load skin %s\n", name);
|
Con_Printf ("Couldn't load skin %s\n", name);
|
||||||
snprintf(name, sizeof(name), "skins/%s.pcx", baseskin->string);
|
snprintf(name, sizeof(name), "skins/%s.pcx", baseskin->string);
|
||||||
raw = COM_LoadTempFile (name);
|
// raw = COM_LoadTempFile (name);
|
||||||
if (!raw)
|
COM_FOpenFile (name, &f);
|
||||||
|
if (f == NULL)
|
||||||
{
|
{
|
||||||
skin->failedload = true;
|
skin->failedload = true;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoadPCX (f, &out);
|
||||||
|
#if 0
|
||||||
//
|
//
|
||||||
// parse the PCX file
|
// parse the PCX file
|
||||||
//
|
//
|
||||||
|
@ -216,7 +222,7 @@ byte *Skin_Cache (skin_t *skin)
|
||||||
}
|
}
|
||||||
|
|
||||||
skin->failedload = false;
|
skin->failedload = false;
|
||||||
|
#endif
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ CFLAGS += @CFLAGS@ -DQUAKEWORLD -DLIBDIR=\"$(libdir)\" $(OPTFLAGS) $(DEFS) \
|
||||||
-I. $(SRC_DIR_INC) -I$(QW_COMMON_DIR) -I$(COMMON_ODIR) -I$(COMMON_DIR)
|
-I. $(SRC_DIR_INC) -I$(QW_COMMON_DIR) -I$(COMMON_ODIR) -I$(COMMON_DIR)
|
||||||
|
|
||||||
GENERAL_SRC = $(CL_COMMON_SRC) \
|
GENERAL_SRC = $(CL_COMMON_SRC) \
|
||||||
$(QW_CL_SRC) $(QW_NET_SRC) net_chan.c skin.c \
|
$(QW_CL_SRC) $(QW_NET_SRC) net_chan.c skin.c pcx.c\
|
||||||
$(SYS_SRC) $(QW_GENERAL_SRC)
|
$(SYS_SRC) $(QW_GENERAL_SRC)
|
||||||
|
|
||||||
# FIXME: add dos/win specifc source
|
# FIXME: add dos/win specifc source
|
||||||
|
|
|
@ -159,7 +159,7 @@ UQ_NET_SRC = net_com.c mdfour.c net_dgrm.c net_loop.c net_main.c net_vcr.c $(NET
|
||||||
|
|
||||||
MISC_SRC = common.c crc.c cvar.c cmd.c mathlib.c register_check.c \
|
MISC_SRC = common.c crc.c cvar.c cmd.c mathlib.c register_check.c \
|
||||||
wad.c zone.c cvars.c lib_replace.c qendian.c quakefs.c \
|
wad.c zone.c cvars.c lib_replace.c qendian.c quakefs.c \
|
||||||
quakeio.c qargs.c plugin.c
|
quakeio.c qargs.c plugin.c pcx.c
|
||||||
ifeq ($(GENERATIONS),yes)
|
ifeq ($(GENERATIONS),yes)
|
||||||
MISC_SRC += unzip.c
|
MISC_SRC += unzip.c
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in a new issue