diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.cpp index 3a0742c8f..4468a3b9b 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.cpp @@ -122,11 +122,11 @@ AndroidApplicationInfo CIrrDeviceAndroid::ApplicationInfo; // Execution of android_main() function is a kind of "onCreate" event, so this // function should be used there to make sure that global window state variables // have their default values on startup. -void CIrrDeviceAndroid::onCreate() +extern "C" void IrrDeviceAndroid_onCreate() { - IsPaused = true; - IsFocused = false; - IsStarted = false; + CIrrDeviceAndroid::IsPaused = true; + CIrrDeviceAndroid::IsFocused = false; + CIrrDeviceAndroid::IsStarted = false; } JNIEnv* CIrrDeviceAndroid::m_jni_env = NULL; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h index bd90e58ea..fcd07b292 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h @@ -41,6 +41,9 @@ namespace irr class CIrrDeviceAndroid : public CIrrDeviceStub, video::IImagePresenter { public: + static bool IsPaused; + static bool IsFocused; + static bool IsStarted; //! constructor CIrrDeviceAndroid(const SIrrlichtCreationParameters& param); @@ -105,10 +108,6 @@ namespace irr bool GyroscopeActive; static AndroidApplicationInfo ApplicationInfo; - static bool IsPaused; - static bool IsFocused; - static bool IsStarted; - bool HasTouchDevice; float GamepadAxisX; float GamepadAxisY; diff --git a/lib/irrlicht/source/Irrlicht/stk_android_native_app_glue.c b/lib/irrlicht/source/Irrlicht/stk_android_native_app_glue.c index be253b4fb..2887b0a01 100644 --- a/lib/irrlicht/source/Irrlicht/stk_android_native_app_glue.c +++ b/lib/irrlicht/source/Irrlicht/stk_android_native_app_glue.c @@ -206,6 +206,9 @@ static void process_cmd(struct android_app* app, struct android_poll_source* sou android_app_post_exec_cmd(app, cmd); } +// From CIrrDeviceAndroid.h +extern void IrrDeviceAndroid_onCreate(); + static void* android_app_entry(void* param) { struct android_app* android_app = (struct android_app*)param; @@ -226,6 +229,9 @@ static void* android_app_entry(void* param) { &android_app->cmdPollSource); android_app->looper = looper; + // Initialize global variables in android device before android_app->running + IrrDeviceAndroid_onCreate(); + pthread_mutex_lock(&android_app->mutex); android_app->running = 1; pthread_cond_broadcast(&android_app->cond); diff --git a/src/main_android.cpp b/src/main_android.cpp index c382b80ab..33fde3706 100644 --- a/src/main_android.cpp +++ b/src/main_android.cpp @@ -186,10 +186,7 @@ void android_main(struct android_app* app) global_android_app = app; global_android_activity = app->activity; - - // Initialize global Android window state variables - CIrrDeviceAndroid::onCreate(); - + app_dummy(); override_default_params_for_mobile();