Merge pull request #363 from 0lvin/image_resize

Soft Render: Image resize
This commit is contained in:
Yamagi 2019-02-04 13:41:54 +01:00 committed by GitHub
commit 9c549f1cd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 3067 additions and 1366 deletions

View File

@ -521,7 +521,7 @@ set(SOFT-Source
${REF_SRC_DIR}/soft/sw_model.c
${REF_SRC_DIR}/soft/sw_part.c
${REF_SRC_DIR}/soft/sw_poly.c
${REF_SRC_DIR}/soft/sw_polyse.c
${REF_SRC_DIR}/soft/sw_polyset.c
${REF_SRC_DIR}/soft/sw_rast.c
${REF_SRC_DIR}/soft/sw_scan.c
${REF_SRC_DIR}/soft/sw_sprite.c
@ -535,7 +535,9 @@ set(SOFT-Source
)
set(SOFT-Header
${REF_SRC_DIR}/constants/adivtab.h
${REF_SRC_DIR}/ref_shared.h
${REF_SRC_DIR}/files/stb_image.h
${REF_SRC_DIR}/files/stb_image_resize.h
${REF_SRC_DIR}/soft/header/local.h
${REF_SRC_DIR}/soft/header/model.h
${COMMON_SRC_DIR}/header/shared.h

View File

@ -5,7 +5,7 @@ copys for each license:
- Quake II
- Info-ZIP
- Cocoa SDL entry points
- stb_image.h, stb_image_write.h, stb_vorbis.h
- stb_image.h, stb_image_write.h, stb_image_resize.h, stb_vorbis.h
- miniz
Parts of other Quake II Clients were included into the source. They

View File

@ -834,7 +834,7 @@ REFSOFT_OBJS_ := \
src/client/refresh/soft/sw_model.o \
src/client/refresh/soft/sw_part.o \
src/client/refresh/soft/sw_poly.o \
src/client/refresh/soft/sw_polyse.o \
src/client/refresh/soft/sw_polyset.o \
src/client/refresh/soft/sw_rast.o \
src/client/refresh/soft/sw_scan.o \
src/client/refresh/soft/sw_sprite.o \

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,10 @@
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
// include resize implementation
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include "stb_image_resize.h"
/*
* origname: the filename to be opened, might be without extension
* type: extension of the type we wanna open ("jpg", "png" or "tga")
@ -89,5 +93,11 @@ LoadSTB(const char *origname, const char* type, byte **pic, int *width, int *hei
return true;
}
extern qboolean ResizeSTB(byte *input_pixels, int input_width, int input_height,
byte *output_pixels, int output_width, int output_height)
{
if (stbir_resize_uint8(input_pixels, input_width, input_height, 0,
output_pixels, output_width, output_height, 0, 4))
return true;
return false;
}

View File

@ -1,4 +1,4 @@
/* stb_image - v2.18 - public domain image loader - http://nothings.org/stb
/* stb_image - v2.19 - public domain image loader - http://nothings.org/stb
no warranty implied; use at your own risk
Do this:
@ -48,6 +48,7 @@ LICENSE
RECENT REVISION HISTORY:
2.19 (2018-02-11) fix warning
2.18 (2018-01-30) fix warnings
2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings
2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes
@ -6894,7 +6895,7 @@ static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp)
static int stbi__psd_is16(stbi__context *s)
{
int channelCount, dummy, depth;
int channelCount, depth;
if (stbi__get32be(s) != 0x38425053) {
stbi__rewind( s );
return 0;
@ -6909,8 +6910,8 @@ static int stbi__psd_is16(stbi__context *s)
stbi__rewind( s );
return 0;
}
dummy = stbi__get32be(s);
dummy = stbi__get32be(s);
(void) stbi__get32be(s);
(void) stbi__get32be(s);
depth = stbi__get16be(s);
if (depth != 16) {
stbi__rewind( s );
@ -7237,6 +7238,8 @@ STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user
/*
revision history:
2.19 (2018-02-11) fix warning
2.18 (2018-01-30) fix warnings
2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug
1-bit BMP
*_is_16_bit api

File diff suppressed because it is too large Load Diff

View File

@ -56,7 +56,7 @@ Mod_PointInLeaf(vec3_t p, model_t *model)
if (!model || !model->nodes)
{
ri.Sys_Error(ERR_DROP, "Mod_PointInLeaf: bad model");
ri.Sys_Error(ERR_DROP, "%s: bad model", __func__);
}
node = model->nodes;
@ -139,7 +139,7 @@ Mod_ForName(char *name, qboolean crash)
if (!name[0])
{
ri.Sys_Error(ERR_DROP, "Mod_ForName: NULL name");
ri.Sys_Error(ERR_DROP, "%s: NULL name", __func__);
}
/* inline models are grabbed only from worldmodel */
@ -149,7 +149,8 @@ Mod_ForName(char *name, qboolean crash)
if ((i < 1) || !r_worldmodel || (i >= r_worldmodel->numsubmodels))
{
ri.Sys_Error(ERR_DROP, "bad inline model number");
ri.Sys_Error(ERR_DROP, "%s: bad inline model number",
__func__);
}
return &mod_inline[i];
@ -197,7 +198,8 @@ Mod_ForName(char *name, qboolean crash)
{
if (crash)
{
ri.Sys_Error(ERR_DROP, "Mod_NumForName: %s not found", mod->name);
ri.Sys_Error(ERR_DROP, "%s: %s not found",
__func__, mod->name);
}
memset(mod->name, 0, sizeof(mod->name));
@ -222,9 +224,8 @@ Mod_ForName(char *name, qboolean crash)
break;
default:
ri.Sys_Error(ERR_DROP,
"Mod_NumForName: unknown fileid for %s",
mod->name);
ri.Sys_Error(ERR_DROP, "%s: unknown fileid for %s",
__func__, mod->name);
break;
}
@ -282,8 +283,8 @@ Mod_LoadVertexes(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -311,8 +312,8 @@ Mod_LoadSubmodels(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -349,8 +350,8 @@ Mod_LoadEdges(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -379,8 +380,8 @@ Mod_LoadTexinfo(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -505,8 +506,8 @@ Mod_LoadFaces(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -540,7 +541,8 @@ Mod_LoadFaces(lump_t *l)
if ((ti < 0) || (ti >= loadmodel->numtexinfo))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: bad texinfo number");
ri.Sys_Error(ERR_DROP, "%s: bad texinfo number",
__func__);
}
out->texinfo = loadmodel->texinfo + ti;
@ -619,8 +621,8 @@ Mod_LoadNodes(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -673,8 +675,8 @@ Mod_LoadLeafs(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -706,7 +708,8 @@ Mod_LoadLeafs(lump_t *l)
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
{
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: wrong marksurfaces position in %s",loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
__func__, loadmodel->name);
}
}
}
@ -722,8 +725,8 @@ Mod_LoadMarksurfaces(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -738,7 +741,8 @@ Mod_LoadMarksurfaces(lump_t *l)
if ((j < 0) || (j >= loadmodel->numsurfaces))
{
ri.Sys_Error(ERR_DROP, "Mod_ParseMarksurfaces: bad surface number");
ri.Sys_Error(ERR_DROP, "%s: bad surface number",
__func__);
}
out[i] = loadmodel->surfaces + j;
@ -755,16 +759,16 @@ Mod_LoadSurfedges(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
if ((count < 1) || (count >= MAX_MAP_SURFEDGES))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: bad surfedges count in %s: %i",
loadmodel->name, count);
ri.Sys_Error(ERR_DROP, "%s: bad surfedges count in %s: %i",
__func__, loadmodel->name, count);
}
out = Hunk_Alloc(count * sizeof(*out));
@ -791,8 +795,8 @@ Mod_LoadPlanes(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -850,8 +854,8 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
if (i != BSPVERSION)
{
ri.Sys_Error(ERR_DROP, "Mod_LoadBrushModel: %s has wrong version number (%i should be %i)",
mod->name, i, BSPVERSION);
ri.Sys_Error(ERR_DROP, "%s: %s has wrong version number (%i should be %i)",
__func__, mod->name, i, BSPVERSION);
}
/* swap all the lumps */
@ -893,7 +897,8 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
if (starmod->firstnode >= loadmodel->numnodes)
{
ri.Sys_Error(ERR_DROP, "Inline model %i has bad firstnode", i);
ri.Sys_Error(ERR_DROP, "%s: Inline model %i has bad firstnode",
__func__, i);
}
VectorCopy(bm->maxs, starmod->maxs);

View File

@ -48,7 +48,7 @@ GL3_Mod_PointInLeaf(vec3_t p, gl3model_t *model)
if (!model || !model->nodes)
{
ri.Sys_Error(ERR_DROP, "Mod_PointInLeaf: bad model");
ri.Sys_Error(ERR_DROP, "%s: bad model", __func__);
}
node = model->nodes;
@ -166,8 +166,8 @@ Mod_LoadVertexes(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -195,8 +195,8 @@ Mod_LoadSubmodels(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -233,8 +233,8 @@ Mod_LoadEdges(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -263,8 +263,8 @@ Mod_LoadTexinfo(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -392,8 +392,8 @@ Mod_LoadFaces(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -427,7 +427,8 @@ Mod_LoadFaces(lump_t *l)
if ((ti < 0) || (ti >= loadmodel->numtexinfo))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: bad texinfo number");
ri.Sys_Error(ERR_DROP, "%s: bad texinfo number",
__func__);
}
out->texinfo = loadmodel->texinfo + ti;
@ -505,8 +506,8 @@ Mod_LoadNodes(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -559,8 +560,8 @@ Mod_LoadLeafs(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -592,7 +593,8 @@ Mod_LoadLeafs(lump_t *l)
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
{
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: wrong marksurfaces position in %s",loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
__func__, loadmodel->name);
}
}
}
@ -608,8 +610,8 @@ Mod_LoadMarksurfaces(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -624,7 +626,7 @@ Mod_LoadMarksurfaces(lump_t *l)
if ((j < 0) || (j >= loadmodel->numsurfaces))
{
ri.Sys_Error(ERR_DROP, "Mod_ParseMarksurfaces: bad surface number");
ri.Sys_Error(ERR_DROP, "%s: bad surface number", __func__);
}
out[i] = loadmodel->surfaces + j;
@ -641,16 +643,16 @@ Mod_LoadSurfedges(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
if ((count < 1) || (count >= MAX_MAP_SURFEDGES))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: bad surfedges count in %s: %i",
loadmodel->name, count);
ri.Sys_Error(ERR_DROP, "%s: bad surfedges count in %s: %i",
__func__, loadmodel->name, count);
}
out = Hunk_Alloc(count * sizeof(*out));
@ -677,8 +679,8 @@ Mod_LoadPlanes(lump_t *l)
if (l->filelen % sizeof(*in))
{
ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
@ -736,8 +738,8 @@ Mod_LoadBrushModel(gl3model_t *mod, void *buffer, int modfilelen)
if (i != BSPVERSION)
{
ri.Sys_Error(ERR_DROP, "Mod_LoadBrushModel: %s has wrong version number (%i should be %i)",
mod->name, i, BSPVERSION);
ri.Sys_Error(ERR_DROP, "%s: %s has wrong version number (%i should be %i)",
__func__, mod->name, i, BSPVERSION);
}
/* swap all the lumps */
@ -779,7 +781,8 @@ Mod_LoadBrushModel(gl3model_t *mod, void *buffer, int modfilelen)
if (starmod->firstnode >= loadmodel->numnodes)
{
ri.Sys_Error(ERR_DROP, "Inline model %i has bad firstnode", i);
ri.Sys_Error(ERR_DROP, "%s: Inline model %i has bad firstnode",
__func__, i);
}
VectorCopy(bm->maxs, starmod->maxs);
@ -831,7 +834,7 @@ Mod_ForName(char *name, qboolean crash)
if (!name[0])
{
ri.Sys_Error(ERR_DROP, "Mod_ForName: NULL name");
ri.Sys_Error(ERR_DROP, "%s: NULL name", __func__);
}
/* inline models are grabbed only from worldmodel */
@ -841,7 +844,8 @@ Mod_ForName(char *name, qboolean crash)
if ((i < 1) || !gl3_worldmodel || (i >= gl3_worldmodel->numsubmodels))
{
ri.Sys_Error(ERR_DROP, "bad inline model number");
ri.Sys_Error(ERR_DROP, "%s: bad inline model number",
__func__);
}
return &mod_inline[i];
@ -889,7 +893,8 @@ Mod_ForName(char *name, qboolean crash)
{
if (crash)
{
ri.Sys_Error(ERR_DROP, "Mod_NumForName: %s not found", mod->name);
ri.Sys_Error(ERR_DROP, "%s: %s not found",
__func__, mod->name);
}
memset(mod->name, 0, sizeof(mod->name));
@ -914,9 +919,8 @@ Mod_ForName(char *name, qboolean crash)
break;
default:
ri.Sys_Error(ERR_DROP,
"Mod_NumForName: unknown fileid for %s",
mod->name);
ri.Sys_Error(ERR_DROP, "%s: unknown fileid for %s",
__func__, mod->name);
break;
}

View File

@ -64,6 +64,8 @@ extern void LoadPCX(char *origname, byte **pic, byte **palette, int *width, int
extern void GetPCXInfo(char *filename, int *width, int *height);
extern qboolean LoadSTB(const char *origname, const char* type, byte **pic, int *width, int *height);
extern qboolean ResizeSTB(byte *input_pixels, int input_width, int input_height,
byte *output_pixels, int output_width, int output_height);
extern void GetWalInfo(char *name, int *width, int *height);

View File

@ -74,6 +74,7 @@ typedef struct image_s
typedef unsigned char pixel_t;
typedef int shift20_t;
typedef int zvalue_t;
typedef unsigned int light_t;
// xyz-prescale to 16.16 fixed-point
#define SHIFT16XYZ 16
@ -314,8 +315,6 @@ typedef struct surf_s
float nearzi; // nearest 1/z on surface, for mipmapping
qboolean insubmodel;
float d_ziorigin, d_zistepu, d_zistepv;
int pad[2]; // to 64 bytes
} surf_t;
typedef struct edge_s

View File

@ -58,7 +58,6 @@ typedef struct mplane_s
float dist;
byte type; // for texture axis selection and fast side tests
byte signbits; // signx + signy<<1 + signz<<1
byte pad[2];
} mplane_t;

View File

@ -496,8 +496,8 @@ R_AliasSetupSkin(const entity_t *currententity, const model_t *currentmodel)
skinnum = currententity->skinnum;
if ((skinnum >= s_pmdl->num_skins) || (skinnum < 0))
{
R_Printf(PRINT_ALL, "R_AliasSetupSkin %s: no such skin # %d\n",
currentmodel->name, skinnum);
R_Printf(PRINT_ALL, "%s %s: no such skin # %d\n",
__func__, currentmodel->name, skinnum);
skinnum = 0;
}
@ -624,14 +624,14 @@ R_AliasSetupFrames(const entity_t *currententity, const model_t *currentmodel, d
if ( ( thisframe >= pmdl->num_frames ) || ( thisframe < 0 ) )
{
R_Printf(PRINT_ALL, "R_AliasSetupFrames %s: no such thisframe %d\n",
currentmodel->name, thisframe);
R_Printf(PRINT_ALL, "%s %s: no such thisframe %d\n",
__func__, currentmodel->name, thisframe);
thisframe = 0;
}
if ( ( lastframe >= pmdl->num_frames ) || ( lastframe < 0 ) )
{
R_Printf(PRINT_ALL, "R_AliasSetupFrames %s: no such lastframe %d\n",
currentmodel->name, lastframe);
R_Printf(PRINT_ALL, "%s %s: no such lastframe %d\n",
__func__, currentmodel->name, lastframe);
lastframe = 0;
}

View File

@ -377,7 +377,7 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre
for (j=0 ; j<psurf->numedges ; j++)
{
lindex = currentmodel->surfedges[psurf->firstedge+j];
lindex = currentmodel->surfedges[psurf->firstedge+j];
if (lindex > 0)
{
@ -399,9 +399,14 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre
pbedge[j-1].pnext = NULL; // mark end of edges
if ( !( psurf->texinfo->flags & ( SURF_TRANS66 | SURF_TRANS33 ) ) )
{
// FIXME: Fan broken in borehole
R_RecursiveClipBPoly(currententity, pbedge, topnode, psurf);
}
else
{
R_RenderBmodelFace(currententity, pbedge, psurf );
}
}
}

View File

@ -63,7 +63,7 @@ Draw_InitLocal (void)
draw_chars = RE_Draw_FindPic ("conchars");
if (!draw_chars)
{
ri.Sys_Error(ERR_FATAL, "Couldn't load pics/conchars.pcx");
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/conchars.pcx", __func__);
}
}
@ -171,7 +171,7 @@ RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic
(x + w > vid.width) ||
(y + h > vid.height))
{
ri.Sys_Error (ERR_FATAL,"Draw_Pic: bad coordinates");
ri.Sys_Error(ERR_FATAL, "%s: bad coordinates", __func__);
}
height = h;

View File

@ -97,7 +97,7 @@ R_FindFreeImage (void)
if (i == numr_images)
{
if (numr_images == MAX_RIMAGES)
ri.Sys_Error(ERR_DROP, "MAX_RIMAGES");
ri.Sys_Error(ERR_DROP, "%s: Max images", __func__);
numr_images++;
}
image = &r_images[i];
@ -124,6 +124,44 @@ R_ImageShrink(const unsigned char* src, unsigned char *dst, int width, int realw
}
}
static void
R_RestoreMips(image_t *image, int min_mips)
{
int i;
for (i=min_mips+1; i<NUM_MIPS; 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));
}
}
static size_t
R_GetImageMipsSize(size_t mip1_size)
{
size_t full_size = 0;
int i;
for (i=0; i<NUM_MIPS; i++)
{
full_size += mip1_size >> (i * 2);
}
return full_size;
}
static void
R_RestoreImagePointers(image_t *image, int min_mips)
{
int i;
for (i=min_mips+1; i<NUM_MIPS; i++)
{
image->pixels[i] = image->pixels[i - 1] + (
image->width * image->height / (1 << ((i - 1) * 2)));
}
}
/*
================
R_LoadPic
@ -138,7 +176,7 @@ R_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type)
image = R_FindFreeImage();
if (strlen(name) >= sizeof(image->name))
ri.Sys_Error(ERR_DROP, "Draw_LoadPic: \"%s\" is too long", name);
ri.Sys_Error(ERR_DROP, "%s: '%s' is too long", __func__, name);
strcpy (image->name, name);
image->registration_sequence = registration_sequence;
@ -147,7 +185,7 @@ R_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type)
image->type = type;
size = width * height;
full_size = size * (256+64+16+4)/256;
full_size = R_GetImageMipsSize(size);
image->pixels[0] = malloc(full_size);
image->transparent = false;
for (i=0 ; i<size ; i++)
@ -161,19 +199,9 @@ R_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type)
memcpy(image->pixels[0], pic, size);
// restore mips
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;
R_RestoreImagePointers(image, 0);
// 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);
R_RestoreMips(image, 0);
return image;
}
@ -188,7 +216,7 @@ R_LoadWal (char *name, imagetype_t type)
miptex_t *mt;
int ofs;
image_t *image;
int size, file_size;
size_t size, file_size;
file_size = ri.FS_LoadFile (name, (void **)&mt);
if (!mt)
@ -211,7 +239,7 @@ R_LoadWal (char *name, imagetype_t type)
image->type = type;
image->registration_sequence = registration_sequence;
ofs = LittleLong(mt->offsets[0]);
size = image->width * image->height * (256+64+16+4)/256;
size = R_GetImageMipsSize(image->width * image->height);
if ((ofs <= 0) || (image->width <= 0) || (image->height <= 0) ||
((file_size - ofs) / image->width < image->height))
@ -222,23 +250,13 @@ R_LoadWal (char *name, imagetype_t type)
}
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;
R_RestoreImagePointers(image, 0);
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);
R_RestoreMips(image, 0);
}
else
{
@ -300,8 +318,10 @@ R_LoadHiColorImage(char *name, const char* namewe, const char *ext, imagetype_t
{
if (width >= realwidth && height >= realheight)
{
// resulted image
byte* pic8 = NULL;
int size;
// resulted image memory size
size_t size8;
if (realheight == 0 || realwidth == 0)
{
@ -309,14 +329,33 @@ R_LoadHiColorImage(char *name, const char* namewe, const char *ext, imagetype_t
realwidth = width;
}
size = width * height * (256+64+16+4)/256;
pic8 = malloc(size);
R_Convert32To8bit(pic, pic8, width * height);
size8 = R_GetImageMipsSize(width * height);
pic8 = malloc(size8);
if (width != realwidth || height != realheight)
{
R_ImageShrink(pic8, pic8, width, realwidth, height, realheight);
// temporary place for shrinked image
byte* pic32 = NULL;
// temporary image memory size
size_t size32;
// resize image
size32 = width * height * 4;
pic32 = malloc(size32);
if (ResizeSTB(pic, width, height,
pic32, realwidth, realheight))
{
R_Convert32To8bit(pic32, pic8, realwidth * realheight);
image = R_LoadPic(name, pic8, realwidth, realheight, type);
}
free(pic32);
}
else
{
R_Convert32To8bit(pic, pic8, width * height);
image = R_LoadPic(name, pic8, width, height, type);
}
image = R_LoadPic(name, pic8, realwidth, realheight, type);
free(pic8);
}
}
@ -335,7 +374,7 @@ R_LoadImage(char *name, const char* namewe, const char *ext, imagetype_t type)
image_t *image = NULL;
// with retexturing and not skin
if (sw_retexturing->value && type != it_skin)
if (sw_retexturing->value)
{
image = R_LoadHiColorImage(name, namewe, ext, type);
}
@ -461,6 +500,46 @@ R_FreeUnusedImages (void)
}
}
static struct texture_buffer {
image_t image;
byte buffer[4096];
} r_notexture_buffer;
/*
==================
R_InitTextures
==================
*/
static void
R_InitTextures (void)
{
int x,y, m;
// create a simple checkerboard texture for the default
r_notexture_mip = &r_notexture_buffer.image;
r_notexture_mip->width = r_notexture_mip->height = 16;
r_notexture_mip->pixels[0] = r_notexture_buffer.buffer;
R_RestoreImagePointers(r_notexture_mip, 0);
for (m=0 ; m<NUM_MIPS ; m++)
{
byte *dest;
dest = r_notexture_mip->pixels[m];
for (y=0 ; y< (16>>m) ; y++)
for (x=0 ; x< (16>>m) ; x++)
{
if ( (y< (8>>m) ) ^ (x< (8>>m) ) )
*dest++ = 0;
else
*dest++ = 0xff;
}
}
}
/*
===============
R_InitImages
@ -477,11 +556,13 @@ R_InitImages (void)
if ( !table16to8 )
{
ri.Sys_Error(ERR_FATAL, "Couldn't load pics/16to8.dat");
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/16to8.dat", __func__);
}
d_16to8table = malloc(0x10000);
memcpy(d_16to8table, table16to8, 0x10000);
ri.FS_FreeFile((void *)table16to8);
R_InitTextures ();
}
/*

View File

@ -298,6 +298,7 @@ R_AddDynamicLights (drawsurf_t* drawsurf)
for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
{
light_t *plightdest = blocklights;
if (!(surf->dlightbits & (1<<lnum)))
continue; // not lit by this light
@ -355,17 +356,18 @@ R_AddDynamicLights (drawsurf_t* drawsurf)
if(!negativeLight)
{
if (dist < minlight)
blocklights[t*smax + s] += (rad - dist)*256;
*plightdest += (rad - dist)*256;
}
else
{
if (dist < minlight)
blocklights[t*smax + s] -= (rad - dist)*256;
if(blocklights[t*smax + s] < minlight)
blocklights[t*smax + s] = minlight;
*plightdest -= (rad - dist)*256;
if(*plightdest < minlight)
*plightdest = minlight;
}
//PGM
//====
plightdest ++;
}
}
}
@ -394,15 +396,12 @@ R_BuildLightMap (drawsurf_t* drawsurf)
if (r_fullbright->value || !r_worldmodel->lightdata)
{
for (i=0 ; i<size ; i++)
blocklights[i] = 0;
memset(blocklights, 0, size * sizeof(light_t));
return;
}
// clear to no light
for (i=0 ; i<size ; i++)
blocklights[i] = 0;
memset(blocklights, 0, size * sizeof(light_t));
// add all the lightmaps
lightmap = surf->samples;

View File

@ -190,54 +190,12 @@ zvalue_t *d_pzbuffer;
qboolean insubmodel;
static struct texture_buffer {
image_t image;
byte buffer[1024];
} r_notexture_buffer;
static void Draw_GetPalette (void);
static void RE_BeginFrame( float camera_separation );
static void Draw_BuildGammaTable(void);
static void RE_EndFrame(void);
static void R_DrawBeam(const entity_t *e);
/*
==================
R_InitTextures
==================
*/
static void
R_InitTextures (void)
{
int x,y, m;
// create a simple checkerboard texture for the default
r_notexture_mip = &r_notexture_buffer.image;
r_notexture_mip->width = r_notexture_mip->height = 16;
r_notexture_mip->pixels[0] = r_notexture_buffer.buffer;
r_notexture_mip->pixels[1] = r_notexture_mip->pixels[0] + 16*16;
r_notexture_mip->pixels[2] = r_notexture_mip->pixels[1] + 8*8;
r_notexture_mip->pixels[3] = r_notexture_mip->pixels[2] + 4*4;
for (m=0 ; m<4 ; m++)
{
byte *dest;
dest = r_notexture_mip->pixels[m];
for (y=0 ; y< (16>>m) ; y++)
for (x=0 ; x< (16>>m) ; x++)
{
if ( (y< (8>>m) ) ^ (x< (8>>m) ) )
*dest++ = 0;
else
*dest++ = 0xff;
}
}
}
/*
================
R_InitTurb
@ -332,7 +290,6 @@ RE_Init(void)
R_InitImages ();
Mod_Init ();
Draw_InitLocal ();
R_InitTextures ();
view_clipplanes[0].leftedge = true;
view_clipplanes[1].rightedge = true;
@ -421,8 +378,6 @@ R_ReallocateMapBuffers (void)
if (r_outofsurfaces)
{
//R_Printf(PRINT_ALL, "%s: not enough %d(+%d) surfaces\n",
// __func__, r_cnumsurfs, r_outofsurfaces);
r_cnumsurfs *= 2;
}
@ -457,8 +412,6 @@ R_ReallocateMapBuffers (void)
if (r_outofedges)
{
//R_Printf(PRINT_ALL, "%s: not enough %d(+%d) edges\n",
// __func__, r_numallocatededges, r_outofedges * 2 / 3);
r_numallocatededges *= 2;
}
@ -489,8 +442,6 @@ R_ReallocateMapBuffers (void)
if (r_outofverts)
{
//R_Printf(PRINT_ALL, "%s: not enough %d(+%d) finalverts\n",
// __func__, r_numallocatedverts, r_outofverts);
r_numallocatedverts *= 2;
}
@ -518,8 +469,6 @@ R_ReallocateMapBuffers (void)
if (r_outoftriangles)
{
//R_Printf(PRINT_ALL, "%s: not enough %d(+%d) triangles\n",
// __func__, r_numallocatedtriangles, r_outoftriangles);
r_numallocatedtriangles *= 2;
}
@ -685,8 +634,8 @@ R_DrawEntitiesOnList (void)
modelorg[0] = -r_origin[0];
modelorg[1] = -r_origin[1];
modelorg[2] = -r_origin[2];
VectorCopy( vec3_origin, r_entorigin );
R_DrawBeam( currententity );
VectorCopy(vec3_origin, r_entorigin);
R_DrawBeam(currententity);
}
else
{
@ -1092,7 +1041,9 @@ RE_RenderFrame (refdef_t *fd)
r_newrefdef = *fd;
if (!r_worldmodel && !( r_newrefdef.rdflags & RDF_NOWORLDMODEL ) )
ri.Sys_Error (ERR_FATAL,"R_RenderView: NULL worldmodel");
{
ri.Sys_Error(ERR_FATAL, "%s: NULL worldmodel", __func__);
}
VectorCopy (fd->vieworg, r_refdef.vieworg);
VectorCopy (fd->viewangles, r_refdef.viewangles);
@ -1120,7 +1071,7 @@ RE_RenderFrame (refdef_t *fd)
}
// Draw enemies, barrel etc...
// Use Z-Buffer in read mode only.
// Use Z-Buffer mostly in read mode only.
R_DrawEntitiesOnList ();
if (r_dspeeds->value)
@ -1244,19 +1195,21 @@ RE_BeginFrame( float camera_separation )
if ( err == rserr_invalid_mode )
{
ri.Cvar_SetValue( "r_mode", sw_state.prev_mode );
R_Printf( PRINT_ALL, "ref_soft::RE_BeginFrame() - could not set mode\n" );
R_Printf(PRINT_ALL, "%s: could not set mode", __func__);
}
else if ( err == rserr_invalid_fullscreen )
{
R_InitGraphics( vid.width, vid.height );
ri.Cvar_SetValue( "vid_fullscreen", 0);
R_Printf( PRINT_ALL, "ref_soft::RE_BeginFrame() - fullscreen unavailable in this mode\n" );
R_Printf(PRINT_ALL, "%s: fullscreen unavailable in this mode",
__func__);
sw_state.prev_mode = r_mode->value;
}
else
{
ri.Sys_Error( ERR_FATAL, "ref_soft::RE_BeginFrame() - catastrophic mode change failure\n" );
ri.Sys_Error(ERR_FATAL, "%s: Catastrophic mode change failure",
__func__);
}
}
}

View File

@ -102,7 +102,9 @@ Mod_ForName (char *name, qboolean crash)
int i, modfilelen;
if (!name[0])
ri.Sys_Error (ERR_DROP,"Mod_ForName: NULL name");
{
ri.Sys_Error(ERR_DROP, "%s: NULL name", __func__);
}
//
// inline models are grabbed only from worldmodel
@ -111,7 +113,11 @@ Mod_ForName (char *name, qboolean crash)
{
i = atoi(name+1);
if (i < 1 || !r_worldmodel || i >= r_worldmodel->numsubmodels)
ri.Sys_Error (ERR_DROP, "bad inline model number");
{
ri.Sys_Error(ERR_DROP, "%s: bad inline model number",
__func__);
}
return &mod_inline[i];
}
@ -133,7 +139,7 @@ Mod_ForName (char *name, qboolean crash)
if (i == mod_numknown)
{
if (mod_numknown == MAX_MOD_KNOWN)
ri.Sys_Error (ERR_DROP, "mod_numknown == MAX_MOD_KNOWN");
ri.Sys_Error(ERR_DROP, "mod_numknown == MAX_MOD_KNOWN");
mod_numknown++;
}
strcpy (mod->name, name);
@ -145,7 +151,11 @@ Mod_ForName (char *name, qboolean crash)
if (!buf)
{
if (crash)
ri.Sys_Error (ERR_DROP,"Mod_NumForName: %s not found", mod->name);
{
ri.Sys_Error(ERR_DROP, "%s: %s not found",
__func__, mod->name);
}
memset (mod->name, 0, sizeof(mod->name));
return NULL;
}
@ -173,7 +183,8 @@ Mod_ForName (char *name, qboolean crash)
break;
default:
ri.Sys_Error(ERR_DROP,"Mod_NumForName: unknown fileid for %s", mod->name);
ri.Sys_Error(ERR_DROP, "%s: unknown fileid for %s",
__func__, mod->name);
break;
}
@ -196,7 +207,9 @@ Mod_PointInLeaf (vec3_t p, model_t *model)
mnode_t *node;
if (!model || !model->nodes)
ri.Sys_Error (ERR_DROP, "Mod_PointInLeaf: bad model");
{
ri.Sys_Error(ERR_DROP, "%s: bad model", __func__);
}
node = model->nodes;
while (node->contents == -1)
@ -343,8 +356,13 @@ Mod_LoadVertexes (lump_t *l)
int i, count;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc((count+8)*sizeof(*out)); // extra for skybox
/*
@ -380,8 +398,13 @@ Mod_LoadSubmodels (lump_t *l)
int i, j, count;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc(count*sizeof(*out));
@ -416,7 +439,11 @@ Mod_LoadEdges (lump_t *l)
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc((count + 13) * sizeof(*out)); // extra for skybox
@ -444,8 +471,13 @@ Mod_LoadTexinfo (lump_t *l)
char name[MAX_QPATH];
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
ri.Sys_Error (ERR_DROP,"Mod_LoadTexinfo: funny lump size in %s",loadmodel->name);
{
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc((count+6)*sizeof(*out)); // extra for skybox
@ -563,7 +595,9 @@ CalcSurfaceExtents (msurface_t *s)
if (s->extents[i] < 16)
s->extents[i] = 16; // take at least one cache block
if ( !(tex->flags & (SURF_WARP|SURF_SKY)) && s->extents[i] > 256)
ri.Sys_Error (ERR_DROP,"Bad surface extents");
{
ri.Sys_Error(ERR_DROP, "%s: Bad surface extents", __func__);
}
}
}
@ -581,8 +615,13 @@ Mod_LoadFaces (lump_t *l)
int i, count, surfnum;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc((count+6)*sizeof(*out)); // extra for skybox
@ -596,7 +635,10 @@ Mod_LoadFaces (lump_t *l)
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleShort(in->numedges);
if (out->numedges < 3)
ri.Sys_Error (ERR_DROP,"Surface with %d edges", out->numedges);
{
ri.Sys_Error(ERR_DROP, "%s: Surface with %d edges",
__func__, out->numedges);
}
out->flags = 0;
planenum = LittleShort(in->planenum);
@ -688,8 +730,13 @@ Mod_LoadNodes (lump_t *l)
mnode_t *out;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc(count*sizeof(*out));
@ -739,8 +786,13 @@ Mod_LoadLeafs (lump_t *l)
int i, j, count;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc(count*sizeof(*out));
@ -768,7 +820,8 @@ Mod_LoadLeafs (lump_t *l)
out->firstmarksurface = loadmodel->marksurfaces + firstleafface;
if ((firstleafface + out->nummarksurfaces) > loadmodel->nummarksurfaces)
{
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: wrong marksurfaces position in %s",loadmodel->name);
ri.Sys_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
__func__, loadmodel->name);
}
}
}
@ -787,8 +840,13 @@ Mod_LoadMarksurfaces (lump_t *l)
msurface_t **out;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc(count*sizeof(*out));
@ -800,7 +858,9 @@ Mod_LoadMarksurfaces (lump_t *l)
int j;
j = LittleShort(in[i]);
if (j >= loadmodel->numsurfaces)
ri.Sys_Error (ERR_DROP,"Mod_ParseMarksurfaces: bad surface number");
{
ri.Sys_Error(ERR_DROP, "%s: bad surface number", __func__);
}
out[i] = loadmodel->surfaces + j;
}
}
@ -817,8 +877,13 @@ Mod_LoadSurfedges (lump_t *l)
int *in, *out;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc((count+24)*sizeof(*out)); // extra for skybox
@ -843,8 +908,13 @@ Mod_LoadPlanes (lump_t *l)
int count;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
{
ri.Sys_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, loadmodel->name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc((count+6)*sizeof(*out)); // extra for skybox
@ -894,13 +964,16 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
loadmodel->type = mod_brush;
if (loadmodel != mod_known)
ri.Sys_Error (ERR_DROP, "Loaded a brush model after the world");
ri.Sys_Error(ERR_DROP, "Loaded a brush model after the world");
header = (dheader_t *)buffer;
i = LittleLong (header->version);
if (i != BSPVERSION)
ri.Sys_Error (ERR_DROP,"Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
{
ri.Sys_Error(ERR_DROP, "%s: %s has wrong version number (%i should be %i)",
__func__, mod->name, i, BSPVERSION);
}
// swap all the lumps
mod_base = (byte *)header;
@ -940,7 +1013,10 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
starmod->nummodelsurfaces = bm->numfaces;
starmod->firstnode = bm->headnode;
if (starmod->firstnode >= loadmodel->numnodes)
ri.Sys_Error (ERR_DROP, "Inline model %i has bad firstnode", i);
{
ri.Sys_Error(ERR_DROP, "%s: Inline model %i has bad firstnode",
__func__, i);
}
VectorCopy (bm->maxs, starmod->maxs);
VectorCopy (bm->mins, starmod->mins);
@ -980,13 +1056,17 @@ Mod_LoadAliasModel(model_t *mod, void *buffer, int modfilelen)
version = LittleLong (pinmodel->version);
if (version != ALIAS_VERSION)
ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
mod->name, version, ALIAS_VERSION);
{
ri.Sys_Error(ERR_DROP, "%s: %s has wrong version number (%i should be %i)",
__func__, mod->name, version, ALIAS_VERSION);
}
ofs_end = LittleLong(pinmodel->ofs_end);
if (ofs_end < 0 || ofs_end > modfilelen)
ri.Sys_Error (ERR_DROP, "model %s file size(%d) too small, should be %d", mod->name,
modfilelen, ofs_end);
{
ri.Sys_Error(ERR_DROP, "%s: model %s file size(%d) too small, should be %d", mod->name,
__func__, modfilelen, ofs_end);
}
mod->extradata = Hunk_Begin(modfilelen);
pheader = Hunk_Alloc(ofs_end);
@ -996,23 +1076,40 @@ Mod_LoadAliasModel(model_t *mod, void *buffer, int modfilelen)
((int *)pheader)[i] = LittleLong (((int *)buffer)[i]);
if (pheader->skinheight > MAX_LBM_HEIGHT)
ri.Sys_Error (ERR_DROP, "model %s has a skin taller than %d", mod->name,
MAX_LBM_HEIGHT);
{
ri.Sys_Error(ERR_DROP, "%s: model %s has a skin taller than %d", mod->name,
__func__, MAX_LBM_HEIGHT);
}
if (pheader->num_xyz <= 0)
ri.Sys_Error (ERR_DROP, "model %s has no vertices", mod->name);
{
ri.Sys_Error(ERR_DROP, "%s: model %s has no vertices",
__func__, mod->name);
}
if (pheader->num_xyz > MAX_VERTS)
ri.Sys_Error (ERR_DROP, "model %s has too many vertices", mod->name);
{
ri.Sys_Error(ERR_DROP, "%s: model %s has too many vertices",
__func__, mod->name);
}
if (pheader->num_st <= 0)
ri.Sys_Error (ERR_DROP, "model %s has no st vertices", mod->name);
{
ri.Sys_Error(ERR_DROP, "%s: model %s has no st vertices",
__func__, mod->name);
}
if (pheader->num_tris <= 0)
ri.Sys_Error (ERR_DROP, "model %s has no triangles", mod->name);
{
ri.Sys_Error(ERR_DROP, "%s: model %s has no triangles",
__func__, mod->name);
}
if (pheader->num_frames <= 0)
ri.Sys_Error (ERR_DROP, "model %s has no frames", mod->name);
{
ri.Sys_Error(ERR_DROP, "%s: model %s has no frames",
__func__, mod->name);
}
//
// load base s and t vertices (not used in gl version)
@ -1113,12 +1210,16 @@ Mod_LoadSpriteModel(model_t *mod, void *buffer, int modfilelen)
sprout->numframes = LittleLong (sprin->numframes);
if (sprout->version != SPRITE_VERSION)
ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
mod->name, sprout->version, SPRITE_VERSION);
{
ri.Sys_Error(ERR_DROP, "%s: %s has wrong version number (%i should be %i)",
__func__, mod->name, sprout->version, SPRITE_VERSION);
}
if (sprout->numframes > MAX_MD2SKINS)
ri.Sys_Error (ERR_DROP, "%s has too many frames (%i > %i)",
mod->name, sprout->numframes, MAX_MD2SKINS);
{
ri.Sys_Error(ERR_DROP, "%s: %s has too many frames (%i > %i)",
__func__, mod->name, sprout->numframes, MAX_MD2SKINS);
}
// byte swap everything
for (i=0 ; i<sprout->numframes ; i++)

View File

@ -983,7 +983,9 @@ R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured )
if (nump < 3)
return;
if (nump > MAXWORKINGVERTS)
ri.Sys_Error(ERR_DROP, "R_ClipAndDrawPoly: too many points: %d", nump );
{
ri.Sys_Error(ERR_DROP, "%s: too many points: %d", __func__, nump);
}
}
// transform vertices into viewspace and project

View File

@ -17,12 +17,11 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// d_polyset.c: routines for drawing sets of polygons sharing the same
// sw_polyset.c: routines for drawing sets of polygons sharing the same
// texture (used for Alias models)
#include "header/local.h"
#define MASK_1K 0x3FF
#include <limits.h>
typedef struct {
int isflattop;
@ -77,15 +76,6 @@ static int d_lightbasestep, d_ptexbasestep;
static int d_sfracbasestep, d_tfracbasestep;
static zvalue_t d_ziextrastep, d_zibasestep;
typedef struct {
int quotient;
int remainder;
} adivtab_t;
static adivtab_t adivtab[32*32] = {
#include "../constants/adivtab.h"
};
static byte *skintable[MAX_LBM_HEIGHT];
int skinwidth;
static byte *skinstart;
@ -359,33 +349,16 @@ static void
R_PolysetSetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv,
fixed8_t endvertu, fixed8_t endvertv)
{
int tm, tn;
adivtab_t *ptemp;
float tm, tn;
errorterm = -1;
tm = endvertu - startvertu;
tn = endvertv - startvertv;
if (((tm <= 16) && (tm >= -15)) &&
((tn <= 16) && (tn >= -15)))
{
ptemp = &adivtab[((tm+15) << 5) + (tn+15)];
ubasestep = ptemp->quotient;
erroradjustup = ptemp->remainder;
erroradjustdown = tn;
}
else
{
float dm, dn;
FloorDivMod (tm, tn, &ubasestep, &erroradjustup);
dm = tm;
dn = tn;
FloorDivMod (dm, dn, &ubasestep, &erroradjustup);
erroradjustdown = dn;
}
erroradjustdown = tn;
}
@ -481,7 +454,7 @@ R_PolysetDrawSpans8_33(const entity_t *currententity, spanpackage_t *pspanpackag
errorterm -= erroradjustdown;
}
if (lcount)
if (lcount > 0)
{
int pos_shift = (pspanpackage->v * vid.width) + pspanpackage->u;
@ -519,7 +492,7 @@ R_PolysetDrawSpans8_33(const entity_t *currententity, spanpackage_t *pspanpackag
}
pspanpackage++;
} while (pspanpackage->count != -999999);
} while ((pspanpackage < triangles_max) && (pspanpackage->count != INT_MIN));
}
void
@ -545,7 +518,7 @@ R_PolysetDrawSpansConstant8_33(const entity_t *currententity, spanpackage_t *psp
errorterm -= erroradjustdown;
}
if (lcount)
if (lcount > 0)
{
int pos_shift = (pspanpackage->v * vid.width) + pspanpackage->u;
@ -566,7 +539,7 @@ R_PolysetDrawSpansConstant8_33(const entity_t *currententity, spanpackage_t *psp
}
pspanpackage++;
} while (pspanpackage->count != -999999);
} while ((pspanpackage < triangles_max) && (pspanpackage->count != INT_MIN));
}
void
@ -595,7 +568,7 @@ R_PolysetDrawSpans8_66(const entity_t *currententity, spanpackage_t *pspanpackag
errorterm -= erroradjustdown;
}
if (lcount)
if (lcount > 0)
{
int pos_shift = (pspanpackage->v * vid.width) + pspanpackage->u;
@ -634,7 +607,7 @@ R_PolysetDrawSpans8_66(const entity_t *currententity, spanpackage_t *pspanpackag
}
pspanpackage++;
} while (pspanpackage->count != -999999);
} while ((pspanpackage < triangles_max) && (pspanpackage->count != INT_MIN));
}
void
@ -660,7 +633,7 @@ R_PolysetDrawSpansConstant8_66(const entity_t *currententity, spanpackage_t *psp
errorterm -= erroradjustdown;
}
if (lcount)
if (lcount > 0)
{
int pos_shift = (pspanpackage->v * vid.width) + pspanpackage->u;
@ -681,7 +654,7 @@ R_PolysetDrawSpansConstant8_66(const entity_t *currententity, spanpackage_t *psp
}
pspanpackage++;
} while (pspanpackage->count != -999999);
} while ((pspanpackage < triangles_max) && (pspanpackage->count != INT_MIN));
}
void
@ -702,7 +675,7 @@ R_PolysetDrawSpans8_Opaque (const entity_t *currententity, spanpackage_t *pspanp
errorterm -= erroradjustdown;
}
if (lcount)
if (lcount > 0)
{
int lsfrac, ltfrac;
pixel_t *lpdest;
@ -752,7 +725,7 @@ R_PolysetDrawSpans8_Opaque (const entity_t *currententity, spanpackage_t *pspanp
}
pspanpackage++;
} while (pspanpackage->count != -999999);
} while ((pspanpackage < triangles_max) && (pspanpackage->count != INT_MIN));
}
/*
@ -922,7 +895,7 @@ R_RasterizeAliasPolySmooth(const entity_t *currententity)
return;
}
originalcount = triangle_spans[initialrightheight].count;
triangle_spans[initialrightheight].count = -999999; // mark end of the spanpackages
triangle_spans[initialrightheight].count = INT_MIN; // mark end of the spanpackages
(*d_pdrawspans) (currententity, triangle_spans);
// scan out the bottom part of the right edge, if it exists
@ -950,7 +923,7 @@ R_RasterizeAliasPolySmooth(const entity_t *currententity)
r_outoftriangles++;
return;
}
triangle_spans[initialrightheight + height].count = -999999; // mark end of the spanpackages
triangle_spans[initialrightheight + height].count = INT_MIN; // mark end of the spanpackages
(*d_pdrawspans) (currententity, pstart);
}
}

View File

@ -21,21 +21,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "header/local.h"
static int lightleft, sourcetstep;
static int lightright, lightleftstep, lightrightstep, blockdivshift;
static int sourcetstep;
static void *prowdestbase;
static unsigned char *pbasesource;
static int r_stepback;
static int r_lightwidth;
static int r_numhblocks, r_numvblocks;
static int r_numvblocks;
static unsigned char *r_source, *r_sourcemax;
static unsigned *r_lightptr;
void R_BuildLightMap (drawsurf_t *drawsurf);
extern unsigned blocklights[1024]; // allow some very large lightmaps
static float surfscale;
static int sc_size;
static surfcache_t *sc_rover;
surfcache_t *sc_base;
@ -55,6 +52,9 @@ R_TextureAnimation (const entity_t *currententity, mtexinfo_t *tex)
if (!tex->next)
return tex->image;
if (!currententity)
return tex->image;
c = currententity->frame % tex->numframes;
while (c)
{
@ -83,7 +83,9 @@ R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes)
for (v=0 ; v<r_numvblocks ; v++)
{
// FIXME: make these locals?
int lightleft, lightright;
int lightleftstep, lightrightstep;
// FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
@ -133,6 +135,8 @@ R_DrawSurface (drawsurf_t *drawsurf)
int blocksize;
unsigned char *pcolumndest;
image_t *mt;
int blockdivshift;
int r_numhblocks;
mt = drawsurf->image;
@ -269,16 +273,22 @@ D_SCAlloc (int width, int size)
surfcache_t *new;
if ((width < 0) || (width > 256))
ri.Sys_Error (ERR_FATAL,"D_SCAlloc: bad cache width %d\n", width);
{
ri.Sys_Error(ERR_FATAL, "%s: bad cache width %d\n", __func__, width);
}
if ((size <= 0) || (size > 0x10000))
ri.Sys_Error (ERR_FATAL,"D_SCAlloc: bad cache size %d\n", size);
{
ri.Sys_Error(ERR_FATAL, "%s: bad cache size %d\n", __func__, size);
}
// Add header size
size += ((char*)sc_base->data - (char*)sc_base);
size = (size + 3) & ~3;
if (size > sc_size)
ri.Sys_Error (ERR_FATAL,"D_SCAlloc: %i > cache size of %i",size, sc_size);
{
ri.Sys_Error(ERR_FATAL, "%s: %i > cache size of %i", __func__, size, sc_size);
}
// if there is not size bytes after the rover, reset to the start
if ( !sc_rover || (byte *)sc_rover - (byte *)sc_base > sc_size - size)
@ -296,7 +306,9 @@ D_SCAlloc (int width, int size)
// free another
sc_rover = sc_rover->next;
if (!sc_rover)
ri.Sys_Error (ERR_FATAL,"D_SCAlloc: hit the end of memory");
{
ri.Sys_Error(ERR_FATAL, "%s: hit the end of memory", __func__);
}
if (sc_rover->owner)
*sc_rover->owner = NULL;
@ -341,6 +353,7 @@ surfcache_t *
D_CacheSurface (const entity_t *currententity, msurface_t *surface, int miplevel)
{
surfcache_t *cache;
float surfscale;
//
// if the surface is animating or flashing, flush the cache