From fc7be5be3c2b8c8a4d1995a65136052aa3361862 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 26 Feb 2016 03:14:51 +0900 Subject: [PATCH] ui: Bug fix: monitor's size might be 0 e.g. on Linux VM --- internal/ui/ui_glfw.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index be995f2d7..009653857 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -109,10 +109,14 @@ type userInterface struct { func (u *userInterface) start(width, height, scale int, title string) (actualScale int, err error) { m := glfw.GetPrimaryMonitor() - mw, _ := m.GetPhysicalSize() v := m.GetVideoMode() - dpi := float64(v.Width) * 25.4 / float64(mw) - u.deviceScaleFactor = dpi / 96 + mw, _ := m.GetPhysicalSize() + u.deviceScaleFactor = 1 + // mw can be 0 on some environment like Linux VM + if 0 < mw { + dpi := float64(v.Width) * 25.4 / float64(mw) + u.deviceScaleFactor = dpi / 96 + } u.setScreenSize(width, height, scale) u.window.SetTitle(title)