mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
Bug fix: move waiting onto the window's own thread
This commit is contained in:
parent
bbb28d2083
commit
24430719ff
@ -90,9 +90,12 @@ func (w *GameWindow) loop(context *opengl.Context, glContext *C.NSOpenGLContext)
|
|||||||
case <-w.closed:
|
case <-w.closed:
|
||||||
return
|
return
|
||||||
case f := <-w.funcs:
|
case f := <-w.funcs:
|
||||||
|
// Wait 10 millisecond at least to avoid busy loop.
|
||||||
|
after := time.After(time.Duration(int64(time.Millisecond) * 10))
|
||||||
C.UseGLContext(glContext)
|
C.UseGLContext(glContext)
|
||||||
f(context)
|
f(context)
|
||||||
C.UnuseGLContext()
|
C.UnuseGLContext()
|
||||||
|
<-after
|
||||||
w.funcsDone <- struct{}{}
|
w.funcsDone <- struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,13 +107,6 @@ func (w *GameWindow) Draw(f func(graphics.Context)) {
|
|||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait 10 millisecond at least to avoid busy loop.
|
|
||||||
after := time.After(time.Duration(int64(time.Millisecond) * 10))
|
|
||||||
defer func() {
|
|
||||||
<-after
|
|
||||||
}()
|
|
||||||
|
|
||||||
w.useGLContext(func(context *opengl.Context) {
|
w.useGLContext(func(context *opengl.Context) {
|
||||||
context.Update(f)
|
context.Update(f)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user