Document android app lifecycle; kill app when window is closed, until pausing/restori...
[freeglut] / src / android / fg_runtime_android.c
index 253db95..b5d6cad 100644 (file)
@@ -49,6 +49,7 @@
 #include <android/asset_manager.h>
 #include <android/native_window.h>
 #include "android/native_app_glue/android_native_app_glue.h"
+#include "android/fg_main_android.h"
 
 #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "FreeGLUT", __VA_ARGS__))
 #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "FreeGLUT", __VA_ARGS__))
@@ -154,16 +155,22 @@ void android_main(struct android_app* app) {
     char progname[5] = "self";
     char* argv[] = {progname, NULL};
     main(1, argv);
+    /* FreeGLUT will exit() by itself if
+       GLUT_ACTION_ON_WINDOW_CLOSE == GLUT_ACTION_EXIT */
   }
 
   LOGI("android_main: end");
 
+  /* TODO: Pausing/resuming windows not ready yet, so exiting now */
+  exit(0);
+
   /* Finish processing all events (namely APP_CMD_DESTROY) before
      exiting thread */
   while (!app->destroyRequested)
       fgPlatformProcessSingleEvent();
 
-  /* In theory we should let NativeActivity restart us, however this
-     doesn't work well yet, so force exit */
-  exit(0);
+  /* Let NativeActivity restart us */
+  /* Users may want to forcibly exit() in their main() anyway because
+     NativeActivity doesn't dlclose() us, so all statically-assigned
+     variables keep their old values on restart.. */
 }