From 85daef74361717e4694e0ed0363c5560fbf146b0 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 23 Mar 2022 02:56:39 +0900 Subject: [PATCH] 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. --- internal/ui/ui_mobile.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/ui/ui_mobile.go b/internal/ui/ui_mobile.go index 173639f11..79d0a03fd 100644 --- a/internal/ui/ui_mobile.go +++ b/internal/ui/ui_mobile.go @@ -270,14 +270,17 @@ func (u *userInterfaceImpl) run(game Game, mainloop bool) (err error) { }() u.context = newContextImpl(game) - u.graphicsDriver = graphicsDriver() if mainloop { // 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. + g := opengl.Get() + u.graphicsDriver = g + ctx := <-glContextCh - u.graphicsDriver.(*opengl.Graphics).SetGomobileGLContext(ctx) + g.SetGomobileGLContext(ctx) } else { + u.graphicsDriver = graphicsDriver() u.t = thread.NewOSThread() graphicscommand.SetRenderingThread(u.t) }