Bug fix: move waiting onto the window's own thread

This commit is contained in:
Hajime Hoshi 2014-01-15 01:59:49 +09:00
parent bbb28d2083
commit 24430719ff

View File

@ -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)
}) })