From f6c2d899f11944fa320c25c855131bd0dc9aa4a5 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 8 Oct 2018 01:24:19 +0900 Subject: [PATCH] ui: Bug fix: compile error on browsers and mobiles --- internal/ui/ui_js.go | 7 ++++++- internal/ui/ui_mobile.go | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index 01292cd0a..798f8d219 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -22,6 +22,7 @@ import ( "github.com/gopherjs/gopherwasm/js" + "github.com/hajimehoshi/ebiten/internal/devicescale" "github.com/hajimehoshi/ebiten/internal/hooks" "github.com/hajimehoshi/ebiten/internal/input" "github.com/hajimehoshi/ebiten/internal/opengl" @@ -153,6 +154,10 @@ func SetWindowDecorated(decorated bool) { // Do nothing } +func DeviceScaleFactor() float64 { + return devicescale.GetAt(0, 0) +} + func (u *userInterface) getScale() float64 { if !u.fullscreen { return u.scale @@ -174,7 +179,7 @@ func (u *userInterface) actualScreenScale() float64 { // * Chrome just after restoring the lost context // * Safari // Let's use the devicePixelRatio as it is here. - return u.getScale() * deviceScale.GetAt(0, 0) + return u.getScale() * devicescale.GetAt(0, 0) } func (u *userInterface) updateGraphicsContext(g GraphicsContext) { diff --git a/internal/ui/ui_mobile.go b/internal/ui/ui_mobile.go index 760d559d6..1c409935f 100644 --- a/internal/ui/ui_mobile.go +++ b/internal/ui/ui_mobile.go @@ -420,3 +420,7 @@ func SetVsyncEnabled(enabled bool) { func UpdateTouches(touches []*input.Touch) { input.Get().UpdateTouches(touches) } + +func DeviceScaleFactor() float64 { + return getDeviceScale() +}