From 9e161864f625177b6230e969dcf37e2ad145bf14 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 22 Feb 2016 03:14:31 +0900 Subject: [PATCH] ui: Bug fix: Make sure current framebuffers rendered (#158) --- internal/graphics/opengl/context.go | 4 ++++ internal/ui/ui_glfw.go | 5 +++++ run.go | 1 + 3 files changed, 10 insertions(+) diff --git a/internal/graphics/opengl/context.go b/internal/graphics/opengl/context.go index a3f7777f1..0cc12697c 100644 --- a/internal/graphics/opengl/context.go +++ b/internal/graphics/opengl/context.go @@ -156,6 +156,10 @@ func (c *Context) TexSubImage2D(p []uint8, width, height int) { gl.TexSubImage2D(mgl.TEXTURE_2D, 0, 0, 0, width, height, mgl.RGBA, mgl.UNSIGNED_BYTE, p) } +func (c *Context) BindZeroFramebuffer() { + gl.BindFramebuffer(mgl.FRAMEBUFFER, mgl.Framebuffer(ZeroFramebuffer)) +} + func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) { f := gl.CreateFramebuffer() gl.BindFramebuffer(mgl.FRAMEBUFFER, f) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 0e074091e..d029de338 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -157,6 +157,11 @@ func (u *userInterface) setScreenSize(width, height, scale int) bool { return false } + // To make sure the current existing framebuffers are rendered, + // swap buffers here. + u.context.BindZeroFramebuffer() + u.swapBuffers() + ch := make(chan struct{}) window := u.window window.SetFramebufferSizeCallback(func(w *glfw.Window, width, height int) { diff --git a/run.go b/run.go index 5ae950357..84b7193ff 100644 --- a/run.go +++ b/run.go @@ -114,6 +114,7 @@ func Run(f func(*Image) error, width, height, scale int, title string) error { return err } + // Note that the current bound framebuffer must be the default one (0). ui.SwapBuffers() // Calc the current FPS.