Merge pull request #635 from 0lvin/ref_soft

Port improvements to soft and vulkan
This commit is contained in:
Yamagi 2020-12-31 10:27:03 +01:00 committed by GitHub
commit faf6a91ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 1318 additions and 401 deletions

View File

@ -57,3 +57,30 @@ GetWalInfo(char *name, int *width, int *height)
return;
}
void
GetM8Info(char *name, int *width, int *height)
{
m8tex_t *mt;
int size;
size = ri.FS_LoadFile(name, (void **)&mt);
if (!mt)
{
return;
}
if (size < sizeof(m8tex_t) || LittleLong (mt->version) != M8_VERSION)
{
ri.FS_FreeFile((void *)mt);
return;
}
*width = LittleLong(mt->width[0]);
*height = LittleLong(mt->height[0]);
ri.FS_FreeFile((void *)mt);
return;
}

View File

@ -1024,6 +1024,75 @@ LoadWal(char *origname, imagetype_t type)
return image;
}
static image_t *
LoadM8(char *origname, imagetype_t type)
{
m8tex_t *mt;
int width, height, ofs, size;
image_t *image;
char name[256];
unsigned char *image_buffer = NULL;
Q_strlcpy(name, origname, sizeof(name));
/* Add the extension */
if (strcmp(COM_FileExtension(name), "m8"))
{
Q_strlcat(name, ".m8", sizeof(name));
}
size = ri.FS_LoadFile(name, (void **)&mt);
if (!mt)
{
R_Printf(PRINT_ALL, "%s: can't load %s\n", __func__, name);
return r_notexture;
}
if (size < sizeof(m8tex_t))
{
R_Printf(PRINT_ALL, "%s: can't load %s, small header\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return r_notexture;
}
if (LittleLong (mt->version) != M8_VERSION)
{
R_Printf(PRINT_ALL, "%s: can't load %s, wrong magic value.\n", __func__, name);
ri.FS_FreeFile ((void *)mt);
return r_notexture;
}
width = LittleLong(mt->width[0]);
height = LittleLong(mt->height[0]);
ofs = LittleLong(mt->offsets[0]);
if ((ofs <= 0) || (width <= 0) || (height <= 0) ||
(((size - ofs) / height) < width))
{
R_Printf(PRINT_ALL, "%s: can't load %s, small body\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return r_notexture;
}
image_buffer = malloc (width * height * 4);
for(int i=0; i<width * height; i++)
{
unsigned char value = *((byte *)mt + ofs + i);
image_buffer[i * 4 + 0] = mt->palette[value].r;
image_buffer[i * 4 + 1] = mt->palette[value].g;
image_buffer[i * 4 + 2] = mt->palette[value].b;
image_buffer[i * 4 + 3] = value == 255 ? 0 : 255;
}
image = R_LoadPic(name, image_buffer, width, 0, height, 0, type, 32);
free(image_buffer);
ri.FS_FreeFile((void *)mt);
return image;
}
/*
* Finds or loads the given image
*/
@ -1128,12 +1197,20 @@ R_FindImage(char *name, imagetype_t type)
image = R_LoadPic(name, pic, width, 0, height, 0, type, 8);
}
}
else if (strcmp(ext, "wal") == 0)
else if (strcmp(ext, "wal") == 0 || strcmp(ext, "m8") == 0)
{
if (gl_retexturing->value)
{
/* Get size of the original texture */
GetWalInfo(name, &realwidth, &realheight);
if (strcmp(ext, "m8") == 0)
{
GetM8Info(name, &realwidth, &realheight);
}
else
{
GetWalInfo(name, &realwidth, &realheight);
}
if(realwidth == 0)
{
/* No texture found */
@ -1149,6 +1226,10 @@ R_FindImage(char *name, imagetype_t type)
image = R_LoadPic(name, pic, width, realwidth, height,
realheight, type, 32);
}
else if (strcmp(ext, "m8") == 0)
{
image = LoadM8(namewe, type);
}
else
{
/* WAL if no TGA/PNG/JPEG available (exists always) */
@ -1161,6 +1242,16 @@ R_FindImage(char *name, imagetype_t type)
return NULL;
}
}
else if (strcmp(ext, "m8") == 0)
{
image = LoadM8(name, type);
if (!image)
{
/* No texture found */
return NULL;
}
}
else /* gl_retexture is not set */
{
image = LoadWal(name, type);
@ -1183,6 +1274,12 @@ R_FindImage(char *name, imagetype_t type)
strcat(tmp_name, ".wal");
GetWalInfo(tmp_name, &realwidth, &realheight);
if (realwidth == 0 || realheight == 0) {
strcpy(tmp_name, namewe);
strcat(tmp_name, ".m8");
GetM8Info(tmp_name, &realwidth, &realheight);
}
if (realwidth == 0 || realheight == 0) {
/* It's a sky or model skin. */
strcpy(tmp_name, namewe);
@ -1199,6 +1296,10 @@ R_FindImage(char *name, imagetype_t type)
{
image = R_LoadPic(name, pic, width, realwidth, height, realheight, type, 32);
}
else
{
return NULL;
}
}
else
{

View File

@ -71,15 +71,6 @@ static byte notex[4][4] = {
{0, 1, 1, 1}
};
typedef struct _TargaHeader
{
unsigned char id_length, colormap_type, image_type;
unsigned short colormap_index, colormap_length;
unsigned char colormap_size;
unsigned short x_origin, y_origin, width, height;
unsigned char pixel_size, attributes;
} TargaHeader;
void
R_InitParticleTexture(void)
{

View File

@ -414,6 +414,12 @@ Mod_LoadTexinfo(lump_t *l)
out->image = R_FindImage(name, it_wall);
if (!out->image || out->image == r_notexture)
{
Com_sprintf(name, sizeof(name), "textures/%s.m8", in->texture);
out->image = R_FindImage(name, it_wall);
}
if (!out->image)
{
R_Printf(PRINT_ALL, "Couldn't load %s\n", name);

View File

@ -26,10 +26,8 @@
#include "header/local.h"
extern int modfilelen;
void
LoadSP2(model_t *mod, void *buffer)
LoadSP2(model_t *mod, void *buffer, int modfilelen)
{
dsprite_t *sprin, *sprout;
int i;

View File

@ -748,6 +748,13 @@ RI_SetSky(char *name, float rotate, vec3_t axis)
sky_images[i] = R_FindImage(pathname, it_sky);
if (!sky_images[i] || sky_images[i] == r_notexture)
{
Com_sprintf(pathname, sizeof(pathname), "pics/Skies/%s%s.m8",
skyname, suf[i]);
sky_images[i] = R_FindImage(pathname, it_sky);
}
if (!sky_images[i])
{
sky_images[i] = r_notexture;

View File

@ -608,6 +608,75 @@ LoadWal(char *origname, imagetype_t type)
return image;
}
static gl3image_t *
LoadM8(char *origname, imagetype_t type)
{
m8tex_t *mt;
int width, height, ofs, size;
gl3image_t *image;
char name[256];
unsigned char *image_buffer = NULL;
Q_strlcpy(name, origname, sizeof(name));
/* Add the extension */
if (strcmp(COM_FileExtension(name), "m8"))
{
Q_strlcat(name, ".m8", sizeof(name));
}
size = ri.FS_LoadFile(name, (void **)&mt);
if (!mt)
{
R_Printf(PRINT_ALL, "%s: can't load %s\n", __func__, name);
return gl3_notexture;
}
if (size < sizeof(m8tex_t))
{
R_Printf(PRINT_ALL, "%s: can't load %s, small header\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return gl3_notexture;
}
if (LittleLong (mt->version) != M8_VERSION)
{
R_Printf(PRINT_ALL, "LoadWal: can't load %s, wrong magic value.\n", name);
ri.FS_FreeFile ((void *)mt);
return gl3_notexture;
}
width = LittleLong(mt->width[0]);
height = LittleLong(mt->height[0]);
ofs = LittleLong(mt->offsets[0]);
if ((ofs <= 0) || (width <= 0) || (height <= 0) ||
(((size - ofs) / height) < width))
{
R_Printf(PRINT_ALL, "%s: can't load %s, small body\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return gl3_notexture;
}
image_buffer = malloc (width * height * 4);
for(int i=0; i<width * height; i++)
{
unsigned char value = *((byte *)mt + ofs + i);
image_buffer[i * 4 + 0] = mt->palette[value].r;
image_buffer[i * 4 + 1] = mt->palette[value].g;
image_buffer[i * 4 + 2] = mt->palette[value].b;
image_buffer[i * 4 + 3] = value == 255 ? 0 : 255;
}
image = GL3_LoadPic(name, image_buffer, width, 0, height, 0, type, 32);
free(image_buffer);
ri.FS_FreeFile((void *)mt);
return image;
}
/*
* Finds or loads the given image
*/
@ -712,12 +781,20 @@ GL3_FindImage(char *name, imagetype_t type)
image = GL3_LoadPic(name, pic, width, 0, height, 0, type, 8);
}
}
else if (strcmp(ext, "wal") == 0)
else if (strcmp(ext, "wal") == 0 || strcmp(ext, "m8") == 0)
{
if (gl_retexturing->value)
{
/* Get size of the original texture */
GetWalInfo(name, &realwidth, &realheight);
if (strcmp(ext, "m8") == 0)
{
GetM8Info(name, &realwidth, &realheight);
}
else
{
GetWalInfo(name, &realwidth, &realheight);
}
if(realwidth == 0)
{
/* No texture found */
@ -732,6 +809,10 @@ GL3_FindImage(char *name, imagetype_t type)
/* upload tga or png or jpg */
image = GL3_LoadPic(name, pic, width, realwidth, height, realheight, type, 32);
}
else if (strcmp(ext, "m8") == 0)
{
image = LoadM8(namewe, type);
}
else
{
/* WAL if no TGA/PNG/JPEG available (exists always) */
@ -744,6 +825,16 @@ GL3_FindImage(char *name, imagetype_t type)
return NULL;
}
}
else if (strcmp(ext, "m8") == 0)
{
image = LoadM8(name, type);
if (!image)
{
/* No texture found */
return NULL;
}
}
else /* gl_retexture is not set */
{
image = LoadWal(name, type);
@ -766,6 +857,12 @@ GL3_FindImage(char *name, imagetype_t type)
strcat(tmp_name, ".wal");
GetWalInfo(tmp_name, &realwidth, &realheight);
if (realwidth == 0 || realheight == 0) {
strcpy(tmp_name, namewe);
strcat(tmp_name, ".m8");
GetM8Info(tmp_name, &realwidth, &realheight);
}
if (realwidth == 0 || realheight == 0) {
/* It's a sky or model skin. */
strcpy(tmp_name, namewe);
@ -781,6 +878,8 @@ GL3_FindImage(char *name, imagetype_t type)
if(LoadSTB(name, ext, &pic, &width, &height))
{
image = GL3_LoadPic(name, pic, width, realwidth, height, realheight, type, 32);
} else {
return NULL;
}
}
else

View File

@ -297,6 +297,12 @@ Mod_LoadTexinfo(lump_t *l)
out->image = GL3_FindImage(name, it_wall);
if (!out->image || out->image == gl3_notexture)
{
Com_sprintf(name, sizeof(name), "textures/%s.m8", in->texture);
out->image = GL3_FindImage(name, it_wall);
}
if (!out->image)
{
R_Printf(PRINT_ALL, "Couldn't load %s\n", name);

View File

@ -329,6 +329,13 @@ GL3_SetSky(char *name, float rotate, vec3_t axis)
sky_images[i] = GL3_FindImage(pathname, it_sky);
if (sky_images[i] == NULL || sky_images[i] == gl3_notexture)
{
Com_sprintf(pathname, sizeof(pathname), "pics/Skies/%s%s.m8", skyname, suf[i]);
sky_images[i] = GL3_FindImage(pathname, it_sky);
}
if (sky_images[i] == NULL)
{
sky_images[i] = gl3_notexture;

View File

@ -187,8 +187,6 @@ typedef struct
int prev_mode;
unsigned char *d_16to8table;
// each lightmap consists of 4 sub-lightmaps allowing changing shadows on the same surface
// used for switching on/off light and stuff like that.
// most surfaces only have one really and the remaining for are filled with dummy data

View File

@ -71,6 +71,7 @@ extern void scale2x(byte *src, byte *dst, int width, int height);
extern void scale3x(byte *src, byte *dst, int width, int height);
extern void GetWalInfo(char *name, int *width, int *height);
extern void GetM8Info(char *name, int *width, int *height);
extern float Mod_RadiusFromBounds(const vec3_t mins, const vec3_t maxs);
extern byte* Mod_DecompressVis(byte *in, int row);

View File

@ -161,8 +161,6 @@ extern oldrefdef_t r_refdef;
#define ALIAS_Z_CLIP 0x0010
#define ALIAS_XY_CLIP_MASK 0x000F
#define SURFCACHE_SIZE_AT_320X240 1024*768
#define BMODEL_FULLY_CLIPPED 0x10 // value returned by R_BmodelCheckBBox ()
// if bbox is trivially rejected
@ -420,10 +418,12 @@ extern cvar_t *sw_stipplealpha;
extern cvar_t *sw_surfcacheoverride;
extern cvar_t *sw_waterwarp;
extern cvar_t *sw_gunzposition;
extern cvar_t *sw_retexturing;
extern cvar_t *r_fullbright;
extern cvar_t *r_lefthand;
extern cvar_t *r_gunfov;
extern cvar_t *r_farsee;
extern cvar_t *r_drawworld;
extern cvar_t *r_lerpmodels;
extern cvar_t *r_lightlevel;

View File

@ -89,7 +89,7 @@ RE_Draw_CharScaled(int x, int y, int c, float scale)
c &= 255;
if (c == 32 || c == 32+128)
if ((c&127) == 32)
return;
if (y <= -8)
@ -208,17 +208,49 @@ RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic
}
else
{
int v;
int v, pic_height, pic_width;
byte *pic_pixels, *image_scaled;
pic_height = pic->height;
pic_width = pic->width;
pic_pixels = pic->pixels[0];
if (sw_retexturing->value)
{
if (pic_width < (vid.width / 3) || pic_height < (vid.height / 3))
{
image_scaled = malloc(pic_width * pic_height * 9);
scale3x(pic_pixels, image_scaled, pic_width, pic_height);
pic_width = pic_width * 3;
pic_height = pic_height * 3;
}
else
{
image_scaled = malloc(pic_width * pic_height * 4);
scale2x(pic_pixels, image_scaled, pic_width, pic_height);
pic_width = pic_width * 2;
pic_height = pic_height * 2;
}
}
else
{
image_scaled = pic_pixels;
}
// size of screen tile to pic pixel
int picupscale = h / pic->height;
int picupscale = h / pic_height;
for (v=0 ; v<height ; v++, dest += vid.width)
{
int f, fstep, u;
int sv = (skip + v)*pic->height/h;
source = pic->pixels[0] + sv*pic->width;
int sv = (skip + v)*pic_height/h;
source = image_scaled + sv*pic_width;
f = 0;
fstep = (pic->width << SHIFT16XYZ) / w;
fstep = (pic_width << SHIFT16XYZ) / w;
for (u=0 ; u<w ; u++)
{
dest[u] = source[f>>16];
@ -240,6 +272,11 @@ RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic
v += (picupscale - 1);
}
}
if (sw_retexturing->value)
{
free(image_scaled);
}
}
}

View File

@ -20,8 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "header/local.h"
extern cvar_t *sw_retexturing;
#define MAX_RIMAGES 1024
static image_t r_images[MAX_RIMAGES];
static int numr_images;
@ -111,8 +109,8 @@ R_ImageShrink(const unsigned char* src, unsigned char *dst, int width, int realw
int x, y;
float xstep, ystep;
xstep = (float)height / realheight;
ystep = (float)width / realwidth;
xstep = (float)width / realwidth;
ystep = (float)height / realheight;
for (y=0; y<realheight; y++)
{
@ -129,11 +127,11 @@ R_RestoreMips(image_t *image, int min_mips)
{
int i;
for (i=min_mips+1; i<NUM_MIPS; i++)
for (i=min_mips; i<(NUM_MIPS-1); i++)
{
R_ImageShrink(image->pixels[i-1], image->pixels[i],
image->height / (1 << (i - 1)), image->height / (1 << i),
image->width / (1 << (i - 1)), image->width / (1 << i));
R_ImageShrink(image->pixels[i], image->pixels[i + 1],
image->width >> i, image->width >> (i + 1),
image->height >> i, image->height >> (i + 1));
}
}
@ -155,10 +153,10 @@ R_RestoreImagePointers(image_t *image, int min_mips)
{
int i;
for (i=min_mips+1; i<NUM_MIPS; i++)
for (i=min_mips; i<NUM_MIPS-1; i++)
{
image->pixels[i] = image->pixels[i - 1] + (
image->width * image->height / (1 << ((i - 1) * 2)));
image->pixels[i + 1] = image->pixels[i] + (
image->width * image->height / (1 << (i * 2)));
}
}
@ -230,13 +228,13 @@ R_LoadWal (char *name, imagetype_t type)
file_size = ri.FS_LoadFile (name, (void **)&mt);
if (!mt)
{
R_Printf(PRINT_ALL, "R_LoadWal: can't load %s\n", name);
R_Printf(PRINT_ALL, "%s: can't load %s\n", __func__, name);
return r_notexture_mip;
}
if (file_size < sizeof(miptex_t))
{
R_Printf(PRINT_ALL, "R_LoadWal: can't load %s, small header\n", name);
R_Printf(PRINT_ALL, "%s: can't load %s, small header\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return r_notexture_mip;
}
@ -253,7 +251,7 @@ R_LoadWal (char *name, imagetype_t type)
if ((ofs <= 0) || (image->width <= 0) || (image->height <= 0) ||
((file_size - ofs) / image->width < image->height))
{
R_Printf(PRINT_ALL, "LoadWal: can't load %s, small body\n", name);
R_Printf(PRINT_ALL, "%s: can't load %s, small body\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return r_notexture_mip;
}
@ -301,6 +299,119 @@ R_Convert32To8bit(unsigned char* pic_in, unsigned char* pic_out, size_t size)
}
}
static void
R_FixPalette(unsigned char* pixels, size_t size, rgb_t* pallette)
{
unsigned char* convert = malloc(256);
size_t i;
if (!d_16to8table)
{
free(convert);
return;
}
for(i=0; i < 256; i ++)
{
unsigned int r, g, b, c;
r = ( pallette[i].r >> 3 ) & 31;
g = ( pallette[i].g >> 2 ) & 63;
b = ( pallette[i].b >> 3 ) & 31;
c = r | ( g << 5 ) | ( b << 11 );
convert[i] = d_16to8table[c & 0xFFFF];
}
for(i=0; i < size; i++)
{
pixels[i] = convert[pixels[i]];
}
free(convert);
}
/*
================
R_LoadM8
================
*/
static image_t *
R_LoadM8 (char *name, imagetype_t type)
{
m8tex_t *mt;
int ofs, file_size;
image_t *image;
int size;
file_size = ri.FS_LoadFile (name, (void **)&mt);
if (!mt)
{
R_Printf(PRINT_ALL, "%s: can't load %s\n", __func__, name);
return r_notexture_mip;
}
if (file_size < sizeof(m8tex_t))
{
R_Printf(PRINT_ALL, "%s: can't load %s, small header\n", __func__, name);
ri.FS_FreeFile ((void *)mt);
return r_notexture_mip;
}
if (LittleLong (mt->version) != M8_VERSION)
{
R_Printf(PRINT_ALL, "%s: can't load %s, wrong magic value.\n", __func__, name);
ri.FS_FreeFile ((void *)mt);
return r_notexture_mip;
}
image = R_FindFreeImage ();
strcpy (image->name, name);
image->width = LittleLong (mt->width[0]);
image->height = LittleLong (mt->height[0]);
image->type = type;
image->registration_sequence = registration_sequence;
ofs = LittleLong (mt->offsets[0]);
size = image->width * image->height * (256+64+16+4)/256;
if ((ofs <= 0) || (image->width <= 0) || (image->height <= 0) ||
((file_size - ofs) / image->width < image->height))
{
R_Printf(PRINT_ALL, "%s: can't load %s, small body\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return r_notexture_mip;
}
image->pixels[0] = malloc (size);
image->pixels[1] = image->pixels[0] + image->width*image->height;
image->pixels[2] = image->pixels[1] + image->width*image->height/4;
image->pixels[3] = image->pixels[2] + image->width*image->height/16;
if (size > (file_size - ofs))
{
memcpy(image->pixels[0], (byte *)mt + ofs, file_size - ofs);
// looks short, restore everything from first image
R_ImageShrink(image->pixels[0], image->pixels[1],
image->height, image->height/2,
image->width, image->width/2);
R_ImageShrink(image->pixels[1], image->pixels[2],
image->height/2, image->height/4,
image->width/2, image->width/4);
R_ImageShrink(image->pixels[2], image->pixels[3],
image->height/4, image->height/8,
image->width/4, image->width/8);
}
else
{
memcpy ( image->pixels[0], (byte *)mt + ofs, size);
}
R_FixPalette(image->pixels[0], size, mt->palette);
ri.FS_FreeFile ((void *)mt);
return image;
}
static image_t *
R_LoadHiColorImage(char *name, const char* namewe, const char *ext, imagetype_t type)
{
@ -319,6 +430,11 @@ R_LoadHiColorImage(char *name, const char* namewe, const char *ext, imagetype_t
/* Get size of the original texture */
GetWalInfo(name, &realwidth, &realheight);
}
else if (strcmp(ext, "m8") == 0)
{
/* Get size of the original texture */
GetM8Info(name, &realwidth, &realheight);
}
/* try to load a tga, png or jpg (in that order/priority) */
if ( LoadSTB(namewe, "tga", &pic, &width, &height)
@ -417,6 +533,10 @@ R_LoadImage(char *name, const char* namewe, const char *ext, imagetype_t type)
{
image = R_LoadWal(name, type);
}
else if (strcmp(ext, "m8") == 0)
{
image = R_LoadM8 (name, type);
}
}
return image;

View File

@ -135,6 +135,7 @@ float se_time1, se_time2, de_time1, de_time2;
cvar_t *r_lefthand;
cvar_t *r_gunfov;
cvar_t *r_farsee;
static cvar_t *sw_aliasstats;
cvar_t *sw_clearcolor;
cvar_t *sw_drawflat;
@ -389,6 +390,7 @@ R_RegisterVariables (void)
r_lefthand = ri.Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
r_gunfov = ri.Cvar_Get( "r_gunfov", "80", CVAR_ARCHIVE );
r_farsee = ri.Cvar_Get("r_farsee", "0", CVAR_LATCH | CVAR_ARCHIVE);
r_speeds = ri.Cvar_Get ("r_speeds", "0", 0);
r_fullbright = ri.Cvar_Get ("r_fullbright", "0", 0);
r_drawentities = ri.Cvar_Get ("r_drawentities", "1", 0);
@ -543,7 +545,9 @@ R_ReallocateMapBuffers (void)
r_outofsurfaces = false;
}
if (r_cnumsurfs < NUMSTACKSURFACES)
if ((r_farsee->value > 0) && (r_cnumsurfs < NUMSTACKSURFACES))
r_cnumsurfs = NUMSTACKSURFACES * 2;
else if (r_cnumsurfs < NUMSTACKSURFACES)
r_cnumsurfs = NUMSTACKSURFACES;
// edge_t->surf limited size to short
@ -618,7 +622,9 @@ R_ReallocateMapBuffers (void)
r_outofedges = false;
}
if (r_numallocatededges < NUMSTACKEDGES)
if ((r_farsee->value > 0) && (r_numallocatededges < NUMSTACKEDGES * 2))
r_numallocatededges = NUMSTACKEDGES * 2;
else if (r_numallocatededges < NUMSTACKEDGES)
r_numallocatededges = NUMSTACKEDGES;
r_edges = malloc (r_numallocatededges * sizeof(edge_t));
@ -1077,12 +1083,12 @@ R_DrawBEntitiesOnList (void)
{
entity_t *currententity = &r_newrefdef.entities[i];
const model_t *currentmodel = currententity->model;
if ( currententity->flags & RF_BEAM )
continue;
if (!currentmodel)
continue;
if (currentmodel->nummodelsurfaces == 0)
continue; // clip brush only
if ( currententity->flags & RF_BEAM )
continue;
if (currentmodel->type != mod_brush)
continue;
// see if the bounding box lets us trivially reject, also sets
@ -1293,7 +1299,8 @@ RE_RenderFrame (refdef_t *fd)
VectorCopy (fd->viewangles, r_refdef.viewangles);
// compare current position with old
if (!VectorCompareRound(fd->vieworg, lastvieworg) ||
if (vid.width <= 640 ||
!VectorCompareRound(fd->vieworg, lastvieworg) ||
!VectorCompare(fd->viewangles, lastviewangles))
{
fastmoving = true;
@ -1426,6 +1433,8 @@ RE_BeginFrame( float camera_separation )
{
// pallete without changes
palette_changed = false;
// run without speed optimization
fastmoving = false;
while (r_mode->modified || vid_fullscreen->modified || r_vsync->modified)
{
@ -1519,7 +1528,7 @@ RE_SetMode(void)
}
/* try setting it back to something safe */
if ((err = SWimp_SetMode(&vid.width, &vid.height, sw_state.prev_mode, 0)) != rserr_ok)
if (SWimp_SetMode(&vid.width, &vid.height, sw_state.prev_mode, 0) != rserr_ok)
{
R_Printf(PRINT_ALL, "%s() - could not revert to safe mode\n", __func__);
return false;
@ -1713,6 +1722,11 @@ RE_SetSky (char *name, float rotate, vec3_t axis)
{
Com_sprintf (pathname, sizeof(pathname), "env/%s%s.pcx", skyname, suf[r_skysideimage[i]]);
r_skytexinfo[i].image = R_FindImage (pathname, it_sky);
if (!r_skytexinfo[i].image)
{
Com_sprintf (pathname, sizeof(pathname), "pics/Skies/%s%s.m8", skyname, suf[r_skysideimage[i]]);
r_skytexinfo[i].image = R_FindImage (pathname, it_sky);
}
}
}
@ -2055,10 +2069,13 @@ RE_CopyFrame (Uint32 * pixels, int pitch, int vmin, int vmax)
max_pixels = pixels + vmax;
buffer_pos = vid_buffer + vmin;
for (pixels_pos = pixels + vmin; pixels_pos < max_pixels; pixels_pos++)
pixels_pos = pixels + vmin;
while ( pixels_pos < max_pixels)
{
*pixels_pos = sdl_palette[*buffer_pos];
buffer_pos++;
pixels_pos++;
}
}
else
@ -2128,6 +2145,7 @@ RE_CleanFrame(void)
Com_Printf("Can't lock texture: %s\n", SDL_GetError());
return;
}
// only cleanup texture without flush texture to screen
memset(pixels, 0, pitch * vid.height);
SDL_UnlockTexture(texture);
@ -2157,6 +2175,12 @@ RE_FlushFrame(int vmin, int vmax)
// code have to copy a whole screen to the texture
RE_CopyFrame (pixels, pitch / sizeof(Uint32), 0, vid.height * vid.width);
}
if (((int)sw_texture_filtering->value & 0x01) && !fastmoving)
{
SmoothColorImage(pixels + vmin, vmax - vmin, vid.width >> 7);
}
SDL_UnlockTexture(texture);
SDL_RenderCopy(renderer, texture, NULL, NULL);

View File

@ -514,6 +514,12 @@ Mod_LoadTexinfo (lump_t *l)
Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);
out->image = R_FindImage (name, it_wall);
if (!out->image || out->image == r_notexture_mip)
{
Com_sprintf (name, sizeof(name), "textures/%s.m8", in->texture);
out->image = R_FindImage (name, it_wall);
}
if (!out->image)
{
out->image = r_notexture_mip; // texture not found

View File

@ -719,7 +719,7 @@ D_DrawSpansPow2 (espan_t *pspan, float d_ziorigin, float d_zistepu, float d_zist
}
// Drawing phrase
if (texture_filtering == 0 || fastmoving)
if ((texture_filtering & 0x02) == 0 || fastmoving)
{
pdest = D_DrawSpan(pdest, pbase, s, t, sstep, tstep,
spancount);

View File

@ -213,19 +213,21 @@ R_InitCaches (void)
int size;
// calculate size to allocate
if (sw_surfcacheoverride->value)
int pix;
// surface cache size at 320X240
size = 1024*768;
pix = vid.width*vid.height;
if (pix > 64000)
size += (pix-64000)*3;
if (r_farsee->value > 0)
size *= 2;
if (sw_surfcacheoverride->value > size)
{
size = sw_surfcacheoverride->value;
}
else
{
int pix;
size = SURFCACHE_SIZE_AT_320X240;
pix = vid.width*vid.height;
if (pix > 64000)
size += (pix-64000)*3;
}
// round up to page size
size = (size + 8191) & ~8191;

View File

@ -197,7 +197,7 @@ void R_RenderDlights (void);
void R_DrawAlphaSurfaces (void);
void RE_InitParticleTexture (void);
void Draw_InitLocal (void);
void Vk_SubdivideSurface (msurface_t *fa);
void Vk_SubdivideSurface (msurface_t *fa, model_t *loadmodel);
qboolean R_CullBox (vec3_t mins, vec3_t maxs);
void R_RotateForEntity (entity_t *e, float *mvMatrix);
void R_MarkLeaves (void);
@ -232,9 +232,15 @@ void Vk_TextureMode( char *string );
void Vk_LmapTextureMode( char *string );
void Vk_ImageList_f (void);
void Vk_BuildPolygonFromSurface(msurface_t *fa, model_t *currentmodel);
void Vk_CreateSurfaceLightmap (msurface_t *surf);
void Vk_EndBuildingLightmaps (void);
void Vk_BeginBuildingLightmaps (model_t *m);
void Vk_InitImages (void);
void Vk_ShutdownImages (void);
void Vk_FreeUnusedImages (void);
qboolean Vk_ImageHasFreeSpace(void);
void RE_BeginRegistration (char *model);
struct model_s *RE_RegisterModel (char *name);

View File

@ -44,16 +44,6 @@ typedef struct
vec3_t position;
} mvertex_t;
typedef struct
{
vec3_t mins, maxs;
vec3_t origin; // for sounds or lights
float radius;
int headnode;
int visleafs; // not including the solid leaf 0
int firstface, numfaces;
} mmodel_t;
#define SIDE_FRONT 0
#define SIDE_BACK 1
@ -200,7 +190,7 @@ typedef struct model_s
int lightmap; // only for submodels
int numsubmodels;
mmodel_t *submodels;
struct model_s *submodels;
int numplanes;
cplane_t *planes;
@ -239,6 +229,9 @@ typedef struct model_s
int extradatasize;
void *extradata;
// submodules
vec3_t origin; // for sounds or lights
} model_t;
//============================================================================

View File

@ -21,7 +21,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "header/local.h"
image_t vktextures[MAX_VKTEXTURES];
int numvktextures;
int numvktextures = 0;
static int img_loaded = 0;
static int image_max = 0;
// texture for storing raw image data (cinematics, endscreens, etc.)
qvktexture_t vk_rawTexture = QVVKTEXTURE_INIT;
@ -530,17 +533,27 @@ Vk_ImageList_f
*/
void Vk_ImageList_f (void)
{
int i;
int i, used, texels;
image_t *image;
int texels;
qboolean freeup;
R_Printf(PRINT_ALL, "------------------\n");
texels = 0;
used = 0;
for (i = 0, image = vktextures; i < numvktextures; i++, image++)
{
char *in_use = "";
if (image->vk_texture.resource.image == VK_NULL_HANDLE)
continue;
if (image->registration_sequence == registration_sequence)
{
in_use = "*";
used++;
}
texels += image->upload_width*image->upload_height;
switch (image->type)
{
@ -561,11 +574,13 @@ void Vk_ImageList_f (void)
break;
}
R_Printf(PRINT_ALL, " %4i %4i RGB: %s (%dx%d)\n",
R_Printf(PRINT_ALL, " %4i %4i RGB: %s (%dx%d) %s\n",
image->upload_width, image->upload_height, image->name,
image->width, image->height);
image->width, image->height, in_use);
}
R_Printf(PRINT_ALL, "Total texel count (not counting mipmaps): %i\n", texels);
R_Printf(PRINT_ALL, "Total texel count (not counting mipmaps): %i in %d images\n", texels, img_loaded);
freeup = Vk_ImageHasFreeSpace();
R_Printf(PRINT_ALL, "Used %d of %d images%s.\n", used, image_max, freeup ? ", has free space" : "");
}
typedef struct
@ -978,6 +993,12 @@ Vk_LoadPic(char *name, byte *pic, int width, int realwidth,
image->width = realwidth;
image->height = realheight;
image->type = type;
// update count of loaded images
img_loaded ++;
if (vk_validation->value)
{
R_Printf(PRINT_ALL, "%s: Load %s[%d]\n", __func__, image->name, img_loaded);
}
if (type == it_skin && bits == 8)
FloodFillSkin(pic, width, height);
@ -1055,6 +1076,75 @@ static image_t *Vk_LoadWal (char *name, imagetype_t type)
return image;
}
static image_t *
Vk_LoadM8(char *origname, imagetype_t type)
{
m8tex_t *mt;
int width, height, ofs, size;
image_t *image;
char name[256];
unsigned char *image_buffer = NULL;
Q_strlcpy(name, origname, sizeof(name));
/* Add the extension */
if (strcmp(COM_FileExtension(name), "m8"))
{
Q_strlcat(name, ".m8", sizeof(name));
}
size = ri.FS_LoadFile(name, (void **)&mt);
if (!mt)
{
R_Printf(PRINT_ALL, "%s: can't load %s\n", __func__, name);
return r_notexture;
}
if (size < sizeof(m8tex_t))
{
R_Printf(PRINT_ALL, "%s: can't load %s, small header\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return r_notexture;
}
if (LittleLong (mt->version) != M8_VERSION)
{
R_Printf(PRINT_ALL, "LoadWal: can't load %s, wrong magic value.\n", name);
ri.FS_FreeFile ((void *)mt);
return r_notexture;
}
width = LittleLong(mt->width[0]);
height = LittleLong(mt->height[0]);
ofs = LittleLong(mt->offsets[0]);
if ((ofs <= 0) || (width <= 0) || (height <= 0) ||
(((size - ofs) / height) < width))
{
R_Printf(PRINT_ALL, "%s: can't load %s, small body\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return r_notexture;
}
image_buffer = malloc (width * height * 4);
for(int i=0; i<width * height; i++)
{
unsigned char value = *((byte *)mt + ofs + i);
image_buffer[i * 4 + 0] = mt->palette[value].r;
image_buffer[i * 4 + 1] = mt->palette[value].g;
image_buffer[i * 4 + 2] = mt->palette[value].b;
image_buffer[i * 4 + 3] = value == 255 ? 0 : 255;
}
image = Vk_LoadPic(name, image_buffer, width, width, height, height, type, 32);
free(image_buffer);
ri.FS_FreeFile((void *)mt);
return image;
}
static image_t*
Vk_LoadHiColorImage(char *name, const char* namewe, const char *ext, imagetype_t type)
{
@ -1073,6 +1163,11 @@ Vk_LoadHiColorImage(char *name, const char* namewe, const char *ext, imagetype_t
/* Get size of the original texture */
GetWalInfo(name, &realwidth, &realheight);
}
else if (strcmp(ext, "m8") == 0)
{
/* Get size of the original texture */
GetM8Info(name, &realwidth, &realheight);
}
/* try to load a tga, png or jpg (in that order/priority) */
if ( LoadSTB(namewe, "tga", &pic, &width, &height)
@ -1142,6 +1237,10 @@ Vk_LoadImage(char *name, const char* namewe, const char *ext, imagetype_t type)
{
image = Vk_LoadWal (name, type);
}
else if (!strcmp(ext, "m8"))
{
image = Vk_LoadM8 (name, type);
}
else if (!strcmp(ext, "tga"))
{
if (!LoadSTB (namewe, "tga", &pic, &width, &height))
@ -1232,6 +1331,31 @@ struct image_s *RE_RegisterSkin (char *name)
return Vk_FindImage (name, it_skin);
}
qboolean Vk_ImageHasFreeSpace(void)
{
int i, used;
image_t *image;
used = 0;
for (i = 0, image = vktextures; i < numvktextures; i++, image++)
{
if (!image->name[0])
continue;
if (image->registration_sequence == registration_sequence)
{
used ++;
}
}
if (image_max < used)
{
image_max = used;
}
// should same size of free slots as currently used
return (img_loaded + used) < MAX_VKTEXTURES;
}
/*
================
@ -1246,6 +1370,12 @@ void Vk_FreeUnusedImages (void)
int i;
image_t *image;
if (Vk_ImageHasFreeSpace())
{
// should be enough space for load next images
return;
}
// never free r_notexture or particle texture
r_notexture->registration_sequence = registration_sequence;
r_particletexture->registration_sequence = registration_sequence;
@ -1259,9 +1389,21 @@ void Vk_FreeUnusedImages (void)
continue; // free image_t slot
if (image->type == it_pic)
continue; // don't free pics
if (vk_validation->value)
{
R_Printf(PRINT_ALL, "%s: Unload %s[%d]\n", __func__, image->name, img_loaded);
}
// free it
QVk_ReleaseTexture(&image->vk_texture);
memset(image, 0, sizeof(*image));
img_loaded --;
if (img_loaded < 0)
{
ri.Sys_Error (ERR_DROP, "%s: Broken unload", __func__);
}
}
// free all unused blocks
@ -1318,6 +1460,9 @@ void Vk_InitImages (void)
int i;
float overbright;
numvktextures = 0;
img_loaded = 0;
image_max = 0;
registration_sequence = 1;
// init intensity conversions
@ -1377,8 +1522,19 @@ void Vk_ShutdownImages (void)
if (!image->registration_sequence)
continue; // free image_t slot
if (vk_validation->value)
{
R_Printf(PRINT_ALL, "%s: Unload %s[%d]\n", __func__, image->name, img_loaded);
}
QVk_ReleaseTexture(&image->vk_texture);
memset(image, 0, sizeof(*image));
img_loaded --;
if (img_loaded < 0)
{
ri.Sys_Error (ERR_DROP, "%s: Broken unload", __func__);
}
}
QVk_ReleaseTexture(&vk_rawTexture);

File diff suppressed because it is too large Load Diff

View File

@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// vk_warp.c -- sky and water polygons
#include "header/local.h"
extern model_t *loadmodel;
static char skyname[MAX_QPATH];
static float skyrotate;
static vec3_t skyaxis;
@ -162,7 +160,7 @@ boundaries so that turbulent and sky warps
can be done reasonably.
================
*/
void Vk_SubdivideSurface (msurface_t *fa)
void Vk_SubdivideSurface (msurface_t *fa, model_t *loadmodel)
{
vec3_t verts[64];
int numverts;
@ -687,6 +685,11 @@ void RE_SetSky (char *name, float rotate, vec3_t axis)
Com_sprintf(pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);
sky_images[i] = Vk_FindImage(pathname, it_sky);
if (!sky_images[i]) {
Com_sprintf(pathname, sizeof(pathname), "pics/Skies/%s%s.m8", skyname, suf[i]);
sky_images[i] = Vk_FindImage(pathname, it_sky);
}
if (!sky_images[i])
sky_images[i] = r_notexture;

View File

@ -138,32 +138,34 @@ Cvar_FindVar(const char *var_name)
static qboolean
Cvar_IsFloat(const char *s)
{
int c, dot = '.';
int dot = '.';
if (*s == '-')
if (*s == '-')
{
s++;
}
s++;
}
if (!*s)
if (!*s)
{
return false;
}
return false;
}
do {
c = *s++;
do {
int c;
if (c == dot)
c = *s++;
if (c == dot)
{
dot = 0;
}
else if (!(c >= '0' || c <= '9'))
dot = 0;
}
else if (c < '0' || c > '9')
{
return false;
}
} while (*s);
return false;
}
} while (*s);
return true;
return true;
}
float
@ -514,7 +516,7 @@ void
Cvar_Set_f(void)
{
char *firstarg;
int c, flags, i;
int c, i;
c = Cmd_Argc();
@ -537,6 +539,8 @@ Cvar_Set_f(void)
if (c == 4)
{
int flags;
if (!strcmp(Cmd_Argv(3), "u"))
{
flags = CVAR_USERINFO;

View File

@ -174,6 +174,31 @@ typedef struct miptex_s
int value;
} miptex_t;
/* .M8 texture file format */
#define M8_MIP_LEVELS 16
#define M8_VERSION 0x2
typedef struct {
unsigned char r;
unsigned char g;
unsigned char b;
} rgb_t;
typedef struct m8tex_s
{
unsigned version;
char name[32];
unsigned width[M8_MIP_LEVELS];
unsigned height[M8_MIP_LEVELS];
unsigned offsets[M8_MIP_LEVELS]; /* 16 mip maps stored */
char animname[32]; /* next frame in animation chain */
rgb_t palette[256];
int flags;
int contents;
int value;
} m8tex_t;
/* .BSP file format */
#define IDBSPHEADER (('P' << 24) + ('S' << 16) + ('B' << 8) + 'I') /* little-endian "IBSP" */

View File

@ -1356,7 +1356,12 @@ Info_SetValueForKey(char *s, char *key, char *value)
int c;
int maxsize = MAX_INFO_STRING;
if (strstr(key, "\\") || strstr(value, "\\"))
if (!key)
{
return;
}
if (strstr(key, "\\") || (value && strstr(value, "\\")))
{
Com_Printf("Can't use keys or values with a \\\n");
return;
@ -1368,13 +1373,13 @@ Info_SetValueForKey(char *s, char *key, char *value)
return;
}
if (strstr(key, "\"") || strstr(value, "\""))
if (strstr(key, "\"") || (value && strstr(value, "\"")))
{
Com_Printf("Can't use keys or values with a \"\n");
return;
}
if ((strlen(key) > MAX_INFO_KEY - 1) || (strlen(value) > MAX_INFO_KEY - 1))
if ((strlen(key) > MAX_INFO_KEY - 1) || (value && (strlen(value) > MAX_INFO_KEY - 1)))
{
Com_Printf("Keys and values must be < 64 characters.\n");
return;

View File

@ -27,7 +27,7 @@
#include "header/local.h"
void infantry_die(edict_t *self, edict_t *inflictor, edict_t *attacker,
int damage);
int damage, vec3_t point);
void infantry_stand(edict_t *self);
void monster_use(edict_t *self, edict_t *other, edict_t *activator);
qboolean FindTarget(edict_t *self);
@ -410,7 +410,7 @@ SP_turret_base(edict_t *self)
*/
void
turret_driver_die(edict_t *self, edict_t *inflictor, edict_t *attacker,
int damage, vec3_t point /* unused */)
int damage, vec3_t point)
{
edict_t *ent;
@ -436,7 +436,7 @@ turret_driver_die(edict_t *self, edict_t *inflictor, edict_t *attacker,
self->target_ent->owner = NULL;
self->target_ent->teammaster->owner = NULL;
infantry_die(self, inflictor, attacker, damage);
infantry_die(self, inflictor, attacker, damage, point);
}
void

View File

@ -392,7 +392,7 @@ SP_info_player_coop(edict_t *self)
* roll as well as yaw. 'pitch yaw roll'
*/
void
SP_info_player_intermission(void)
SP_info_player_intermission(edict_t *self)
{
/* Thus function cannot be removed
* since the info_player_intermission

View File

@ -194,7 +194,7 @@ extern void ClientObituary ( edict_t * self , edict_t * inflictor , edict_t * at
extern qboolean IsNeutral ( edict_t * ent ) ;
extern qboolean IsFemale ( edict_t * ent ) ;
extern void player_pain ( edict_t * self , edict_t * other , float kick , int damage ) ;
extern void SP_info_player_intermission ( void ) ;
extern void SP_info_player_intermission ( edict_t * ent ) ;
extern void SP_info_player_coop ( edict_t * self ) ;
extern void SP_info_player_deathmatch ( edict_t * self ) ;
extern void SP_info_player_start ( edict_t * self ) ;