From 8c0004e99008799d8a357f54e060f691591354e5 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Tue, 21 Nov 2023 18:06:34 +0100 Subject: [PATCH] fix android event loop init --- kubi/src/lib.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/kubi/src/lib.rs b/kubi/src/lib.rs index 859bbde..735083c 100644 --- a/kubi/src/lib.rs +++ b/kubi/src/lib.rs @@ -191,7 +191,8 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp //Init assman world.add_unique(AssetManager { - #[cfg(target_os = "android")] app + #[cfg(target_os = "android")] + app: app.clone() }); //Register workloads @@ -205,7 +206,16 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp world.run_workload(pre_startup).unwrap(); //Create event loop - let event_loop = EventLoop::new().unwrap(); + let event_loop ={ + #[cfg(not(target_os = "android"))] { EventLoop::new().unwrap() } + #[cfg(target_os = "android")] { + use winit::{ + platform::android::EventLoopBuilderExtAndroid, + event_loop::EventLoopBuilder + }; + EventLoopBuilder::new().with_android_app(app).build().unwrap() + } + }; //Initialize renderer { @@ -269,7 +279,7 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp world.run_workload(after_frame_end).unwrap(); //Process control flow changes - if world.borrow::>().unwrap().0 == true { + if world.borrow::>().unwrap().0 { window_target.exit(); } },