Skip to content

Commit

Permalink
Add more check for renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Nov 30, 2020
1 parent fc83f3b commit b7bec6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="space.celestia.mobilecelestia"
android:versionCode="129"
android:versionName="1.2.1">
android:versionCode="140"
android:versionName="1.2.2">

<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.INTERNET"/>
Expand Down
13 changes: 8 additions & 5 deletions app/src/main/cpp/CelestiaRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ bool CelestiaRenderer::initialize()
}
}

if (surface != EGL_NO_SURFACE) {
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroySurface(display, surface);
surface = EGL_NO_SURFACE;
}

if (window) {
ANativeWindow_setBuffersGeometry(window, 0, 0, format);
if (!(surface = eglCreateWindowSurface(display, config, window, nullptr))) {
Expand All @@ -175,9 +181,6 @@ bool CelestiaRenderer::initialize()
destroy();
return false;
}
} else {
eglDestroySurface(display, surface);
surface = EGL_NO_SURFACE;
}
return true;
}
Expand Down Expand Up @@ -318,7 +321,7 @@ void *CelestiaRenderer::threadCallback(void *self)
bool renderingEnabled = true;

while (renderingEnabled) {
if (renderer->display != EGL_NO_DISPLAY && !renderer->engineStartedCalled)
if (renderer->surface != EGL_NO_SURFACE && !renderer->engineStartedCalled)
renderer->engineStartedCalled = newEnv->CallBooleanMethod(renderer->javaObject, CelestiaRenderer::engineStartedMethod) == JNI_TRUE;
if (renderer->engineStartedCalled)
newEnv->CallVoidMethod(renderer->javaObject, CelestiaRenderer::flushTasksMethod);
Expand All @@ -340,7 +343,7 @@ void *CelestiaRenderer::threadCallback(void *self)
}
renderer->msg = CelestiaRenderer::MSG_NONE;

if (renderer->engineStartedCalled && renderer->core) {
if (renderer->engineStartedCalled && renderer->surface != EGL_NO_SURFACE && renderer->core) {
renderer->resizeIfNeeded();
renderer->tickAndDraw();
}
Expand Down

0 comments on commit b7bec6a

Please sign in to comment.