From 28f9fcebb4f521b6bd0e6a4bfd934ab1c97b8559 Mon Sep 17 00:00:00 2001 From: pogokeen Date: Fri, 16 Feb 2018 06:38:05 +0000 Subject: [PATCH] Polymost: Avoid generation of mipmaps if filter mode isn't set to use them git-svn-id: https://svn.eduke32.com/eduke32@6654 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/polymost.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index be6bbdb7d..f2e2b811d 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -966,6 +966,14 @@ void uploadtexture(int32_t doalloc, vec2_t siz, int32_t texfmt, if (hi && !nodownsize && r_downsize > miplevel) miplevel = r_downsize; + // don't use mipmaps if mipmapping is disabled + if (glfiltermodes[gltexfiltermode].min == GL_NEAREST || + glfiltermodes[gltexfiltermode].min == GL_LINEAR) + { + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); + } + if (!miplevel) Polymost_SendTexToDriver(doalloc, siz, texfmt, pic, intexfmt, @@ -974,6 +982,13 @@ void uploadtexture(int32_t doalloc, vec2_t siz, int32_t texfmt, texcompress_ok, #endif 0); + + // don't generate mipmaps if we're not going to use them + if (glfiltermodes[gltexfiltermode].min == GL_NEAREST || + glfiltermodes[gltexfiltermode].min == GL_LINEAR) + { + return; + } vec2_t siz2 = siz; @@ -6182,7 +6197,7 @@ void polymost_initosdfuncs(void) { "r_anisotropy", "changes the OpenGL texture anisotropy setting", (void *) &glanisotropy, CVAR_INT|CVAR_FUNCPTR, 0, 16 }, { "r_texturemaxsize","changes the maximum OpenGL texture size limit",(void *) &gltexmaxsize, CVAR_INT | CVAR_NOSAVE, 0, 4096 }, { "r_texturemiplevel","changes the highest OpenGL mipmap level used",(void *) &gltexmiplevel, CVAR_INT, 0, 6 }, - { "r_texfilter", "changes the texture filtering settings", (void *) &gltexfiltermode, CVAR_INT|CVAR_FUNCPTR, 0, 5 }, + { "r_texfilter", "changes the texture filtering settings (may require restart)", (void *) &gltexfiltermode, CVAR_INT|CVAR_FUNCPTR, 0, 5 }, { "r_usenewshading", "visibility/fog code: 0: orig. Polymost 1: 07/2011 2: linear 12/2012 3: no neg. start 03/2014 4: base constant on shade table 11/2017",