From 4d43933255849492693ae06e29d15a4f36ed1671 Mon Sep 17 00:00:00 2001 From: Julius Trinkunas Date: Wed, 12 Jun 2024 19:19:49 +0300 Subject: [PATCH] AxmolRenderer: fix lost state when app activity is relaunched --- .../java/src/org/axmol/lib/AxmolRenderer.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/platform/android/java/src/org/axmol/lib/AxmolRenderer.java b/core/platform/android/java/src/org/axmol/lib/AxmolRenderer.java index 7ec99ca814a..1d47c5011c1 100644 --- a/core/platform/android/java/src/org/axmol/lib/AxmolRenderer.java +++ b/core/platform/android/java/src/org/axmol/lib/AxmolRenderer.java @@ -47,8 +47,9 @@ public class AxmolRenderer implements GLSurfaceView.Renderer { private long mLastTickInNanoSeconds; private int mScreenWidth; private int mScreenHeight; - private boolean mNativeInitCompleted = false; - private boolean mIsPaused = false; + + private static boolean gNativeInitialized = false; + private static boolean gNativeIsPaused = false; // =========================================================== // Constructors @@ -76,11 +77,11 @@ public void onSurfaceCreated(final GL10 GL10, final EGLConfig EGLConfig) { AxmolRenderer.nativeInit(this.mScreenWidth, this.mScreenHeight); this.mLastTickInNanoSeconds = System.nanoTime(); - if (mNativeInitCompleted) { + if (gNativeInitialized) { // This must be from an OpenGL context loss nativeOnContextLost(); } else { - mNativeInitCompleted = true; + gNativeInitialized = true; } } @@ -160,17 +161,17 @@ public void handleOnPause() { * onSurfaceCreated is invoked. Can not invoke any * native method before onSurfaceCreated is invoked */ - if (!mNativeInitCompleted) + if (!gNativeInitialized) return; AxmolRenderer.nativeOnPause(); - mIsPaused = true; + gNativeIsPaused = true; } public void handleOnResume() { - if (mIsPaused) { + if (gNativeIsPaused) { AxmolRenderer.nativeOnResume(); - mIsPaused = false; + gNativeIsPaused = false; } }