app/internal/window: re-create EGL surface on resizing

This is effectively a revert of 60e4cca934, which
seems to have caused flickering problems on some versions of Windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-11-07 11:31:17 +01:00
parent 97299dc2f9
commit 237a8dad8f
+21 -26
View File
@@ -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
}