From 04dc1faa9c163dbf61ec5109397702b53a216ecf Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 14 Feb 2019 01:36:21 +0900 Subject: [PATCH] graphicsdriver/opengl: Call glFinish before glReadPixels It looks like glFlush is not enough at least on Travis CI. Fixes #814 --- internal/graphicsdriver/opengl/context_desktop.go | 5 ++++- internal/graphicsdriver/opengl/context_mobile.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/graphicsdriver/opengl/context_desktop.go b/internal/graphicsdriver/opengl/context_desktop.go index f2dbbdc92..221385954 100644 --- a/internal/graphicsdriver/opengl/context_desktop.go +++ b/internal/graphicsdriver/opengl/context_desktop.go @@ -161,7 +161,10 @@ func (c *context) bindFramebufferImpl(f framebufferNative) { func (c *context) framebufferPixels(f *framebuffer, width, height int) ([]byte, error) { var pixels []byte _ = mainthread.Run(func() error { - gl.Flush() + // glFlush is not enough. glFinish can be required before glReadPixels on some environments like + // Travis CI (#814) + // See also: https://forums.khronos.org/showthread.php/62741 + gl.Finish() return nil }) c.bindFramebuffer(f.native) diff --git a/internal/graphicsdriver/opengl/context_mobile.go b/internal/graphicsdriver/opengl/context_mobile.go index f514ef58d..e7b3fb413 100644 --- a/internal/graphicsdriver/opengl/context_mobile.go +++ b/internal/graphicsdriver/opengl/context_mobile.go @@ -142,7 +142,7 @@ func (c *context) bindFramebufferImpl(f framebufferNative) { func (c *context) framebufferPixels(f *framebuffer, width, height int) ([]byte, error) { gl := c.gl - gl.Flush() + gl.Finish() c.bindFramebuffer(f.native)