MCPcopy Create free account
hub / github.com/android/ndk-samples / HandleCmd

Function HandleCmd

hello-vulkan/app/src/main/cpp/vk_main.cpp:52–85  ·  view source on GitHub ↗

* Called by the Android runtime whenever events happen so the * app can react to it. */

Source from the content-addressed store, hash-verified

50 * app can react to it.
51 */
52static void HandleCmd(struct android_app* app, int32_t cmd) {
53 auto* engine = (VulkanEngine*)app->userData;
54 switch (cmd) {
55 case APP_CMD_START:
56 if (engine->app->window != nullptr) {
57 engine->app_backend->reset(app->window, app->activity->assetManager);
58 engine->app_backend->initVulkan();
59 engine->canRender = true;
60 }
61 case APP_CMD_INIT_WINDOW:
62 // The window is being shown, get it ready.
63 LOGI("Called - APP_CMD_INIT_WINDOW");
64 if (engine->app->window != nullptr) {
65 LOGI("Setting a new surface");
66 engine->app_backend->reset(app->window, app->activity->assetManager);
67 if (!engine->app_backend->initialized) {
68 LOGI("Starting application");
69 engine->app_backend->initVulkan();
70 }
71 engine->canRender = true;
72 }
73 break;
74 case APP_CMD_TERM_WINDOW:
75 // The window is being hidden or closed, clean it up.
76 engine->canRender = false;
77 break;
78 case APP_CMD_DESTROY:
79 // The window is being hidden or closed, clean it up.
80 LOGI("Destroying");
81 engine->app_backend->cleanup();
82 default:
83 break;
84 }
85}
86
87/*
88 * Key events filter to GameActivity's android_native_app_glue. This sample does

Callers

nothing calls this directly

Calls 3

resetMethod · 0.80
initVulkanMethod · 0.80
cleanupMethod · 0.80

Tested by

no test coverage detected