/*
- * freeglut_runtime_android.c
+ * fg_runtime_android.c
*
* Android runtime
*
#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__))
static void onNativeWindowRedrawNeeded(ANativeActivity* activity, ANativeWindow* window) {
LOGI("onNativeWindowRedrawNeeded: %p\n", (void*)activity);
struct android_app* app = (struct android_app*)activity->instance;
- //if (fgDisplay.pDisplay.single_window->Window.pContext.eglSurface != EGL_NO_SURFACE)
android_app_write_cmd(app, APP_CMD_WINDOW_RESIZED);
}
AAssetDir_close(assetDir);
}
}
+
+ (*vm)->DetachCurrentThread(vm);
}
/**
* 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
+ /* Register window resize callback */
app->activity->callbacks->onNativeWindowResized = onNativeWindowResized;
app->activity->callbacks->onContentRectChanged = onContentRectChanged;
app->activity->callbacks->onNativeWindowRedrawNeeded = onNativeWindowRedrawNeeded;
{
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.. */
}