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 8 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 )
*h *= yscale; *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 if( refState.width != clgame.scrInfo.iWidth )
*s1 += 0.5f; {
*s2 -= 0.5f; // align to texel if scaling
} *s1 += 0.5f;
*s2 -= 0.5f;
}
if( refState.height != clgame.scrInfo.iHeight ) if( refState.height != clgame.scrInfo.iHeight )
{ {
// align to texel if scaling // align to texel if scaling
*t1 += 0.5f; *t1 += 0.5f;
*t2 -= 0.5f; *t2 -= 0.5f;
}
} }
*s1 /= width; *s1 /= width;
@ -402,6 +405,8 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
height = h; height = h;
} }
texnum = ref.dllFuncs.R_GetSpriteTexture( clgame.ds.pSprite, frame );
if( prc ) if( prc )
{ {
wrect_t rc = *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; t2 = rc.bottom;
// calc user-defined rectangle // 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; width = rc.right - rc.left;
height = rc.bottom - rc.top; 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 // scale for screen sizes
SPR_AdjustSize( &x, &y, &width, &height ); 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.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 ); 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 );
model_t *CL_LoadModel( const char *modelname, int *index ); model_t *CL_LoadModel( const char *modelname, int *index );
HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags ); HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags );
void SPR_AdjustSize( float *x, float *y, float *w, float *h ); 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 ); int CL_GetScreenInfo( SCREENINFO *pscrinfo );
void CL_FillRGBA( int x, int y, int width, int height, int r, int g, int b, int a ); 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 ); pmtrace_t *PM_CL_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe );

Loading…
Cancel
Save