From 02d4316c560779fbf4c9204c97f4050517a29111 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 23 Apr 2020 00:27:04 +0200 Subject: [PATCH] gpu: reset to the default framebuffer on reset The macOS backend doesn't re-create contexts, holding on to the first created instead. Make sure the GPU leaves the default framebuffer bound, in case the context is re-used. Signed-off-by: Elias Naur --- app/internal/window/gl_macos.go | 5 +++++ gpu/gpu.go | 1 + 2 files changed, 6 insertions(+) diff --git a/app/internal/window/gl_macos.go b/app/internal/window/gl_macos.go index bbbfda6e..9b229ab5 100644 --- a/app/internal/window/gl_macos.go +++ b/app/internal/window/gl_macos.go @@ -50,6 +50,11 @@ func (c *context) Release() { c.Lock() defer c.Unlock() C.gio_clearCurrentContext() + // We could release the context with [view clearGLContext] + // and rely on [view openGLContext] auto-creating a new context. + // However that second context is not properly set up by + // OpenGLContextView, so we'll stay on the safe side and keep + // the first context around. } func (c *context) Present() error { diff --git a/gpu/gpu.go b/gpu/gpu.go index 1010ff3d..49da6ef9 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -354,6 +354,7 @@ func (g *GPU) BeginFrame() { g.ctx.SetBlend(false) g.renderer.pather.stenciler.invalidateFBO() g.coverTimer.end() + g.ctx.BindFramebuffer(g.defFBO) } func (g *GPU) EndFrame() {