From f1f2d9ff273813d22ade9d80624f4ec1782e75e1 Mon Sep 17 00:00:00 2001 From: dom607 <37772150+dom607@users.noreply.github.com> Date: Sat, 13 Jul 2019 11:37:51 +0900 Subject: [PATCH] Return to the previous surface after swapchain create / destroy. (#1815) --- src/glcontext_egl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glcontext_egl.cpp b/src/glcontext_egl.cpp index 0aeb92102..15de208b7 100644 --- a/src/glcontext_egl.cpp +++ b/src/glcontext_egl.cpp @@ -107,6 +107,8 @@ EGL_IMPORT : m_nwh(_nwh) , m_display(_display) { + EGLSurface defaultSurface = eglGetCurrentSurface(EGL_DRAW); + m_surface = eglCreateWindowSurface(m_display, _config, _nwh, NULL); BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface."); @@ -119,13 +121,18 @@ EGL_IMPORT swapBuffers(); GL_CHECK(glClear(GL_COLOR_BUFFER_BIT) ); swapBuffers(); + eglMakeCurrent(m_display, defaultSurface, defaultSurface, _context); } ~SwapChainGL() { + EGLSurface defaultSurface = eglGetCurrentSurface(EGL_DRAW); + EGLContext defaultContext = eglGetCurrentContext(); + eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(m_display, m_context); eglDestroySurface(m_display, m_surface); + eglMakeCurrent(m_display, defaultSurface, defaultSurface, defaultContext); } void makeCurrent()