From 7e0c7e3a6703a05b78853830b7cf5f277ed81ae4 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 26 Oct 2020 18:25:40 -0300 Subject: [PATCH] Fix the default mipmap filter for textures. --- src/modules/graphics/Graphics.cpp | 5 +++++ src/modules/graphics/Graphics.h | 3 +++ src/modules/graphics/Texture.cpp | 3 +++ 3 files changed, 11 insertions(+) diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 001806e85..7a985eed7 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -104,6 +104,11 @@ bool isDebugEnabled() love::Type Graphics::type("graphics", &Module::type); +Graphics::DisplayState::DisplayState() +{ + defaultSamplerState.mipmapFilter = SamplerState::MIPMAP_FILTER_LINEAR; +} + Graphics::Graphics() : width(0) , height(0) diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index 49a540aa5..0ad0c5528 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -869,6 +869,8 @@ protected: struct DisplayState { + DisplayState(); + Colorf color = Colorf(1.0, 1.0, 1.0, 1.0); Colorf backgroundColor = Colorf(0.0, 0.0, 0.0, 1.0); @@ -901,6 +903,7 @@ protected: bool wireframe = false; + // Default mipmap filter is set in the DisplayState constructor. SamplerState defaultSamplerState = SamplerState(); }; diff --git a/src/modules/graphics/Texture.cpp b/src/modules/graphics/Texture.cpp index 6f02cb36f..8897b8de7 100644 --- a/src/modules/graphics/Texture.cpp +++ b/src/modules/graphics/Texture.cpp @@ -281,6 +281,9 @@ Texture::Texture(const Settings &settings, const Slices *slices) samplerState = gfx->getDefaultSamplerState(); + if (getMipmapCount() == 1) + samplerState.mipmapFilter = SamplerState::MIPMAP_FILTER_NONE; + Quad::Viewport v = {0, 0, (double) width, (double) height}; quad.set(new Quad(v, width, height), Acquire::NORETAIN);