mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-25 22:10:59 +00:00
Work in progress version of the retexterung support. The next step is to alter
r_LoadPic, so that it accepts realwidth and realheight as additional arguments and uses them to manipualte image after uploading it into the vram.
This commit is contained in:
parent
441c988b31
commit
1d8109cbbc
6 changed files with 104 additions and 6 deletions
|
@ -73,14 +73,29 @@ LoadJPG
|
||||||
==============
|
==============
|
||||||
*/
|
*/
|
||||||
image_t *
|
image_t *
|
||||||
LoadJPG (char *filename, int *width, int *height, imagetype_t type)
|
LoadJPG (char *oldname, int *width, int *height, imagetype_t type)
|
||||||
{
|
{
|
||||||
byte *pic = NULL;
|
byte *pic = NULL;
|
||||||
struct jpeg_decompress_struct cinfo;
|
struct jpeg_decompress_struct cinfo;
|
||||||
|
char filename[256];
|
||||||
struct jpeg_error_mgr jerr;
|
struct jpeg_error_mgr jerr;
|
||||||
|
int len;
|
||||||
byte *rawdata, *rgbadata, *scanline, *p, *q;
|
byte *rawdata, *rgbadata, *scanline, *p, *q;
|
||||||
unsigned int rawsize, i;
|
unsigned int rawsize, i;
|
||||||
|
|
||||||
|
len = strlen( oldname );
|
||||||
|
|
||||||
|
if ( strcmp( oldname + len - 4, ".jpg" ) )
|
||||||
|
{
|
||||||
|
strncpy(filename, oldname, 256);
|
||||||
|
strncat(filename, ".jpg", 255);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy(filename, oldname, 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load JPEG file into memory
|
// Load JPEG file into memory
|
||||||
rawsize = ri.FS_LoadFile(filename, (void **)&rawdata);
|
rawsize = ri.FS_LoadFile(filename, (void **)&rawdata);
|
||||||
|
|
||||||
|
|
|
@ -27,14 +27,28 @@
|
||||||
#include "../header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
LoadPCX ( char *filename, byte **pic, byte **palette, int *width, int *height )
|
LoadPCX ( char *oldname, byte **pic, byte **palette, int *width, int *height )
|
||||||
{
|
{
|
||||||
byte *raw;
|
byte *raw;
|
||||||
pcx_t *pcx;
|
pcx_t *pcx;
|
||||||
int x, y;
|
int x, y;
|
||||||
int len;
|
int len;
|
||||||
|
int filelen;
|
||||||
int dataByte, runLength;
|
int dataByte, runLength;
|
||||||
byte *out, *pix;
|
byte *out, *pix;
|
||||||
|
char filename[256];
|
||||||
|
|
||||||
|
filelen = strlen( oldname );
|
||||||
|
|
||||||
|
if ( strcmp( oldname + filelen - 4, ".pcx" ) )
|
||||||
|
{
|
||||||
|
strncpy(filename, oldname, 256);
|
||||||
|
strncat(filename, ".pcx", 255);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy(filename, oldname, 256);
|
||||||
|
}
|
||||||
|
|
||||||
*pic = NULL;
|
*pic = NULL;
|
||||||
*palette = NULL;
|
*palette = NULL;
|
||||||
|
|
|
@ -36,7 +36,7 @@ typedef struct _TargaHeader
|
||||||
} TargaHeader;
|
} TargaHeader;
|
||||||
|
|
||||||
image_t *
|
image_t *
|
||||||
LoadTGA ( char *name, int *width, int *height, imagetype_t type )
|
LoadTGA ( char *oldname, int *width, int *height, imagetype_t type )
|
||||||
{
|
{
|
||||||
byte *pic = NULL;
|
byte *pic = NULL;
|
||||||
int columns, rows, numPixels;
|
int columns, rows, numPixels;
|
||||||
|
@ -45,9 +45,24 @@ LoadTGA ( char *name, int *width, int *height, imagetype_t type )
|
||||||
byte *buf_p;
|
byte *buf_p;
|
||||||
byte *buffer;
|
byte *buffer;
|
||||||
int length;
|
int length;
|
||||||
|
int len;
|
||||||
TargaHeader targa_header;
|
TargaHeader targa_header;
|
||||||
byte *targa_rgba;
|
byte *targa_rgba;
|
||||||
byte tmp [ 2 ];
|
byte tmp [ 2 ];
|
||||||
|
char name[256];
|
||||||
|
|
||||||
|
len = strlen( oldname );
|
||||||
|
|
||||||
|
if ( strcmp( oldname + len - 4, ".tga" ) )
|
||||||
|
{
|
||||||
|
strncpy( name, oldname, 256 );
|
||||||
|
strncat(name, ".tga", 255);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy( name, oldname, 256 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* load the file */
|
/* load the file */
|
||||||
length = ri.FS_LoadFile( name, (void **) &buffer );
|
length = ri.FS_LoadFile( name, (void **) &buffer );
|
||||||
|
@ -100,6 +115,8 @@ LoadTGA ( char *name, int *width, int *height, imagetype_t type )
|
||||||
rows = targa_header.height;
|
rows = targa_header.height;
|
||||||
numPixels = columns * rows;
|
numPixels = columns * rows;
|
||||||
|
|
||||||
|
// FIXME Custommaps
|
||||||
|
|
||||||
if ( width )
|
if ( width )
|
||||||
{
|
{
|
||||||
*width = columns;
|
*width = columns;
|
||||||
|
@ -110,6 +127,7 @@ LoadTGA ( char *name, int *width, int *height, imagetype_t type )
|
||||||
*height = rows;
|
*height = rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
targa_rgba = malloc( numPixels * 4 );
|
targa_rgba = malloc( numPixels * 4 );
|
||||||
pic = targa_rgba;
|
pic = targa_rgba;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,25 @@
|
||||||
#include "../header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
image_t *
|
image_t *
|
||||||
LoadWal ( char *name )
|
LoadWal ( char *oldname )
|
||||||
{
|
{
|
||||||
miptex_t *mt;
|
miptex_t *mt;
|
||||||
int width, height, ofs;
|
int width, height, ofs;
|
||||||
image_t *image;
|
image_t *image;
|
||||||
|
int len;
|
||||||
|
char name[256];
|
||||||
|
|
||||||
|
len = strlen( oldname );
|
||||||
|
|
||||||
|
if ( strcmp( oldname + len - 4, ".wal" ) )
|
||||||
|
{
|
||||||
|
strncpy(name, oldname, 256);
|
||||||
|
strncat(name, ".wal", 255);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy(name, oldname, 256);
|
||||||
|
}
|
||||||
|
|
||||||
ri.FS_LoadFile( name, (void **) &mt );
|
ri.FS_LoadFile( name, (void **) &mt );
|
||||||
|
|
||||||
|
@ -24,5 +38,23 @@ LoadWal ( char *name )
|
||||||
ri.FS_FreeFile( (void *) mt );
|
ri.FS_FreeFile( (void *) mt );
|
||||||
|
|
||||||
return ( image );
|
return ( image );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qboolean GetWalInfo (char *name, int *width, int *height)
|
||||||
|
{
|
||||||
|
miptex_t *mt;
|
||||||
|
|
||||||
|
ri.FS_LoadFile (name, (void **)&mt);
|
||||||
|
|
||||||
|
if (!mt)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*width = LittleLong (mt->width);
|
||||||
|
*height = LittleLong (mt->height);
|
||||||
|
|
||||||
|
ri.FS_FreeFile ((void *)mt);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -313,6 +313,7 @@ void R_ResampleTexture ( unsigned *in, int inwidth, int inheight, unsigned *out,
|
||||||
struct image_s *R_RegisterSkin ( char *name );
|
struct image_s *R_RegisterSkin ( char *name );
|
||||||
|
|
||||||
void LoadPCX ( char *filename, byte **pic, byte **palette, int *width, int *height );
|
void LoadPCX ( char *filename, byte **pic, byte **palette, 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 height, imagetype_t type, int bits );
|
||||||
image_t *R_FindImage ( char *name, imagetype_t type );
|
image_t *R_FindImage ( char *name, imagetype_t type );
|
||||||
void R_TextureMode ( char *string );
|
void R_TextureMode ( char *string );
|
||||||
|
|
|
@ -1018,13 +1018,17 @@ R_FindImage ( char *name, imagetype_t type )
|
||||||
int i, len;
|
int i, len;
|
||||||
byte *pic, *palette;
|
byte *pic, *palette;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
int realwidth, realheight;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
char namewe[256];
|
||||||
|
|
||||||
if ( !name )
|
if ( !name )
|
||||||
{
|
{
|
||||||
return ( NULL );
|
return ( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(namewe, 0, 256);
|
||||||
|
|
||||||
len = strlen( name );
|
len = strlen( name );
|
||||||
|
|
||||||
if ( len < 5 )
|
if ( len < 5 )
|
||||||
|
@ -1065,7 +1069,21 @@ R_FindImage ( char *name, imagetype_t type )
|
||||||
}
|
}
|
||||||
else if ( !strcmp( name + len - 4, ".wal" ) )
|
else if ( !strcmp( name + len - 4, ".wal" ) )
|
||||||
{
|
{
|
||||||
image = LoadWal( name );
|
/* Remove the extension */
|
||||||
|
memcpy(namewe, name, len - 4);
|
||||||
|
|
||||||
|
GetWalInfo(name, &realwidth, &realheight);
|
||||||
|
image = LoadTGA( namewe, &width, &height, type );
|
||||||
|
|
||||||
|
if( image == NULL )
|
||||||
|
{
|
||||||
|
image = LoadJPG( namewe, &width, &height, type );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( image == NULL)
|
||||||
|
{
|
||||||
|
image = LoadWal( namewe );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( !strcmp( name + len - 4, ".tga" ) )
|
else if ( !strcmp( name + len - 4, ".tga" ) )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue