+ void
+ recreate(void) {
+ EGLContext currentContext = eglGetCurrentContext();
+ EGLSurface currentDrawSurface = eglGetCurrentSurface(EGL_DRAW);
+ EGLSurface currentReadSurface = eglGetCurrentSurface(EGL_READ);
+ bool rebindDrawSurface = currentDrawSurface == surface;
+ bool rebindReadSurface = currentReadSurface == surface;
+
+ if (rebindDrawSurface || rebindReadSurface) {
+ eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ }
+
+ eglDestroySurface(eglDisplay, surface);
+
+ EGLConfig config = static_cast<const EglVisual *>(visual)->config;
+ surface = eglCreateWindowSurface(eglDisplay, config, (EGLNativeWindowType)window, NULL);
+
+ if (rebindDrawSurface || rebindReadSurface) {
+ eglMakeCurrent(eglDisplay, surface, surface, currentContext);
+ }
+ }
+