From 287b983d27db29413abf18000dad025349e4255a Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 16 Dec 2017 11:25:01 +1100 Subject: [PATCH] [client] opengl: fixed broken mipmap logic mipmapping is turned off for images that are scaled up a it degrades the output quality. --- client/renderers/opengl.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/client/renderers/opengl.c b/client/renderers/opengl.c index 38acd970..b092e02c 100644 --- a/client/renderers/opengl.c +++ b/client/renderers/opengl.c @@ -69,7 +69,6 @@ struct LGR_OpenGL int fpsList; int mouseList; LG_RendererRect destRect; - bool mipmap; bool hasTextures; GLuint textures[TEXTURE_COUNT]; @@ -365,7 +364,7 @@ void lgr_opengl_on_resize(void * opaque, const int width, const int height, cons if (!this || !this->configured) return; - this->window.x = width; + this->window.x = width; this->window.y = height; memcpy(&this->destRect, &destRect, sizeof(LG_RendererRect)); @@ -634,15 +633,17 @@ bool lgr_opengl_on_frame_event(void * opaque, const uint8_t * data) (this->format.width > this->destRect.w) || (this->format.height > this->destRect.h)); - if (this->mipmap != mipmap) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR); - this->mipmap = mipmap; - } - if (mipmap) + { glGenerateMipmap(GL_TEXTURE_2D); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } glBindTexture(GL_TEXTURE_2D, 0);