mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-27 04:08:53 +01:00
Bug fix: Ignore Draw when the window is closed
This commit is contained in:
parent
172dd4bca4
commit
6f1799b1c6
@ -72,11 +72,13 @@ func (w *GameWindow) run(graphicsSharedContext *opengl.SharedContext, sharedGLCo
|
|||||||
w.screenWidth, w.screenHeight, w.screenScale)
|
w.screenWidth, w.screenHeight, w.screenScale)
|
||||||
C.UnuseGLContext()
|
C.UnuseGLContext()
|
||||||
|
|
||||||
w.loop(context, glContext)
|
defer func() {
|
||||||
|
C.UseGLContext(glContext)
|
||||||
|
context.Dispose()
|
||||||
|
C.UnuseGLContext()
|
||||||
|
}()
|
||||||
|
|
||||||
C.UseGLContext(glContext)
|
w.loop(context, glContext)
|
||||||
context.Dispose()
|
|
||||||
C.UnuseGLContext()
|
|
||||||
}()
|
}()
|
||||||
<-ch
|
<-ch
|
||||||
}
|
}
|
||||||
@ -96,9 +98,14 @@ func (w *GameWindow) loop(context *opengl.Context, glContext *C.NSOpenGLContext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *GameWindow) Draw(f func(graphics.Context)) {
|
func (w *GameWindow) Draw(f func(graphics.Context)) {
|
||||||
w.useGLContext(func(context *opengl.Context) {
|
select {
|
||||||
context.Update(f)
|
case <-w.closed:
|
||||||
})
|
return
|
||||||
|
default:
|
||||||
|
w.useGLContext(func(context *opengl.Context) {
|
||||||
|
context.Update(f)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *GameWindow) useGLContext(f func(*opengl.Context)) {
|
func (w *GameWindow) useGLContext(f func(*opengl.Context)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user