mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
ui: Bug fix: SetFullscreen didn't work without Run
This commit is contained in:
parent
c94c994bd1
commit
f591ca3d2b
@ -44,6 +44,7 @@ type userInterface struct {
|
|||||||
sizeChanged bool
|
sizeChanged bool
|
||||||
origPosX int
|
origPosX int
|
||||||
origPosY int
|
origPosY int
|
||||||
|
initFullscreen bool
|
||||||
m sync.Mutex
|
m sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,14 +156,16 @@ func SetScreenScale(scale float64) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetFullscreen(fullscreen bool) {
|
func SetFullscreen(fullscreen bool) {
|
||||||
// This can be called before Run: change the state asyncly.
|
u := currentUI
|
||||||
go func() {
|
if !u.isRunning() {
|
||||||
_ = currentUI.runOnMainThread(func() error {
|
u.initFullscreen = fullscreen
|
||||||
u := currentUI
|
return
|
||||||
u.setScreenSize(u.width, u.height, u.scale, fullscreen)
|
}
|
||||||
return nil
|
_ = u.runOnMainThread(func() error {
|
||||||
})
|
u := currentUI
|
||||||
}()
|
u.setScreenSize(u.width, u.height, u.scale, fullscreen)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScreenScale() float64 {
|
func ScreenScale() float64 {
|
||||||
@ -247,6 +250,9 @@ func Run(width, height int, scale float64, title string, g GraphicsContext) erro
|
|||||||
if err := u.runOnMainThread(func() error {
|
if err := u.runOnMainThread(func() error {
|
||||||
m := glfw.GetPrimaryMonitor()
|
m := glfw.GetPrimaryMonitor()
|
||||||
v := m.GetVideoMode()
|
v := m.GetVideoMode()
|
||||||
|
|
||||||
|
// The game is in window mode (not fullscreen mode) at the first state.
|
||||||
|
// Don't refer u.initFullscreen here to avoid some GLFW problems.
|
||||||
if !u.setScreenSize(width, height, scale, false) {
|
if !u.setScreenSize(width, height, scale, false) {
|
||||||
return errors.New("ui: Fail to set the screen size")
|
return errors.New("ui: Fail to set the screen size")
|
||||||
}
|
}
|
||||||
@ -319,6 +325,15 @@ func (u *userInterface) update(g GraphicsContext) error {
|
|||||||
return &RegularTermination{}
|
return &RegularTermination{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ = u.runOnMainThread(func() error {
|
||||||
|
if u.initFullscreen {
|
||||||
|
u := currentUI
|
||||||
|
u.setScreenSize(u.width, u.height, u.scale, true)
|
||||||
|
u.initFullscreen = false
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
actualScale := 0.0
|
actualScale := 0.0
|
||||||
sizeChanged := false
|
sizeChanged := false
|
||||||
_ = u.runOnMainThread(func() error {
|
_ = u.runOnMainThread(func() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user