diff --git a/internal/loop/run.go b/internal/loop/run.go index d5b471ddf..1e5ba5520 100644 --- a/internal/loop/run.go +++ b/internal/loop/run.go @@ -28,6 +28,7 @@ func CurrentFPS() float64 { } func IsRunning() bool { + // TODO: Need lock? if currentRunContext == nil { return false } diff --git a/run.go b/run.go index 994b0cbf5..fe5d3ab25 100644 --- a/run.go +++ b/run.go @@ -15,6 +15,7 @@ package ebiten import ( + "math" "sync/atomic" "github.com/hajimehoshi/ebiten/internal/loop" @@ -143,7 +144,12 @@ func SetScreenScale(scale float64) { // ScreenScale returns the current screen scale. // +// If Run is not called, this returns NaN. +// // This function is concurrent-safe. func ScreenScale() float64 { + if !loop.IsRunning() { + return math.NaN() + } return ui.ScreenScale() }