From 237a8dad8f5410b64721ea1fbd190f2a8e901e2b Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 7 Nov 2019 11:31:17 +0100 Subject: [PATCH] app/internal/window: re-create EGL surface on resizing This is effectively a revert of 60e4cca934eaa4713fdf693ac4afcacc43f7b632, which seems to have caused flickering problems on some versions of Windows. Signed-off-by: Elias Naur --- app/internal/window/egl.go | 47 +++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/app/internal/window/egl.go b/app/internal/window/egl.go index a301bc15..01e1e9a4 100644 --- a/app/internal/window/egl.go +++ b/app/internal/window/egl.go @@ -142,34 +142,29 @@ func (c *context) MakeCurrent() error { return nil } c.width, c.height = width, height - // Do not re-create surfaces when only resizing. This prevents flickering when resizing on X11. - if c.eglWin != win { - if win == nilEGLNativeWindowType && c.srgbFBO != nil { - c.srgbFBO.Release() - c.srgbFBO = nil - } - c.destroySurface() - c.eglWin = win - if c.eglWin == nilEGLNativeWindowType { - return nil - } - eglSurf, err := createSurfaceAndMakeCurrent(c.eglCtx, win) - c.eglSurf = eglSurf - if err != nil { - c.eglWin = nilEGLNativeWindowType - return err - } - // eglSwapInterval 1 leads to erratic frame rates and unnecessary blocking. - // We rely on platform specific frame rate limiting instead, except on Windows - // and X11 where eglSwapInterval is all there is. - if c.driver.needVSync() { - eglSwapInterval(c.eglCtx.disp, 1) - } else { - eglSwapInterval(c.eglCtx.disp, 0) - } - } else if c.eglWin == nilEGLNativeWindowType { + if win == nilEGLNativeWindowType && c.srgbFBO != nil { + c.srgbFBO.Release() + c.srgbFBO = nil + } + c.destroySurface() + c.eglWin = win + if c.eglWin == nilEGLNativeWindowType { return nil } + eglSurf, err := createSurfaceAndMakeCurrent(c.eglCtx, win) + c.eglSurf = eglSurf + if err != nil { + c.eglWin = nilEGLNativeWindowType + return err + } + // eglSwapInterval 1 leads to erratic frame rates and unnecessary blocking. + // We rely on platform specific frame rate limiting instead, except on Windows + // and X11 where eglSwapInterval is all there is. + if c.driver.needVSync() { + eglSwapInterval(c.eglCtx.disp, 1) + } else { + eglSwapInterval(c.eglCtx.disp, 0) + } if c.eglCtx.srgb { return nil }