From aaade648b99d5390894eb7308b37a23aad40395d Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Thu, 6 Feb 2020 22:13:45 +0200 Subject: [PATCH 1/2] Replace *_ResampleTexture to ResizeSTB --- src/client/refresh/gl1/gl1_image.c | 51 ++------------------------- src/client/refresh/gl1/header/local.h | 3 -- 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/src/client/refresh/gl1/gl1_image.c b/src/client/refresh/gl1/gl1_image.c index f5a23fa8..835dacb1 100644 --- a/src/client/refresh/gl1/gl1_image.c +++ b/src/client/refresh/gl1/gl1_image.c @@ -409,53 +409,6 @@ R_FloodFillSkin(byte *skin, int skinwidth, int skinheight) } } -void -R_ResampleTexture(unsigned *in, int inwidth, int inheight, - unsigned *out, int outwidth, int outheight) -{ - int i, j; - unsigned *inrow, *inrow2; - unsigned frac, fracstep; - unsigned p1[1024], p2[1024]; - byte *pix1, *pix2, *pix3, *pix4; - - fracstep = inwidth * 0x10000 / outwidth; - - frac = fracstep >> 2; - - for (i = 0; i < outwidth; i++) - { - p1[i] = 4 * (frac >> 16); - frac += fracstep; - } - - frac = 3 * (fracstep >> 2); - - for (i = 0; i < outwidth; i++) - { - p2[i] = 4 * (frac >> 16); - frac += fracstep; - } - - for (i = 0; i < outheight; i++, out += outwidth) - { - inrow = in + inwidth * (int)((i + 0.25) * inheight / outheight); - inrow2 = in + inwidth * (int)((i + 0.75) * inheight / outheight); - - for (j = 0; j < outwidth; j++) - { - pix1 = (byte *)inrow + p1[j]; - pix2 = (byte *)inrow + p2[j]; - pix3 = (byte *)inrow2 + p1[j]; - pix4 = (byte *)inrow2 + p2[j]; - ((byte *)(out + j))[0] = (pix1[0] + pix2[0] + pix3[0] + pix4[0]) >> 2; - ((byte *)(out + j))[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1]) >> 2; - ((byte *)(out + j))[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2]) >> 2; - ((byte *)(out + j))[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3]) >> 2; - } - } -} - /* * Scale up the pixel values in a * texture to increase the @@ -702,8 +655,8 @@ R_Upload32Soft(unsigned *data, int width, int height, qboolean mipmap) } else { - R_ResampleTexture(data, width, height, scaled, - scaled_width, scaled_height); + ResizeSTB((byte *)data, width, height, + (byte *)scaled, scaled_width, scaled_height); } R_LightScaleTexture(scaled, scaled_width, scaled_height, !mipmap); diff --git a/src/client/refresh/gl1/header/local.h b/src/client/refresh/gl1/header/local.h index b0d5ee32..533097e2 100644 --- a/src/client/refresh/gl1/header/local.h +++ b/src/client/refresh/gl1/header/local.h @@ -282,9 +282,6 @@ void R_SwapBuffers(int); int Draw_GetPalette(void); -void R_ResampleTexture(unsigned *in, int inwidth, int inheight, - unsigned *out, int outwidth, int outheight); - image_t *R_LoadPic(char *name, byte *pic, int width, int realwidth, int height, int realheight, imagetype_t type, int bits); image_t *R_FindImage(char *name, imagetype_t type); From b3c23dee5bdb48bc46fb8b407523c7cc37ba230c Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 23 Feb 2020 08:19:02 +0200 Subject: [PATCH 2/2] make cppcheck happy and use same version messages as other renders --- src/client/refresh/soft/header/local.h | 2 +- src/client/refresh/soft/sw_main.c | 9 +++++---- src/client/refresh/soft/sw_model.c | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/client/refresh/soft/header/local.h b/src/client/refresh/soft/header/local.h index 1f2b6e93..8265cf85 100644 --- a/src/client/refresh/soft/header/local.h +++ b/src/client/refresh/soft/header/local.h @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#define REF_VERSION "SOFT 0.01" +#define REF_VERSION "Yamagi Quake II Software Refresher" // up / down #define PITCH 0 diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index f81d6262..90625cf0 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -423,6 +423,9 @@ R_Init static qboolean RE_Init(void) { + R_Printf(PRINT_ALL, "Refresh: " REF_VERSION "\n"); + R_Printf(PRINT_ALL, "Client: " YQ2VERSION "\n\n"); + R_RegisterVariables (); R_InitImages (); Mod_Init (); @@ -455,8 +458,6 @@ RE_Init(void) // create the window ri.Vid_MenuInit(); - R_Printf(PRINT_ALL, "ref_soft version: "REF_VERSION"\n"); - return true; } @@ -1480,7 +1481,7 @@ RE_SetMode(void) vid_fullscreen->modified = false; R_Printf(PRINT_ALL, "%s() - fullscreen unavailable in this mode\n", __func__); - if ((err = SWimp_SetMode(&vid.width, &vid.height, r_mode->value, 0)) == rserr_ok) + if ((SWimp_SetMode(&vid.width, &vid.height, r_mode->value, 0)) == rserr_ok) { return true; } @@ -1501,7 +1502,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; diff --git a/src/client/refresh/soft/sw_model.c b/src/client/refresh/soft/sw_model.c index 7489153c..c887147e 100644 --- a/src/client/refresh/soft/sw_model.c +++ b/src/client/refresh/soft/sw_model.c @@ -140,7 +140,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, "%s: mod_numknown == MAX_MOD_KNOWN", __func__); mod_numknown++; } strcpy (mod->name, name); @@ -962,7 +962,7 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen) dmodel_t *bm; if (loadmodel != mod_known) - ri.Sys_Error(ERR_DROP, "Loaded a brush model after the world"); + ri.Sys_Error(ERR_DROP, "%s: Loaded a brush model after the world", __func__); header = (dheader_t *)buffer;