aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Elliott <ianelliott@google.com>2016-05-17 12:03:35 -0600
committerIan Elliott <ianelliott@google.com>2016-05-17 14:08:30 -0600
commitf05d5d11e4a72e5ebae2c89461c22b5319a1afe7 (patch)
treea6a48cb336f4fa746f242cb3664e11f9126e3c82
parentced9af88ebb9c37d24cb6cfbaa77104f73f977f6 (diff)
downloadusermoji-f05d5d11e4a72e5ebae2c89461c22b5319a1afe7.tar.xz
demos: GH#559 fix for new Android windows
On Android, treat a 1st-time new window differently from an nth-time new window.
-rw-r--r--demos/cube.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/demos/cube.c b/demos/cube.c
index bc391414..680e4245 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -3088,6 +3088,19 @@ static void processCommand(struct android_app* app, int32_t cmd) {
switch(cmd) {
case APP_CMD_INIT_WINDOW: {
if (app->window) {
+ // We're getting a new window. If the app is starting up, we
+ // need to initialize. If the app has already been
+ // initialized, that means that we lost our previous window,
+ // which means that we have a lot of work to do. At a minimum,
+ // we need to destroy the swapchain and surface associated with
+ // the old window, and create a new surface and swapchain.
+ // However, since there are a lot of other objects/state that
+ // is tied to the swapchain, it's easiest to simply cleanup and
+ // start over (i.e. use a brute-force approach of re-starting
+ // the app)
+ if (demo.prepared) {
+ demo_cleanup(&demo);
+ }
demo_init(&demo, 0, NULL);
demo.window = (void*)app->window;
demo_init_vk_swapchain(&demo);
@@ -3117,6 +3130,8 @@ void android_main(struct android_app *app)
return;
#endif
+ demo.prepared = false;
+
app->onAppCmd = processCommand;
app->onInputEvent = processInput;