From 86330faca6413ade18463eafc7da05ab59a49382 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 8 Jan 2022 14:40:25 +0100 Subject: [PATCH] gpu/internal/opengl: restore Android emulator OpenGL workaround For some reason, the Android emulator OpenGL implementation needs the output framebuffer current when eglSwapBuffers is called; otherwise sRGB emulation breaks. We used to restore the default FBO explicitly, 9b5e9ae60717e restored it implicitly through automatic state restoring, but 30ecf75a0f broke that by only saving and restoring shared context state. This change restores the explicit behaviour for non-shared contexts. Signed-off-by: Elias Naur --- gpu/internal/opengl/opengl.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gpu/internal/opengl/opengl.go b/gpu/internal/opengl/opengl.go index ef891973..8d4409aa 100644 --- a/gpu/internal/opengl/opengl.go +++ b/gpu/internal/opengl/opengl.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "image" + "runtime" "strings" "time" "unsafe" @@ -297,6 +298,10 @@ func (b *Backend) EndFrame() { } if b.sharedCtx { b.restoreState(b.savedState) + } else if runtime.GOOS == "android" { + // The Android emulator needs the output framebuffer to be current when + // eglSwapBuffers is called. + b.glstate.bindFramebuffer(b.funcs, gl.FRAMEBUFFER, b.outputFBO) } }