From c21d769b7ffd02cfb15b7fab528a47fbb4988d88 Mon Sep 17 00:00:00 2001 From: saschawillems Date: Sun, 20 Mar 2016 20:04:27 +0100 Subject: [PATCH] Android render loop (wip) example base class (#97) --- base/vulkanexamplebase.cpp | 30 +++++++++++++++++++++++++++++- base/vulkanexamplebase.h | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index b4e15b09..5efb3d45 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -341,7 +341,35 @@ void VulkanExampleBase::renderLoop() } } #elif defined(__ANDROID__) - // todo : Android renderlopp + // todo : Application moved to background + while (1) + { + // Read all pending events. + int ident; + int events; + struct android_poll_source* source; + + while ((ident = ALooper_pollAll(animating ? 0 : -1, NULL, &events, (void**)&source)) >= 0) + { + if (source != NULL) + { + source->process(androidApp, source); + } + + if (androidApp->destroyRequested != 0) + { + // todo : free resources + //delete(vulkanExample); + return; + } + } + + // Render frame + if (prepared) + { + render(); + } + } #elif defined(__linux__) xcb_flush(connection); while (!quit) diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 2bec89f2..e33b6d63 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -157,6 +157,7 @@ public: HINSTANCE windowInstance; #elif defined(__ANDROID__) android_app* androidApp; + bool animating = true; #elif defined(__linux__) struct { bool left = false;