From 2f2890cd1107e7ff21b0dc742cbd554a77d81b00 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 25 Jan 2024 05:50:11 +0300 Subject: [PATCH] engine: client: use PARM_TEX_FILTERING to figure out whether we should apply half-texel trick to HUD textures when scaling --- engine/client/cl_game.c | 30 +++++++++++++++++------------- engine/client/client.h | 1 - 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index f8413b5d..53368b67 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -357,20 +357,23 @@ void SPR_AdjustSize( float *x, float *y, float *w, float *h ) *h *= yscale; } -void SPR_AdjustTexCoords( float width, float height, float *s1, float *t1, float *s2, float *t2 ) +static void SPR_AdjustTexCoords( int texnum, float width, float height, float *s1, float *t1, float *s2, float *t2 ) { - if( refState.width != clgame.scrInfo.iWidth ) + if( REF_GET_PARM( PARM_TEX_FILTERING, texnum )) { - // align to texel if scaling - *s1 += 0.5f; - *s2 -= 0.5f; - } + if( refState.width != clgame.scrInfo.iWidth ) + { + // align to texel if scaling + *s1 += 0.5f; + *s2 -= 0.5f; + } - if( refState.height != clgame.scrInfo.iHeight ) - { - // align to texel if scaling - *t1 += 0.5f; - *t2 -= 0.5f; + if( refState.height != clgame.scrInfo.iHeight ) + { + // align to texel if scaling + *t1 += 0.5f; + *t2 -= 0.5f; + } } *s1 /= width; @@ -402,6 +405,8 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei height = h; } + texnum = ref.dllFuncs.R_GetSpriteTexture( clgame.ds.pSprite, frame ); + if( prc ) { wrect_t rc = *prc; @@ -418,7 +423,7 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei t2 = rc.bottom; // calc user-defined rectangle - SPR_AdjustTexCoords( width, height, &s1, &t1, &s2, &t2 ); + SPR_AdjustTexCoords( texnum, width, height, &s1, &t1, &s2, &t2 ); width = rc.right - rc.left; height = rc.bottom - rc.top; } @@ -434,7 +439,6 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei // scale for screen sizes SPR_AdjustSize( &x, &y, &width, &height ); - texnum = ref.dllFuncs.R_GetSpriteTexture( clgame.ds.pSprite, frame ); ref.dllFuncs.Color4ub( clgame.ds.spriteColor[0], clgame.ds.spriteColor[1], clgame.ds.spriteColor[2], clgame.ds.spriteColor[3] ); ref.dllFuncs.R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, texnum ); } diff --git a/engine/client/client.h b/engine/client/client.h index 40b58ff9..c8d514a8 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -846,7 +846,6 @@ model_t *CL_LoadClientSprite( const char *filename ); model_t *CL_LoadModel( const char *modelname, int *index ); HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags ); void SPR_AdjustSize( float *x, float *y, float *w, float *h ); -void SPR_AdjustTexCoords( float width, float height, float *s1, float *t1, float *s2, float *t2 ); int CL_GetScreenInfo( SCREENINFO *pscrinfo ); void CL_FillRGBA( int x, int y, int width, int height, int r, int g, int b, int a ); pmtrace_t *PM_CL_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe );