diff --git a/gameforui.go b/gameforui.go index 99abfaa20..523c60725 100644 --- a/gameforui.go +++ b/gameforui.go @@ -72,13 +72,13 @@ func (c *gameForUI) Update() error { return c.game.Update() } -func (c *gameForUI) Draw(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection, screenClearedEveryFrame bool) error { - c.offscreen.mipmap.SetVolatile(screenClearedEveryFrame) +func (c *gameForUI) Draw(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection, clearScreenEveryFrame bool) error { + c.offscreen.mipmap.SetVolatile(clearScreenEveryFrame) // Even though updateCount == 0, the offscreen is cleared and Draw is called. // Draw should not update the game state and then the screen should not be updated without Update, but // users might want to process something at Draw with the time intervals of FPS. - if screenClearedEveryFrame { + if clearScreenEveryFrame { c.offscreen.Clear() } c.game.Draw(c.offscreen) diff --git a/internal/ui/ui_cbackend.go b/internal/ui/ui_cbackend.go index ddd3dda5c..8f3cd2c6e 100644 --- a/internal/ui/ui_cbackend.go +++ b/internal/ui/ui_cbackend.go @@ -58,10 +58,6 @@ func (u *UserInterface) Run(game Game) error { } } -func (*UserInterface) RunWithoutMainLoop(game Game) { - panic("ui: RunWithoutMainLoop is not implemented") -} - func (*UserInterface) DeviceScaleFactor() float64 { return deviceScaleFactor } diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 936b2c80f..54b585dde 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -642,10 +642,6 @@ func init() { runtime.LockOSThread() } -func (u *UserInterface) RunWithoutMainLoop(game Game) { - panic("ui: RunWithoutMainLoop is not implemented") -} - // createWindow creates a GLFW window. // // width and height are in GLFW pixels (not device-independent pixels). diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index fe5585f4c..83f1e0057 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -600,10 +600,6 @@ func (u *UserInterface) Run(game Game) error { return <-u.loop(game) } -func (u *UserInterface) RunWithoutMainLoop(game Game) { - panic("ui: RunWithoutMainLoop is not implemented") -} - func (u *UserInterface) updateScreenSize() { switch { case document.Truthy(): diff --git a/internal/ui/ui_mobile.go b/internal/ui/ui_mobile.go index ab717a9c2..d5bd9968a 100644 --- a/internal/ui/ui_mobile.go +++ b/internal/ui/ui_mobile.go @@ -250,7 +250,11 @@ func (u *UserInterface) Run(game Game) error { return nil } -func (u *UserInterface) RunWithoutMainLoop(game Game) { +func RunWithoutMainLoop(game Game) { + theUI.runWithoutMainLoop(game) +} + +func (u *UserInterface) runWithoutMainLoop(game Game) { go func() { if err := u.run(game, false); err != nil { u.errCh <- err diff --git a/run_mobile.go b/run_mobile.go index 85c797518..befb1cfc0 100644 --- a/run_mobile.go +++ b/run_mobile.go @@ -29,5 +29,5 @@ import ( // // TODO: Remove this. In order to remove this, the gameForUI should be in another package. func RunGameWithoutMainLoop(game Game) { - ui.Get().RunWithoutMainLoop(newGameForUI(game)) + ui.RunWithoutMainLoop(newGameForUI(game)) }