Browse Source

engine: client: use PARM_TEX_FILTERING to figure out whether we should apply half-texel trick to HUD textures when scaling

master
Alibek Omarov 5 months ago
parent
commit
2f2890cd11
  1. 30
      engine/client/cl_game.c
  2. 1
      engine/client/client.h

30
engine/client/cl_game.c

@ -357,20 +357,23 @@ void SPR_AdjustSize( float *x, float *y, float *w, float *h ) @@ -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 @@ -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 @@ -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 @@ -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 );
}

1
engine/client/client.h

@ -846,7 +846,6 @@ model_t *CL_LoadClientSprite( const char *filename ); @@ -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 );

Loading…
Cancel
Save