From ab15662d78a248d8a22711efa155ac169aa2b89d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 29 Jan 2024 05:48:08 +0300 Subject: [PATCH] ref: gl: fix toggling nearest filter on TF_NOMIPMAP textures --- ref/gl/gl_image.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/ref/gl/gl_image.c b/ref/gl/gl_image.c index 4777f732..af8fa612 100644 --- a/ref/gl/gl_image.c +++ b/ref/gl/gl_image.c @@ -282,30 +282,16 @@ static void GL_UpdateTextureParams( int iTexture ) if( GL_Support( GL_TEXTURE_LOD_BIAS ) && ( tex->numMips > 1 ) && !FBitSet( tex->flags, TF_DEPTHMAP )) pglTexParameterf( tex->target, GL_TEXTURE_LOD_BIAS_EXT, gl_texture_lodbias.value ); - if( IsLightMap( tex )) - { - if( gl_lightmap_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 ); - } - } - - if( tex->numMips <= 1 ) return; + nomipmap = tex->numMips <= 1 || FBitSet( tex->flags, TF_NOMIPMAP|TF_DEPTHMAP ); - if( FBitSet( tex->flags, TF_NEAREST ) || gl_texture_nearest.value ) + if( !GL_TextureFilteringEnabled( tex )) { - pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); + pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, nomipmap ? GL_NEAREST : GL_NEAREST_MIPMAP_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); } else { - pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); + pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, nomipmap ? GL_LINEAR : GL_LINEAR_MIPMAP_LINEAR ); pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); } }