X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fandroid%2Ffg_runtime_android.c;h=c92d5f148ea2161fd091e4ef710e9ea805398bad;hb=a00c7ee3552b527ac6b375d6a6ca42f90770ddc3;hp=1b92bf6256d261b56a6546abc132e3846c152462;hpb=cb1e59cf5e6ac8034ae91abfd320874004a44c88;p=freeglut diff --git a/src/android/fg_runtime_android.c b/src/android/fg_runtime_android.c index 1b92bf6..c92d5f1 100644 --- a/src/android/fg_runtime_android.c +++ b/src/android/fg_runtime_android.c @@ -49,6 +49,7 @@ #include #include #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__)) @@ -127,6 +128,8 @@ static void extract_assets(struct android_app* app) { AAssetDir_close(assetDir); } } + + (*vm)->DetachCurrentThread(vm); } /** @@ -135,7 +138,7 @@ static void extract_assets(struct android_app* app) { * event loop for receiving input events and doing other things. */ void android_main(struct android_app* app) { - LOGI("android_main"); + LOGI("android_main savedState=%p", app->savedState); /* Register window resize callback */ app->activity->callbacks->onNativeWindowResized = onNativeWindowResized; @@ -151,9 +154,16 @@ void android_main(struct android_app* app) { { char progname[5] = "self"; char* argv[] = {progname, NULL}; + fgDisplay.pDisplay.app = app; main(1, argv); + /* FreeGLUT will exit() by itself if + GLUT_ACTION_ON_WINDOW_CLOSE == GLUT_ACTION_EXIT */ } LOGI("android_main: end"); - 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.. */ }