From 352fd76312fab3f11e369cb8ef26af333814c433 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 23 Feb 2022 02:52:15 +0900 Subject: [PATCH] ebiten: optimization: use FilterNearest for an integer scale Updates #1772 --- gameforui.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gameforui.go b/gameforui.go index 523c60725..b54ad5408 100644 --- a/gameforui.go +++ b/gameforui.go @@ -16,6 +16,7 @@ package ebiten import ( "fmt" + "math" "github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver" ) @@ -107,9 +108,12 @@ func (c *gameForUI) Draw(screenScale float64, offsetX, offsetY float64, needsCle // filterScreen works with >=1 scale, but does not well with <1 scale. // Use regular FilterLinear instead so far (#669). - if s >= 1 { + switch { + case math.Floor(s) == s: + op.Filter = FilterNearest + case s > 1: op.Filter = filterScreen - } else { + default: op.Filter = FilterLinear } c.screen.DrawImage(c.offscreen, op)