* This is the main entry point of a native application that is using * android_native_app_glue. It runs in its own thread, with its own * event loop for receiving input events and doing other things. */
| 370 | * event loop for receiving input events and doing other things. |
| 371 | */ |
| 372 | void android_main(android_app *appState) { |
| 373 | InitInstance(appState); |
| 374 | |
| 375 | // loop waiting for stuff to do. |
| 376 | while (1) { |
| 377 | // Read all pending events. |
| 378 | int id; |
| 379 | int events; |
| 380 | android_poll_source *source; |
| 381 | |
| 382 | // If not animating, we will block forever waiting for events. |
| 383 | // If animating, we loop until all events are read, then continue |
| 384 | // to draw the next frame of animation. |
| 385 | while ((id = ALooper_pollAll(!suspended ? 0 : -1, nullptr, &events, (void **)&source)) >= 0) { |
| 386 | // Process this event. |
| 387 | if (source) { |
| 388 | source->process(appState, source); |
| 389 | } |
| 390 | |
| 391 | ProcessSensors(id); |
| 392 | |
| 393 | // Check if we are exiting. |
| 394 | if (appState->destroyRequested != 0) { |
| 395 | ShutdownInstance(); |
| 396 | return; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | if (surfaceCreated && !suspended) { |
| 401 | BE1::RHI::DisplayMetrics displayMetrics; |
| 402 | BE1::rhi.GetDisplayMetrics(mainContext, &displayMetrics); |
| 403 | |
| 404 | if (displayMetrics.backingWidth != currentWindowWidth || displayMetrics.backingHeight != currentWindowHeight) { |
| 405 | WindowSizeChanged(displayMetrics.backingWidth, displayMetrics.backingHeight); |
| 406 | } |
| 407 | |
| 408 | app.RunFrame(); |
| 409 | |
| 410 | BE1::rhi.DisplayContext(mainContext); |
| 411 | } |
| 412 | } |
| 413 | } |
no test coverage detected