internal/ui: bug fix: OpenGL must be used when gomobile-build is used

Now the logic of graphicsDriver() is updated, this can return a Metal
graphics driver on iOS even when gomobile-build is used.

This change fixes this issue.
This commit is contained in:
Hajime Hoshi 2022-03-23 02:56:39 +09:00
parent 09b0a0ffaf
commit 85daef7436

View File

@ -270,14 +270,17 @@ func (u *userInterfaceImpl) run(game Game, mainloop bool) (err error) {
}() }()
u.context = newContextImpl(game) u.context = newContextImpl(game)
u.graphicsDriver = graphicsDriver()
if mainloop { if mainloop {
// When mainloop is true, gomobile-build is used. In this case, GL functions must be called via // When mainloop is true, gomobile-build is used. In this case, GL functions must be called via
// gl.Context so that they are called on the appropriate thread. // gl.Context so that they are called on the appropriate thread.
g := opengl.Get()
u.graphicsDriver = g
ctx := <-glContextCh ctx := <-glContextCh
u.graphicsDriver.(*opengl.Graphics).SetGomobileGLContext(ctx) g.SetGomobileGLContext(ctx)
} else { } else {
u.graphicsDriver = graphicsDriver()
u.t = thread.NewOSThread() u.t = thread.NewOSThread()
graphicscommand.SetRenderingThread(u.t) graphicscommand.SetRenderingThread(u.t)
} }