[android] Restore old GL context after createSurface

Fixes #2807
This commit is contained in:
Leith Bade
2015-10-27 12:34:32 +11:00
parent d48c640b5c
commit fd33dfcd73

View File

@@ -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<mbgl::gl::glProc>(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");