diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/GLView.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/GLView.java index 40f46dcf..d2697f7e 100755 --- a/android-app/src/main/java/org/solovyev/android/calculator/plot/GLView.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/GLView.java @@ -161,10 +161,14 @@ abstract class GLView extends SurfaceView implements SurfaceHolder.Callback { if (hasSurface && !paused) { onDrawFrame(gl); if (!egl.eglSwapBuffers(display, surface)) { + paused = true; } if (egl.eglGetError() == EGL11.EGL_CONTEXT_LOST) { paused = true; } + if(paused) { + reinitGL(); + } if (looping) { requestDraw(); } @@ -177,13 +181,22 @@ abstract class GLView extends SurfaceView implements SurfaceHolder.Callback { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { this.width = width; this.height = height; - boolean doInit = !hasSurface && !paused; + final boolean hadSurface = hasSurface; + boolean doInit = !hadSurface && !paused; hasSurface = true; if (doInit) { initGL(); + } else if (hadSurface) { + reinitGL(); } } + private void reinitGL() { + deinitGL(); + paused = false; + initGL(); + } + public void surfaceDestroyed(SurfaceHolder holder) { hasSurface = false; deinitGL();