mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ui: Bug fix: ScreenSizeFullscreen before Run crashes on Linux
This commit is contained in:
parent
6ef5cc5857
commit
db4395d71b
@ -41,6 +41,8 @@ type userInterface struct {
|
||||
windowWidth int
|
||||
height int
|
||||
initMonitor *glfw.Monitor
|
||||
initFullscreenWidth int
|
||||
initFullscreenHeight int
|
||||
|
||||
scale float64
|
||||
fullscreenScale float64
|
||||
@ -99,6 +101,10 @@ func initialize() error {
|
||||
// TODO: Fix this hack. currentMonitorImpl now requires u.window on POSIX.
|
||||
currentUI.window = w
|
||||
currentUI.initMonitor = currentUI.currentMonitorImpl()
|
||||
v := currentUI.initMonitor.GetVideoMode()
|
||||
s := glfwScale()
|
||||
currentUI.initFullscreenWidth = int(float64(v.Width) / s)
|
||||
currentUI.initFullscreenHeight = int(float64(v.Height) / s)
|
||||
currentUI.window.Destroy()
|
||||
currentUI.window = nil
|
||||
|
||||
@ -236,18 +242,17 @@ func (u *userInterface) setInitIconImages(iconImages []image.Image) {
|
||||
|
||||
func ScreenSizeInFullscreen() (int, int) {
|
||||
u := currentUI
|
||||
if !u.isRunning() {
|
||||
return u.initFullscreenWidth, u.initFullscreenHeight
|
||||
}
|
||||
|
||||
var v *glfw.VidMode
|
||||
s := 0.0
|
||||
if u.isRunning() {
|
||||
_ = mainthread.Run(func() error {
|
||||
v = u.currentMonitor().GetVideoMode()
|
||||
s = glfwScale()
|
||||
return nil
|
||||
})
|
||||
} else {
|
||||
v = currentUI.initMonitor.GetVideoMode()
|
||||
s = glfwScale()
|
||||
}
|
||||
return int(float64(v.Width) / s), int(float64(v.Height) / s)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user