Skip to content

Commit

Permalink
AxmolRenderer: fix lost state when app activity is relaunched
Browse files Browse the repository at this point in the history
  • Loading branch information
smilediver committed Sep 26, 2024
1 parent 1672915 commit 4d43933
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions core/platform/android/java/src/org/axmol/lib/AxmolRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 4d43933

Please sign in to comment.