ui: Bug fix: monitor's size might be 0 e.g. on Linux VM

This commit is contained in:
Hajime Hoshi 2016-02-26 03:14:51 +09:00
parent 4d53cf20da
commit fc7be5be3c

View File

@ -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()
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)