diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index c782e9cd1..ecd48a317 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -22,7 +22,6 @@ package glfw import ( "fmt" "image" - "math" "os" "runtime" "sync" @@ -804,8 +803,8 @@ func (u *UserInterface) updateSize() { h = u.fromGLFWPixel(float64(wh)) } // On Linux/UNIX, further adjusting is required (#1307). - w = math.Ceil(u.toFramebufferPixel(w)) - h = math.Ceil(u.toFramebufferPixel(h)) + w = u.toFramebufferPixel(w) + h = u.toFramebufferPixel(h) return nil }) u.context.Layout(w, h) diff --git a/internal/uidriver/glfw/ui_unix.go b/internal/uidriver/glfw/ui_unix.go index a1f2ae514..297f4bea8 100644 --- a/internal/uidriver/glfw/ui_unix.go +++ b/internal/uidriver/glfw/ui_unix.go @@ -19,12 +19,14 @@ package glfw import ( + "math" + "github.com/hajimehoshi/ebiten/internal/glfw" ) // fromGLFWMonitorPixel must be called from the main thread. func (u *UserInterface) fromGLFWMonitorPixel(x float64) float64 { - return x / u.deviceScaleFactor() + return math.Ceil(x / u.deviceScaleFactor()) } // fromGLFWPixel must be called from the main thread. @@ -44,7 +46,7 @@ func (u *UserInterface) toGLFWPixel(x float64) float64 { // toFramebufferPixel must be called from the main thread. func (u *UserInterface) toFramebufferPixel(x float64) float64 { s, _ := currentMonitor(u.window).GetContentScale() - return x / u.deviceScaleFactor() * float64(s) + return math.Ceil(x * float64(s) / u.deviceScaleFactor()) } func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) {