From 600d574376e92a0b58d010b5f8d60cd592b196ac Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 29 Jan 2024 05:50:59 +0300 Subject: [PATCH] ref: gl: make use of new TF_ALLOW_NEAREST_TOGGLE flag --- engine/ref_api.h | 4 ++-- ref/gl/gl_image.c | 4 +--- ref/gl/gl_local.h | 1 - ref/gl/gl_warp.c | 24 +----------------------- 4 files changed, 4 insertions(+), 29 deletions(-) diff --git a/engine/ref_api.h b/engine/ref_api.h index 58525887..5cb1d474 100644 --- a/engine/ref_api.h +++ b/engine/ref_api.h @@ -46,8 +46,8 @@ GNU General Public License for more details. #define REF_API_VERSION 7 -#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP) -#define TF_FONT (TF_NOMIPMAP|TF_CLAMP) +#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP|TF_ALLOW_NEAREST_TOGGLE) +#define TF_FONT (TF_NOMIPMAP|TF_CLAMP|TF_ALLOW_NEAREST_TOGGLE) #define TF_IMAGE (TF_NOMIPMAP|TF_CLAMP) #define TF_DECAL (TF_CLAMP) diff --git a/ref/gl/gl_image.c b/ref/gl/gl_image.c index af8fa612..6bae8a33 100644 --- a/ref/gl/gl_image.c +++ b/ref/gl/gl_image.c @@ -131,7 +131,7 @@ qboolean GL_TextureFilteringEnabled( const gl_texture_t *tex ) if( FBitSet( tex->flags, TF_ATLAS_PAGE )) return gl_lightmap_nearest.value == 0.0f; - if( FBitSet( tex->flags, TF_SKYSIDE )) + if( FBitSet( tex->flags, TF_ALLOW_NEAREST_TOGGLE )) return gl_texture_nearest.value == 0.0f; return true; @@ -329,8 +329,6 @@ void R_SetTextureParameters( void ) // change all the existing mipmapped texture objects for( i = 0; i < gl_numTextures; i++ ) GL_UpdateTextureParams( i ); - - R_UpdateRippleTexParams(); } /* diff --git a/ref/gl/gl_local.h b/ref/gl/gl_local.h index be29b8db..627ea8c7 100644 --- a/ref/gl/gl_local.h +++ b/ref/gl/gl_local.h @@ -496,7 +496,6 @@ void EmitWaterPolys( msurface_t *warp, qboolean reverse ); void R_InitRipples( void ); void R_ResetRipples( void ); void R_AnimateRipples( void ); -void R_UpdateRippleTexParams( void ); void R_UploadRipples( texture_t *image ); // diff --git a/ref/gl/gl_warp.c b/ref/gl/gl_warp.c index 479b7c0c..e2daa154 100644 --- a/ref/gl/gl_warp.c +++ b/ref/gl/gl_warp.c @@ -882,11 +882,7 @@ void R_InitRipples( void ) pic.numMips = 1; memset( pic.buffer, 0, pic.size ); - g_ripple.rippletexturenum = GL_LoadTextureInternal( "*rippletex", &pic, TF_NOMIPMAP ); - - // need to set proper tex params for TF_NOMIPMAP texture, - // as during upload it fails TF_NEAREST check and gets blurry even with gl_texture_nearest 1 - R_UpdateRippleTexParams(); + g_ripple.rippletexturenum = GL_LoadTextureInternal( "*rippletex", &pic, TF_NOMIPMAP|TF_ALLOW_NEAREST_TOGGLE ); } static void R_SwapBufs( void ) @@ -967,24 +963,6 @@ void R_AnimateRipples( void ) R_RunRipplesAnimation( g_ripple.oldbuf, g_ripple.curbuf ); } -void R_UpdateRippleTexParams( void ) -{ - gl_texture_t *tex = R_GetTexture( g_ripple.rippletexturenum ); - - GL_Bind( XASH_TEXTURE0, g_ripple.rippletexturenum ); - - if( gl_texture_nearest.value ) - { - pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - } - else - { - pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - } -} - void R_UploadRipples( texture_t *image ) { gl_texture_t *glt;