mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ui: Bug fix: monitor's size might be 0 e.g. on Linux VM
This commit is contained in:
parent
4d53cf20da
commit
fc7be5be3c
@ -109,10 +109,14 @@ type userInterface struct {
|
|||||||
|
|
||||||
func (u *userInterface) start(width, height, scale int, title string) (actualScale int, err error) {
|
func (u *userInterface) start(width, height, scale int, title string) (actualScale int, err error) {
|
||||||
m := glfw.GetPrimaryMonitor()
|
m := glfw.GetPrimaryMonitor()
|
||||||
mw, _ := m.GetPhysicalSize()
|
|
||||||
v := m.GetVideoMode()
|
v := m.GetVideoMode()
|
||||||
dpi := float64(v.Width) * 25.4 / float64(mw)
|
mw, _ := m.GetPhysicalSize()
|
||||||
u.deviceScaleFactor = dpi / 96
|
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.setScreenSize(width, height, scale)
|
||||||
u.window.SetTitle(title)
|
u.window.SetTitle(title)
|
||||||
|
Loading…
Reference in New Issue
Block a user