mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
internal/graphicscommand: add Terminate
This change reduces a render thread usage in internal/ui. Updates #2714
This commit is contained in:
parent
08ae0f4a94
commit
338b8957e8
@ -39,3 +39,9 @@ func runOnRenderThread(f func(), sync bool) {
|
||||
// This blocking is expected as double-buffering is used.
|
||||
theRenderThread.CallAsync(f)
|
||||
}
|
||||
|
||||
func Terminate() {
|
||||
// Post a task to the render thread to ensure all the queued functions are executed.
|
||||
// This is necessary especially for GLFW. glfw.Terminate will remove the context and any graphics calls after that will be invalidated.
|
||||
theRenderThread.Call(func() {})
|
||||
}
|
||||
|
@ -1397,9 +1397,7 @@ func (u *UserInterface) update() (float64, float64, error) {
|
||||
|
||||
func (u *UserInterface) loopGame() (ferr error) {
|
||||
defer func() {
|
||||
// Post a task to the render thread to ensure all the queued functions are executed.
|
||||
// glfw.Terminate will remove the context and any graphics calls after that will be invalidated.
|
||||
u.renderThread.Call(func() {})
|
||||
graphicscommand.Terminate()
|
||||
u.mainThread.Call(func() {
|
||||
if err := glfw.Terminate(); err != nil {
|
||||
ferr = err
|
||||
|
Loading…
Reference in New Issue
Block a user