From fd33dfcd7321346631cd9237b5ae2993c29f9ca5 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Tue, 27 Oct 2015 12:34:32 +1100 Subject: [PATCH] [android] Restore old GL context after createSurface Fixes #2807 --- platform/android/native_map_view.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/android/native_map_view.cpp b/platform/android/native_map_view.cpp index 9c4d4b1d1..0a69f2d2d 100644 --- a/platform/android/native_map_view.cpp +++ b/platform/android/native_map_view.cpp @@ -398,6 +398,11 @@ void NativeMapView::createSurface(ANativeWindow *window_) { if (!firstTime) { firstTime = true; + EGLDisplay oldDisplay = eglGetCurrentDisplay(); + EGLSurface oldReadSurface = eglGetCurrentSurface(EGL_READ); + EGLSurface oldDrawSurface = eglGetCurrentSurface(EGL_DRAW); + EGLContext oldContext = eglGetCurrentContext(); + if (!eglMakeCurrent(display, surface, surface, context)) { mbgl::Log::Error(mbgl::Event::OpenGL, "eglMakeCurrent() returned error %d", eglGetError()); @@ -418,7 +423,7 @@ void NativeMapView::createSurface(ANativeWindow *window_) { return reinterpret_cast(eglGetProcAddress(name)); }); - if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) { + if (!eglMakeCurrent(oldDisplay, oldDrawSurface, oldReadSurface, oldContext)) { mbgl::Log::Error(mbgl::Event::OpenGL, "eglMakeCurrent(EGL_NO_CONTEXT) returned error %d", eglGetError()); throw new std::runtime_error("eglMakeCurrent() failed");