gl1: cppcheck fixes

This commit is contained in:
Denis Pauk 2024-03-09 00:05:13 +02:00
parent aea0a9085f
commit 03c39f34ae
21 changed files with 308 additions and 210 deletions

View file

@ -119,7 +119,7 @@ RDraw_FindPic(const char *name)
void
RDraw_GetPicSize(int *w, int *h, const char *pic)
{
image_t *gl;
const image_t *gl;
gl = R_FindPic(pic, (findimage_t)R_FindImage);
@ -231,7 +231,7 @@ RDraw_PicScaled(int x, int y, const char *pic, float factor)
void
RDraw_TileClear(int x, int y, int w, int h, const char *pic)
{
image_t *image;
const image_t *image;
image = R_FindPic(pic, (findimage_t)R_FindImage);
@ -396,8 +396,6 @@ RDraw_StretchRaw(int x, int y, int w, int h, int cols, int rows, const byte *dat
if (!gl_config.palettedtexture || bits == 32)
{
unsigned image32[320*240]; /* was 256 * 256, but we want a bit more space */
/* .. because now if non-power-of-2 textures are supported, we just load
* the data into a texture in the original format, without skipping any
* pixels to fit into a 256x256 texture.
@ -411,6 +409,7 @@ RDraw_StretchRaw(int x, int y, int w, int h, int cols, int rows, const byte *dat
}
else if(gl_config.npottextures || rows <= 256)
{
unsigned image32[320*240]; /* was 256 * 256, but we want a bit more space */
unsigned* img = image32;
if(cols*rows > 320*240)
@ -442,11 +441,11 @@ RDraw_StretchRaw(int x, int y, int w, int h, int cols, int rows, const byte *dat
else
{
unsigned int image32[320*240];
unsigned *dest;
for (i = 0; i < trows; i++)
{
const byte *source;
unsigned *dest;
row = (int)(i * hscale);
@ -475,10 +474,10 @@ RDraw_StretchRaw(int x, int y, int w, int h, int cols, int rows, const byte *dat
else
{
unsigned char image8[256 * 256];
unsigned char *dest;
for (i = 0; i < trows; i++)
{
unsigned char *dest;
const byte *source;
row = (int)(i * hscale);

View file

@ -125,13 +125,13 @@ int upload_width, upload_height;
qboolean uploaded_paletted;
void
R_SetTexturePalette(unsigned palette[256])
R_SetTexturePalette(const unsigned palette[256])
{
int i;
unsigned char temptable[768];
if (gl_config.palettedtexture)
{
unsigned char temptable[768];
int i;
for (i = 0; i < 256; i++)
{
temptable[i * 3 + 0] = (palette[i] >> 0) & 0xff;
@ -176,7 +176,7 @@ R_Bind(int texnum)
}
void
R_TextureMode(char *string)
R_TextureMode(const char *string)
{
int i;
image_t *glt;
@ -263,7 +263,7 @@ R_TextureMode(char *string)
}
void
R_TextureAlphaMode(char *string)
R_TextureAlphaMode(const char *string)
{
int i;
@ -285,7 +285,7 @@ R_TextureAlphaMode(char *string)
}
void
R_TextureSolidMode(char *string)
R_TextureSolidMode(const char *string)
{
int i;
@ -859,7 +859,6 @@ R_LoadPic(const char *name, byte *pic, int width, int realwidth,
int height, int realheight, size_t data_size, imagetype_t type, int bits)
{
image_t *image;
int i;
qboolean nolerp = false;
if (r_2D_unfiltered->value && type == it_pic)
@ -875,35 +874,39 @@ R_LoadPic(const char *name, byte *pic, int width, int realwidth,
nolerp = strstr(r_nolerp_list->string, name) != NULL;
}
/* find a free image_t */
for (i = 0, image = gltextures; i < numgltextures; i++, image++)
{
if (!image->texnum)
int i;
/* find a free image_t */
for (i = 0, image = gltextures; i < numgltextures; i++, image++)
{
break;
if (!image->texnum)
{
break;
}
if (!strcmp(image->name, name))
{
/* we already have such image */
image->registration_sequence = registration_sequence;
return image;
}
}
if (!strcmp(image->name, name))
if (i == numgltextures)
{
/* we already have such image */
image->registration_sequence = registration_sequence;
return image;
if (numgltextures == MAX_TEXTURES)
{
Com_Error(ERR_DROP, "%s: load %s is failed MAX_TEXTURES",
__func__, name);
}
numgltextures++;
}
image = &gltextures[i];
}
if (i == numgltextures)
{
if (numgltextures == MAX_TEXTURES)
{
Com_Error(ERR_DROP, "%s: load %s is failed MAX_TEXTURES",
__func__, name);
}
numgltextures++;
}
image = &gltextures[i];
if (strlen(name) >= sizeof(image->name))
{
Com_Error(ERR_DROP, "%s: \"%s\" is too long", __func__, name);
@ -926,7 +929,7 @@ R_LoadPic(const char *name, byte *pic, int width, int realwidth,
(image->width < 64) && (image->height < 64))
{
int x, y;
int i, j, k;
int i, k;
int texnum;
texnum = Scrap_AllocBlock(image->width, image->height, &x, &y);
@ -943,6 +946,8 @@ R_LoadPic(const char *name, byte *pic, int width, int realwidth,
for (i = 0; i < image->height; i++)
{
int j;
for (j = 0; j < image->width; j++, k++)
{
scrap_texels[texnum][(y + i) * BLOCK_WIDTH + x + j] = pic[k];
@ -1104,7 +1109,7 @@ R_FindImage(const char *name, imagetype_t type)
}
struct image_s *
RI_RegisterSkin(char *name)
RI_RegisterSkin(const char *name)
{
return R_FindImage(name, it_skin);
}
@ -1177,7 +1182,7 @@ R_ImageHasFreeSpace(void)
void
R_InitImages(void)
{
int i, j;
int i;
registration_sequence = 1;
image_max = 0;
@ -1199,6 +1204,8 @@ R_InitImages(void)
for (i = 0; i < 256; i++)
{
int j;
j = i * intensity->value;
if (j > 255)

View file

@ -33,7 +33,6 @@ static void
R_RenderDlight(dlight_t *light)
{
int i, j;
float a;
float rad;
rad = light->intensity * 0.35;
@ -59,6 +58,8 @@ R_RenderDlight(dlight_t *light)
for ( i = 16; i >= 0; i-- )
{
float a;
clr[index_clr++] = 0;
clr[index_clr++] = 0;
clr[index_clr++] = 0;

View file

@ -136,9 +136,9 @@ LM_AllocBlock(int w, int h, int *x, int *y)
void
LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa)
{
int i, lnumverts;
medge_t *pedges, *r_pedge;
float *vec;
int i, lnumverts;
const float *vec;
mpoly_t *poly;
vec3_t total;
vec3_t normal;

View file

@ -156,12 +156,12 @@ R_RotateForEntity(entity_t *e)
static void
R_DrawSpriteModel(entity_t *currententity, const model_t *currentmodel)
{
const dsprframe_t *frame;
const image_t *skin;
dsprite_t *psprite;
float alpha = 1.0F;
vec3_t point[4];
dsprframe_t *frame;
float *up, *right;
dsprite_t *psprite;
image_t *skin;
/* don't even bother culling, because it's just
a single polygon without a surface cache */
@ -414,7 +414,6 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
const particle_t *p;
int i;
vec3_t up, right;
float scale;
YQ2_ALIGNAS_TYPE(unsigned) byte color[4];
YQ2_VLA(GLfloat, vtx, 3 * num_particles * 3);
@ -436,6 +435,8 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
for ( p = particles, i = 0; i < num_particles; i++, p++ )
{
float scale;
/* hack a scale up to keep particles from disapearing */
scale = ( p->origin [ 0 ] - r_origin [ 0 ] ) * vpn [ 0 ] +
( p->origin [ 1 ] - r_origin [ 1 ] ) * vpn [ 1 ] +
@ -625,8 +626,8 @@ R_PolyBlend(void)
static void
R_SetupFrame(void)
{
const mleaf_t *leaf;
int i;
mleaf_t *leaf;
r_framecount++;
@ -917,7 +918,7 @@ R_SetGL2D(void)
* r_newrefdef must be set before the first call
*/
static void
R_RenderView(refdef_t *fd)
R_RenderView(const refdef_t *fd)
{
if ((gl_state.stereo_mode != STEREO_MODE_NONE) && gl_state.camera_separation) {
@ -930,10 +931,10 @@ R_RenderView(refdef_t *fd)
int anaglyph_colours[] = { 0x4, 0x3 }; // Left = red, right = cyan.
if (strlen(gl1_stereo_anaglyph_colors->string) == 2) {
int eye, colour, missing_bits;
int eye, missing_bits;
// Decode the colour name from its character.
for (eye = 0; eye < 2; ++eye) {
colour = 0;
int colour = 0;
switch (toupper((unsigned char)gl1_stereo_anaglyph_colors->string[eye])) {
case 'B': ++colour; // 001 Blue
case 'G': ++colour; // 010 Green
@ -1118,7 +1119,7 @@ GL_GetSpecialBufferModeForStereoMode(enum stereo_modes stereo_mode) {
}
static void
R_SetLightLevel(entity_t *currententity)
R_SetLightLevel(const entity_t *currententity)
{
vec3_t shadelight = {0};
@ -1162,7 +1163,7 @@ static void
RI_RenderFrame(refdef_t *fd)
{
R_RenderView(fd);
R_SetLightLevel (NULL);
R_SetLightLevel(NULL);
R_SetGL2D();
}
@ -1373,7 +1374,7 @@ R_SetMode(void)
ri.Cvar_SetValue("r_msaa_samples", 0.0f);
gl_msaa_samples->modified = false;
if ((err = SetMode_impl(&vid.width, &vid.height, r_mode->value, 0)) == rserr_ok)
if (SetMode_impl(&vid.width, &vid.height, r_mode->value, 0) == rserr_ok)
{
return true;
}
@ -1389,7 +1390,7 @@ R_SetMode(void)
}
/* try setting it back to something safe */
if ((err = SetMode_impl(&vid.width, &vid.height, gl_state.prev_mode, 0)) != rserr_ok)
if (SetMode_impl(&vid.width, &vid.height, gl_state.prev_mode, 0) != rserr_ok)
{
R_Printf(PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n");
return false;
@ -1821,7 +1822,6 @@ R_DrawBeam(entity_t *e)
GLfloat vtx[3*NUM_BEAM_SEGS*4];
unsigned int index_vtx = 0;
unsigned int pointb;
oldorigin[0] = e->oldorigin[0];
oldorigin[1] = e->oldorigin[1];
@ -1867,6 +1867,8 @@ R_DrawBeam(entity_t *e)
for ( i = 0; i < NUM_BEAM_SEGS; i++ )
{
unsigned int pointb;
vtx[index_vtx++] = start_points [ i ][ 0 ];
vtx[index_vtx++] = start_points [ i ][ 1 ];
vtx[index_vtx++] = start_points [ i ][ 2 ];
@ -1897,22 +1899,6 @@ R_DrawBeam(entity_t *e)
glDepthMask(GL_TRUE);
}
extern int RI_PrepareForWindow(void);
extern int RI_InitContext(void* win);
extern void RI_BeginRegistration(const char *model);
extern struct model_s * RI_RegisterModel(const char *name);
extern struct image_s * RI_RegisterSkin(const char *name);
extern void RI_SetSky(const char *name, float rotate, int autorotate, const vec3_t axis);
extern void RI_EndRegistration(void);
extern void RI_RenderFrame(refdef_t *fd);
extern void RI_SetPalette(const unsigned char *palette);
extern qboolean RI_IsVSyncActive(void);
extern void RI_EndFrame(void);
/*
=====================
RI_EndWorldRenderpass
@ -1927,52 +1913,50 @@ RI_EndWorldRenderpass( void )
Q2_DLL_EXPORTED refexport_t
GetRefAPI(refimport_t imp)
{
refexport_t re = {0};
refexport_t refexport = {0};
ri = imp;
re.api_version = API_VERSION;
refexport.api_version = API_VERSION;
re.Init = RI_Init;
re.Shutdown = RI_Shutdown;
re.PrepareForWindow = RI_PrepareForWindow;
re.InitContext = RI_InitContext;
re.GetDrawableSize = RI_GetDrawableSize;
re.ShutdownContext = RI_ShutdownContext;
re.IsVSyncActive = RI_IsVSyncActive;
re.BeginRegistration = RI_BeginRegistration;
re.RegisterModel = RI_RegisterModel;
re.RegisterSkin = RI_RegisterSkin;
refexport.Init = RI_Init;
refexport.Shutdown = RI_Shutdown;
refexport.PrepareForWindow = RI_PrepareForWindow;
refexport.InitContext = RI_InitContext;
refexport.GetDrawableSize = RI_GetDrawableSize;
refexport.ShutdownContext = RI_ShutdownContext;
refexport.IsVSyncActive = RI_IsVSyncActive;
refexport.BeginRegistration = RI_BeginRegistration;
refexport.RegisterModel = RI_RegisterModel;
refexport.RegisterSkin = RI_RegisterSkin;
re.SetSky = RI_SetSky;
re.EndRegistration = RI_EndRegistration;
refexport.SetSky = RI_SetSky;
refexport.EndRegistration = RI_EndRegistration;
re.RenderFrame = RI_RenderFrame;
refexport.RenderFrame = RI_RenderFrame;
re.DrawFindPic = RDraw_FindPic;
refexport.DrawFindPic = RDraw_FindPic;
re.DrawGetPicSize = RDraw_GetPicSize;
//re.DrawPic = Draw_Pic;
re.DrawPicScaled = RDraw_PicScaled;
re.DrawStretchPic = RDraw_StretchPic;
//re.DrawChar = Draw_Char;
re.DrawCharScaled = RDraw_CharScaled;
re.DrawTileClear = RDraw_TileClear;
re.DrawFill = RDraw_Fill;
re.DrawFadeScreen = RDraw_FadeScreen;
refexport.DrawGetPicSize = RDraw_GetPicSize;
refexport.DrawPicScaled = RDraw_PicScaled;
refexport.DrawStretchPic = RDraw_StretchPic;
refexport.DrawCharScaled = RDraw_CharScaled;
refexport.DrawTileClear = RDraw_TileClear;
refexport.DrawFill = RDraw_Fill;
refexport.DrawFadeScreen = RDraw_FadeScreen;
re.DrawStretchRaw = RDraw_StretchRaw;
refexport.DrawStretchRaw = RDraw_StretchRaw;
re.SetPalette = RI_SetPalette;
re.BeginFrame = RI_BeginFrame;
re.EndWorldRenderpass = RI_EndWorldRenderpass;
re.EndFrame = RI_EndFrame;
refexport.SetPalette = RI_SetPalette;
refexport.BeginFrame = RI_BeginFrame;
refexport.EndWorldRenderpass = RI_EndWorldRenderpass;
refexport.EndFrame = RI_EndFrame;
// Tell the client that we're unsing the
// new renderer restart API.
ri.Vid_RequestRestart(RESTART_NO);
return re;
return refexport;
}
void R_Printf(int level, const char* msg, ...)

View file

@ -39,7 +39,7 @@ float shadelight[3];
float *shadedots = r_avertexnormal_dots[0];
static void
R_DrawAliasDrawCommands(entity_t *currententity, int *order, int *order_end,
R_DrawAliasDrawCommands(const entity_t *currententity, int *order, const int *order_end,
float alpha, dxtrivertx_t *verts, vec4_t *s_lerped)
{
#ifdef _MSC_VER // workaround for lack of VLAs (=> our workaround uses alloca() which is bad in loops)
@ -96,13 +96,12 @@ R_DrawAliasDrawCommands(entity_t *currententity, int *order, int *order_end,
YQ2_VLA(GLfloat, clr, 4*total);
#endif
unsigned int index_vtx = 0;
unsigned int index_tex = 0;
unsigned int index_clr = 0;
if (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE))
{
unsigned int index_vtx = 0;
unsigned int index_clr = 0;
do
{
int index_xyz;
@ -123,6 +122,10 @@ R_DrawAliasDrawCommands(entity_t *currententity, int *order, int *order_end,
}
else
{
unsigned int index_vtx = 0;
unsigned int index_tex = 0;
unsigned int index_clr = 0;
do
{
int index_xyz;
@ -177,7 +180,8 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp,
vec4_t *s_lerped)
{
daliasxframe_t *frame, *oldframe;
dxtrivertx_t *ov, *verts;
const dxtrivertx_t *ov;
dxtrivertx_t *verts;
int *order;
float frontlerp;
float alpha;
@ -258,7 +262,7 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp,
}
static void
R_DrawAliasShadowCommand(entity_t *currententity, int *order, int *order_end,
R_DrawAliasShadowCommand(const entity_t *currententity, int *order, const int *order_end,
float height, float lheight, vec4_t *s_lerped)
{
unsigned short total;
@ -417,7 +421,7 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
dmdx_t *paliashdr;
float an;
vec3_t bbox[8];
image_t *skin = NULL;
const image_t *skin = NULL;
vec4_t *s_lerped;
if (!(currententity->flags & RF_WEAPONMODEL))

View file

@ -28,11 +28,10 @@
static YQ2_ALIGNAS_TYPE(int) byte mod_novis[MAX_MAP_LEAFS / 8];
static model_t mod_known[MAX_MOD_KNOWN];
static int mod_numknown = 0;
static int mod_max = 0;
int registration_sequence;
static model_t mod_known[MAX_MOD_KNOWN];
static int mod_numknown = 0;
static int mod_max = 0;
int registration_sequence;
//===============================================================================
@ -184,7 +183,7 @@ static int
calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
{
dface_t* face_in = (void *)(mod_base + fl->fileofs);
texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
const texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
{
@ -260,7 +259,7 @@ static int
calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
{
dqface_t* face_in = (void *)(mod_base + fl->fileofs);
texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
const texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
{
@ -336,7 +335,7 @@ static void
Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
const bspx_header_t *bspx_header)
{
int i, count, surfnum, lminfosize, lightofs;
int i, count, surfnum, lminfosize;
const dlminfo_t *lminfos;
msurface_t *out;
dface_t *in;
@ -366,7 +365,7 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum;
int side, ti, planenum, lightofs;
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleShort(in->numedges);
@ -462,7 +461,7 @@ static void
Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
const bspx_header_t *bspx_header)
{
int i, count, surfnum, lminfosize, lightofs;
int i, count, surfnum, lminfosize;
const dlminfo_t *lminfos;
msurface_t *out;
dqface_t *in;
@ -492,7 +491,7 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum;
int side, ti, planenum, lightofs;
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleLong(in->numedges);
@ -809,6 +808,11 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
__func__, mod->name);
}
if (r_validation->value > 0)
{
R_Printf(PRINT_ALL, "%s: Can't load %s\n", __func__, mod->name);
}
memset(mod->name, 0, sizeof(mod->name));
return NULL;
}
@ -856,7 +860,14 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
}
mod->radius = Mod_RadiusFromBounds(mod->mins, mod->maxs);
mod->extradatasize = Hunk_End();
if (mod->extradata)
{
mod->extradatasize = Hunk_End();
}
else
{
mod->extradatasize = 0;
}
ri.FS_FreeFile(buf);
@ -866,6 +877,18 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
static void
Mod_Free(model_t *mod)
{
if (!mod->extradata)
{
/* looks as empty model */
memset (mod, 0, sizeof(*mod));
return;
}
if (r_validation->value > 0)
{
R_Printf(PRINT_ALL, "%s: Unload %s\n", __func__, mod->name);
}
Hunk_Free(mod->extradata);
memset(mod, 0, sizeof(*mod));
}
@ -891,7 +914,7 @@ void
RI_BeginRegistration(const char *model)
{
char fullname[MAX_QPATH];
cvar_t *flushmap;
const cvar_t *flushmap;
registration_sequence++;
r_oldviewcluster = -1; /* force markleafs */

View file

@ -42,16 +42,18 @@ qboolean R_Upload8(byte *data,
int
Scrap_AllocBlock(int w, int h, int *x, int *y)
{
int i, j;
int best, best2;
int texnum;
for (texnum = 0; texnum < MAX_SCRAPS; texnum++)
{
int best, i;
best = BLOCK_HEIGHT;
for (i = 0; i < BLOCK_WIDTH - w; i++)
{
int best2, j;
best2 = 0;
for (j = 0; j < w; j++)

View file

@ -91,11 +91,11 @@ int RI_PrepareForWindow(void)
gl_state.stencil = false;
}
// Let's see if the driver supports MSAA.
int msaa_samples = 0;
if (gl_msaa_samples->value)
{
/* Let's see if the driver supports MSAA. */
int msaa_samples;
msaa_samples = gl_msaa_samples->value;
if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1) < 0)

View file

@ -228,7 +228,7 @@ static void
R_BlendLightmaps(const model_t *currentmodel)
{
int i;
msurface_t *surf, *newdrawsurf = 0;
msurface_t *surf;
/* don't bother if we're set to fullbright */
if (r_fullbright->value)
@ -299,6 +299,8 @@ R_BlendLightmaps(const model_t *currentmodel)
/* render dynamic lightmaps */
if (r_dynamic->value)
{
msurface_t *newdrawsurf;
LM_InitBlock();
R_Bind(gl_state.lightmap_textures + 0);
@ -411,11 +413,11 @@ R_BlendLightmaps(const model_t *currentmodel)
}
static void
R_RenderBrushPoly(entity_t *currententity, msurface_t *fa)
R_RenderBrushPoly(const entity_t *currententity, msurface_t *fa)
{
int maps;
image_t *image;
qboolean is_dynamic = false;
const image_t *image;
int maps;
c_brush_polys++;
@ -599,7 +601,7 @@ R_DrawAlphaSurfaces(void)
}
static void
R_DrawTextureChains(entity_t *currententity)
R_DrawTextureChains(const entity_t *currententity)
{
int i;
msurface_t *s;
@ -635,7 +637,7 @@ R_DrawTextureChains(entity_t *currententity)
}
static void
R_DrawInlineBModel(entity_t *currententity, const model_t *currentmodel)
R_DrawInlineBModel(const entity_t *currententity, const model_t *currentmodel)
{
int i;
msurface_t *psurf;

View file

@ -38,8 +38,6 @@ static const int skytexorder[6] = {0, 2, 1, 3, 4, 5};
GLfloat vtx_sky[12];
GLfloat tex_sky[8];
unsigned int index_vtx = 0;
unsigned int index_tex = 0;
/* 3dstudio environment map names */
static const char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
@ -146,7 +144,7 @@ RE_ClearSkyBox(void)
}
static void
RE_MakeSkyVec(float s, float t, int axis)
RE_MakeSkyVec(float s, float t, int axis, unsigned int *index_tex, unsigned int *index_vtx)
{
vec3_t v, b;
int j;
@ -197,12 +195,12 @@ RE_MakeSkyVec(float s, float t, int axis)
t = 1.0 - t;
tex_sky[index_tex++] = s;
tex_sky[index_tex++] = t;
tex_sky[(*index_tex)++] = s;
tex_sky[(*index_tex)++] = t;
vtx_sky[index_vtx++] = v[ 0 ];
vtx_sky[index_vtx++] = v[ 1 ];
vtx_sky[index_vtx++] = v[ 2 ];
vtx_sky[(*index_vtx)++] = v[ 0 ];
vtx_sky[(*index_vtx)++] = v[ 1 ];
vtx_sky[(*index_vtx)++] = v[ 2 ];
}
void
@ -234,6 +232,8 @@ R_DrawSkyBox(void)
for (i = 0; i < 6; i++)
{
unsigned int index_vtx = 0, index_tex = 0;
if (skyrotate)
{
skymins[0][i] = -1;
@ -253,20 +253,17 @@ R_DrawSkyBox(void)
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
index_vtx = 0;
index_tex = 0;
RE_MakeSkyVec( skymins [ 0 ] [ i ], skymins [ 1 ] [ i ], i );
RE_MakeSkyVec( skymins [ 0 ] [ i ], skymaxs [ 1 ] [ i ], i );
RE_MakeSkyVec( skymaxs [ 0 ] [ i ], skymaxs [ 1 ] [ i ], i );
RE_MakeSkyVec( skymaxs [ 0 ] [ i ], skymins [ 1 ] [ i ], i );
RE_MakeSkyVec(skymins[ 0 ][ i ], skymins[ 1 ] [ i ], i, &index_tex, &index_vtx);
RE_MakeSkyVec(skymins[ 0 ][ i ], skymaxs[ 1 ] [ i ], i, &index_tex, &index_vtx);
RE_MakeSkyVec(skymaxs[ 0 ][ i ], skymaxs[ 1 ] [ i ], i, &index_tex, &index_vtx);
RE_MakeSkyVec(skymaxs[ 0 ][ i ], skymins[ 1 ] [ i ], i, &index_tex, &index_vtx);
glVertexPointer( 3, GL_FLOAT, 0, vtx_sky );
glTexCoordPointer( 2, GL_FLOAT, 0, tex_sky );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
}
glPopMatrix();

View file

@ -262,10 +262,10 @@ void R_SwapBuffers(int);
image_t *R_LoadPic(const char *name, byte *pic, int width, int realwidth,
int height, int realheight, size_t data_size, imagetype_t type, int bits);
image_t *R_FindImage(const char *name, imagetype_t type);
void R_TextureMode(char *string);
void R_TextureMode(const char *string);
void R_ImageList_f(void);
void R_SetTexturePalette(unsigned palette[256]);
void R_SetTexturePalette(const unsigned palette[256]);
void R_InitImages(void);
void R_ShutdownImages(void);
@ -273,8 +273,8 @@ void R_ShutdownImages(void);
void R_FreeUnusedImages(void);
qboolean R_ImageHasFreeSpace(void);
void R_TextureAlphaMode(char *string);
void R_TextureSolidMode(char *string);
void R_TextureAlphaMode(const char *string);
void R_TextureSolidMode(const char *string);
int Scrap_AllocBlock(int w, int h, int *x, int *y);
#ifdef DEBUG
@ -436,4 +436,15 @@ extern void RDraw_Fill(int x, int y, int w, int h, int c);
extern void RDraw_FadeScreen(void);
extern void RDraw_StretchRaw(int x, int y, int w, int h, int cols, int rows, const byte *data, int bits);
/* public interface funtions */
extern int RI_PrepareForWindow(void);
extern int RI_InitContext(void* win);
extern void RI_BeginRegistration(const char *model);
extern struct model_s * RI_RegisterModel(const char *name);
extern struct image_s * RI_RegisterSkin(const char *name);
extern void RI_SetSky(const char *name, float rotate, int autorotate, const vec3_t axis);
extern void RI_EndRegistration(void);
extern qboolean RI_IsVSyncActive(void);
extern void RI_EndFrame(void);
#endif

View file

@ -29,11 +29,10 @@
static YQ2_ALIGNAS_TYPE(int) byte mod_novis[MAX_MAP_LEAFS / 8];
static gl3model_t mod_known[MAX_MOD_KNOWN];
static int mod_numknown;
static int mod_max = 0;
int registration_sequence;
static gl3model_t mod_known[MAX_MOD_KNOWN];
static int mod_numknown = 0;
static int mod_max = 0;
int registration_sequence;
//===============================================================================
@ -64,7 +63,7 @@ Mod_HasFreeSpace(void)
return (mod_numknown + mod_max) < MAX_MOD_KNOWN;
}
const byte*
const byte *
GL3_Mod_ClusterPVS(int cluster, const gl3model_t *model)
{
if ((cluster == -1) || !model->vis)
@ -185,7 +184,7 @@ static int
calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
{
dface_t* face_in = (void *)(mod_base + fl->fileofs);
texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
const texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
{
@ -261,7 +260,7 @@ static int
calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
{
dqface_t* face_in = (void *)(mod_base + fl->fileofs);
texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
const texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
{
@ -337,7 +336,7 @@ static void
Mod_LoadFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
const bspx_header_t *bspx_header)
{
int i, count, surfnum, lminfosize, lightofs;
int i, count, surfnum, lminfosize;
const dlminfo_t *lminfos;
msurface_t *out;
dface_t *in;
@ -367,7 +366,7 @@ Mod_LoadFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum;
int side, ti, planenum, lightofs;
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleShort(in->numedges);
@ -463,7 +462,7 @@ static void
Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
const bspx_header_t *bspx_header)
{
int i, count, surfnum, lminfosize, lightofs;
int i, count, surfnum, lminfosize;
const dlminfo_t *lminfos;
msurface_t *out;
dqface_t *in;
@ -493,7 +492,7 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum;
int side, ti, planenum, lightofs;
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleLong(in->numedges);
@ -810,6 +809,11 @@ Mod_ForName(const char *name, gl3model_t *parent_model, qboolean crash)
__func__, mod->name);
}
if (r_validation->value > 0)
{
R_Printf(PRINT_ALL, "%s: Can't load %s\n", __func__, mod->name);
}
memset(mod->name, 0, sizeof(mod->name));
return NULL;
}
@ -857,7 +861,14 @@ Mod_ForName(const char *name, gl3model_t *parent_model, qboolean crash)
}
mod->radius = Mod_RadiusFromBounds(mod->mins, mod->maxs);
mod->extradatasize = Hunk_End();
if (mod->extradata)
{
mod->extradatasize = Hunk_End();
}
else
{
mod->extradatasize = 0;
}
ri.FS_FreeFile(buf);
@ -867,6 +878,18 @@ Mod_ForName(const char *name, gl3model_t *parent_model, qboolean crash)
static void
Mod_Free(gl3model_t *mod)
{
if (!mod->extradata)
{
/* looks as empty model */
memset (mod, 0, sizeof(*mod));
return;
}
if (r_validation->value > 0)
{
R_Printf(PRINT_ALL, "%s: Unload %s\n", __func__, mod->name);
}
Hunk_Free(mod->extradata);
memset(mod, 0, sizeof(*mod));
}
@ -892,7 +915,7 @@ void
GL3_BeginRegistration(const char *model)
{
char fullname[MAX_QPATH];
cvar_t *flushmap;
const cvar_t *flushmap;
registration_sequence++;
gl3_oldviewcluster = -1; /* force markleafs */

View file

@ -28,8 +28,9 @@
#include "header/local.h"
YQ2_ALIGNAS_TYPE(int) static byte mod_novis[MAX_MAP_LEAFS / 8];
static gl4model_t mod_known[MAX_MOD_KNOWN];
static int mod_numknown;
static int mod_numknown = 0;
static int mod_max = 0;
int registration_sequence;
@ -62,7 +63,7 @@ Mod_HasFreeSpace(void)
return (mod_numknown + mod_max) < MAX_MOD_KNOWN;
}
const byte*
const byte *
GL4_Mod_ClusterPVS(int cluster, const gl4model_t *model)
{
if ((cluster == -1) || !model->vis)
@ -183,7 +184,7 @@ static int
calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
{
dface_t* face_in = (void *)(mod_base + fl->fileofs);
texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
const texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
{
@ -259,7 +260,7 @@ static int
calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
{
dqface_t* face_in = (void *)(mod_base + fl->fileofs);
texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
const texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
{
@ -335,7 +336,7 @@ static void
Mod_LoadFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
const bspx_header_t *bspx_header)
{
int i, count, surfnum, lminfosize, lightofs;
int i, count, surfnum, lminfosize;
const dlminfo_t *lminfos;
msurface_t *out;
dface_t *in;
@ -365,7 +366,7 @@ Mod_LoadFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum;
int side, ti, planenum, lightofs;
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleShort(in->numedges);
@ -461,7 +462,7 @@ static void
Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
const bspx_header_t *bspx_header)
{
int i, count, surfnum, lminfosize, lightofs;
int i, count, surfnum, lminfosize;
const dlminfo_t *lminfos;
msurface_t *out;
dqface_t *in;
@ -491,7 +492,7 @@ Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum;
int side, ti, planenum, lightofs;
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleLong(in->numedges);
@ -808,6 +809,11 @@ Mod_ForName(const char *name, gl4model_t *parent_model, qboolean crash)
__func__, mod->name);
}
if (r_validation->value > 0)
{
R_Printf(PRINT_ALL, "%s: Can't load %s\n", __func__, mod->name);
}
memset(mod->name, 0, sizeof(mod->name));
return NULL;
}
@ -855,7 +861,14 @@ Mod_ForName(const char *name, gl4model_t *parent_model, qboolean crash)
}
mod->radius = Mod_RadiusFromBounds(mod->mins, mod->maxs);
mod->extradatasize = Hunk_End();
if (mod->extradata)
{
mod->extradatasize = Hunk_End();
}
else
{
mod->extradatasize = 0;
}
ri.FS_FreeFile(buf);
@ -865,6 +878,18 @@ Mod_ForName(const char *name, gl4model_t *parent_model, qboolean crash)
static void
Mod_Free(gl4model_t *mod)
{
if (!mod->extradata)
{
/* looks as empty model */
memset (mod, 0, sizeof(*mod));
return;
}
if (r_validation->value > 0)
{
R_Printf(PRINT_ALL, "%s: Unload %s\n", __func__, mod->name);
}
Hunk_Free(mod->extradata);
memset(mod, 0, sizeof(*mod));
}
@ -890,7 +915,7 @@ void
GL4_BeginRegistration(const char *model)
{
char fullname[MAX_QPATH];
cvar_t *flushmap;
const cvar_t *flushmap;
registration_sequence++;
gl4_oldviewcluster = -1; /* force markleafs */

View file

@ -135,7 +135,6 @@ const byte *Mod_ClusterPVS(int cluster, const model_t *model);
void Mod_Modellist_f(void);
void Mod_FreeAll(void);
void Mod_Free(model_t *mod);
extern int registration_sequence;

View file

@ -33,7 +33,7 @@
static YQ2_ALIGNAS_TYPE(int) byte mod_novis[MAX_MAP_LEAFS / 8];
static model_t mod_known[MAX_MOD_KNOWN];
static int mod_numknown;
static int mod_numknown = 0;
static int mod_max = 0;
int registration_sequence;
@ -129,7 +129,7 @@ static void
Mod_LoadSubmodels(model_t *loadmodel, const byte *mod_base, const lump_t *l)
{
dmodel_t *in;
model_t *out;
model_t *out;
int i, j, count;
in = (void *)(mod_base + l->fileofs);
@ -633,6 +633,11 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
__func__, mod->name);
}
if (r_validation->value > 0)
{
R_Printf(PRINT_ALL, "%s: Can't load %s\n", __func__, mod->name);
}
memset(mod->name, 0, sizeof(mod->name));
return NULL;
}
@ -680,16 +685,35 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
}
mod->radius = Mod_RadiusFromBounds(mod->mins, mod->maxs);
mod->extradatasize = Hunk_End();
if (mod->extradata)
{
mod->extradatasize = Hunk_End();
}
else
{
mod->extradatasize = 0;
}
ri.FS_FreeFile(buf);
return mod;
}
void
static void
Mod_Free(model_t *mod)
{
if (!mod->extradata)
{
/* looks as empty model */
memset (mod, 0, sizeof(*mod));
return;
}
if (r_validation->value > 0)
{
R_Printf(PRINT_ALL, "%s: Unload %s\n", __func__, mod->name);
}
Hunk_Free(mod->extradata);
memset(mod, 0, sizeof(*mod));
}
@ -715,7 +739,7 @@ void
RE_BeginRegistration(const char *model)
{
char fullname[MAX_QPATH];
cvar_t *flushmap;
const cvar_t *flushmap;
registration_sequence++;
r_oldviewcluster = -1; /* force markleafs */

View file

@ -192,7 +192,7 @@ void R_RotateForEntity(entity_t *e, float *mvMatrix);
void R_MarkLeaves(void);
void EmitWaterPolys(msurface_t *fa, image_t *texture,
float *modelMatrix, const float *color,
const float *modelMatrix, const float *color,
qboolean solid_surface);
void RE_AddSkySurface(msurface_t *fa);
void RE_ClearSkyBox(void);

View file

@ -56,8 +56,8 @@ VkResult buffer_create(BufferResource_t *buf,
VkResult buffer_destroy(BufferResource_t *buf);
void buffer_unmap(BufferResource_t *buf);
void *buffer_map(BufferResource_t *buf);
VkResult buffer_flush(BufferResource_t *buf);
VkResult buffer_invalidate(BufferResource_t *buf);
VkResult buffer_flush(const BufferResource_t *buf);
VkResult buffer_invalidate(const BufferResource_t *buf);
VkResult image_create(ImageResource_t *img,
VkImageCreateInfo img_create_info,

View file

@ -30,12 +30,11 @@
static YQ2_ALIGNAS_TYPE(int) byte mod_novis[MAX_MAP_LEAFS / 8];
static model_t *models_known;
static int mod_numknown = 0;
static int mod_max = 0;
static int mod_loaded = 0;
static int mod_numknown = 0;
static int mod_max = 0;
static int mod_loaded = 0;
static int models_known_max = 0;
int registration_sequence;
int registration_sequence;
const byte *
Mod_ClusterPVS(int cluster, const model_t *model)
@ -100,7 +99,7 @@ static void
Mod_LoadSubmodels(model_t *loadmodel, const byte *mod_base, const lump_t *l)
{
dmodel_t *in;
model_t *out;
model_t *out;
int i, j, count;
in = (void *)(mod_base + l->fileofs);
@ -159,7 +158,7 @@ static int
calcTexinfoAndFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
{
dface_t* face_in = (void *)(mod_base + fl->fileofs);
texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
const texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
{
@ -235,7 +234,7 @@ static int
calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
{
dqface_t* face_in = (void *)(mod_base + fl->fileofs);
texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
const texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
{
@ -311,7 +310,7 @@ static void
Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
const bspx_header_t *bspx_header)
{
int i, count, surfnum, lminfosize, lightofs;
int i, count, surfnum, lminfosize;
const dlminfo_t *lminfos;
msurface_t *out;
dface_t *in;
@ -341,7 +340,7 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum;
int side, ti, planenum, lightofs;
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleShort(in->numedges);
@ -407,7 +406,7 @@ Mod_LoadFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
}
R_SubdivideSurface(loadmodel->surfedges, loadmodel->vertexes,
loadmodel->edges, out); // cut up polygon for warps
loadmodel->edges, out); /* cut up polygon for warps */
}
if (r_fixsurfsky->value)
@ -437,7 +436,7 @@ static void
Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
const bspx_header_t *bspx_header)
{
int i, count, surfnum, lminfosize, lightofs;
int i, count, surfnum, lminfosize;
const dlminfo_t *lminfos;
msurface_t *out;
dqface_t *in;
@ -467,7 +466,7 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
{
int side, ti, planenum;
int side, ti, planenum, lightofs;
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleLong(in->numedges);
@ -774,7 +773,7 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
strcpy(mod->name, name);
/* load the file */
modfilelen = Mod_LoadFile (mod->name, &buf);
modfilelen = Mod_LoadFile(mod->name, &buf);
if (!buf)
{
@ -793,16 +792,14 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
return NULL;
}
// update count of loaded models
/* update count of loaded models */
mod_loaded ++;
if (r_validation->value > 0)
{
R_Printf(PRINT_ALL, "%s: Load %s[%d]\n", __func__, mod->name, mod_loaded);
}
//
// fill it in
//
/* fill it in */
/* call the apropriate loader */
switch (LittleLong(*(unsigned *)buf))
@ -866,7 +863,7 @@ Mod_Free(model_t *mod)
{
if (!mod->extradata)
{
// looks as empty model
/* looks as empty model */
memset (mod, 0, sizeof(*mod));
return;
}
@ -913,7 +910,7 @@ void
RE_BeginRegistration(const char *model)
{
char fullname[MAX_QPATH];
cvar_t *flushmap;
const cvar_t *flushmap;
Mod_Reallocate();
@ -999,7 +996,7 @@ Mod_HasFreeSpace(void)
}
void
Mod_Modellist_f (void)
Mod_Modellist_f(void)
{
int i, total, used;
model_t *mod;

View file

@ -665,7 +665,7 @@ image_destroy(ImageResource_t *img)
}
VkResult
buffer_flush(BufferResource_t *buf)
buffer_flush(const BufferResource_t *buf)
{
VkResult result = VK_SUCCESS;
@ -680,7 +680,7 @@ buffer_flush(BufferResource_t *buf)
}
VkResult
buffer_invalidate(BufferResource_t *buf)
buffer_invalidate(const BufferResource_t *buf)
{
VkResult result = VK_SUCCESS;

View file

@ -46,7 +46,7 @@ static float sky_min, sky_max;
* Does a water warp on the pre-fragmented mpoly_t chain
*/
void
EmitWaterPolys(msurface_t *fa, image_t *texture, float *modelMatrix,
EmitWaterPolys(msurface_t *fa, image_t *texture, const float *modelMatrix,
const float *color, qboolean solid_surface)
{
mpoly_t *p, *bp;