(
&mut self,
update_function: impl 'static
+ FnMut(
// Coreall(target_os = "android", not(feature = "headless"))
&mut Engine,
),
)
| 242 | /// Renderer, window, vec of objects, events, and camera are passed to the update code. |
| 243 | #[allow(unreachable_code)] |
| 244 | pub fn update_loop( |
| 245 | &mut self, |
| 246 | update_function: impl 'static |
| 247 | + FnMut( |
| 248 | // Coreall(target_os = "android", not(feature = "headless")) |
| 249 | &mut Engine, |
| 250 | ), |
| 251 | ) -> Result<(), crate::error::Error> { |
| 252 | #[cfg(all(not(feature = "headless"), feature = "window"))] |
| 253 | { |
| 254 | self.update_loop = Some(Box::new(update_function)); |
| 255 | } |
| 256 | |
| 257 | // will create the main event loop of the window. |
| 258 | // and will contain all the callbacks and button press |
| 259 | // also will allow graphics API |
| 260 | #[cfg(all(target_os = "android", not(feature = "headless")))] |
| 261 | let event_loop = if android_app.is_some() { |
| 262 | use winit::platform::android::EventLoopBuilderExtAndroid; |
| 263 | |
| 264 | android_logger::init_once( |
| 265 | android_logger::Config::default() |
| 266 | .with_max_level(log::LevelFilter::Trace) // Default comes from `log::max_level`, i.e. Off |
| 267 | .with_filter( |
| 268 | android_logger::FilterBuilder::new() |
| 269 | .filter_level(log::LevelFilter::Debug) |
| 270 | .filter_module("android_activity", log::LevelFilter::Trace) |
| 271 | .filter_module("winit", log::LevelFilter::Trace) |
| 272 | .build(), |
| 273 | ), |
| 274 | ); |
| 275 | |
| 276 | winit::event_loop::EventLoopBuilder::new() |
| 277 | .with_android_app(if let Some(android_app) = android_app { |
| 278 | android_app |
| 279 | } else { |
| 280 | panic!("No android app") |
| 281 | }) |
| 282 | .build()? |
| 283 | } else { |
| 284 | EventLoop::new()? |
| 285 | }; |
| 286 | |
| 287 | #[cfg(all( |
| 288 | not(target_os = "android"), |
| 289 | not(feature = "headless"), |
| 290 | feature = "window" |
| 291 | ))] |
| 292 | let event_loop = EventLoop::new()?; |
| 293 | #[cfg(all(not(feature = "headless"), feature = "window"))] |
| 294 | event_loop.set_control_flow(self.event_loop_control_flow); |
| 295 | #[cfg(all(not(feature = "headless"), feature = "window"))] |
| 296 | event_loop.run_app(self)?; |
| 297 | |
| 298 | #[cfg(all( |
| 299 | not(target_os = "android"), |
| 300 | not(feature = "window"), |
| 301 | feature = "headless" |
no test coverage detected