From 911958cfbe7c12c3ae2e85a9b10c71d8c62220e2 Mon Sep 17 00:00:00 2001 From: "iwg..ic" Date: Wed, 27 Nov 2013 02:11:49 +0000 Subject: [PATCH] Android: set PreserveEGLContextOnPause when the os is rev 11 or higher. Dramatically reduces the resume time when the context can be preserved. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10919 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../android/com/jme3/system/android/OGLESContext.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engine/src/android/com/jme3/system/android/OGLESContext.java b/engine/src/android/com/jme3/system/android/OGLESContext.java index 345fbf9b8..cf49c1cee 100644 --- a/engine/src/android/com/jme3/system/android/OGLESContext.java +++ b/engine/src/android/com/jme3/system/android/OGLESContext.java @@ -39,6 +39,7 @@ import android.content.DialogInterface; import android.content.pm.ConfigurationInfo; import android.graphics.PixelFormat; import android.opengl.GLSurfaceView; +import android.os.Build; import android.text.InputType; import android.view.Gravity; import android.view.SurfaceHolder; @@ -104,6 +105,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex */ public AndroidGLSurfaceView createView() { AndroidGLSurfaceView view; + int buildVersion = Build.VERSION.SDK_INT; // Start to set up the view view = new AndroidGLSurfaceView(JmeAndroidSystem.getActivity().getApplication()); @@ -153,6 +155,14 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex AndroidConfigChooser configChooser = new AndroidConfigChooser(settings); view.setEGLConfigChooser(configChooser); view.setRenderer(this); + + // Attempt to preserve the EGL Context on app pause/resume. + // Not destroying and recreating the EGL context + // will help with resume time by reusing the existing context to avoid + // reloading all the OpenGL objects. + if (buildVersion >= 11) { + view.setPreserveEGLContextOnPause(true); + } return view; }