From 0ca94918db4e7c27a3b51a9326df2481912045f3 Mon Sep 17 00:00:00 2001 From: saschawillems Date: Sat, 25 Jun 2016 23:01:09 +0200 Subject: [PATCH] Added os specific example main entry point macros --- base/vulkanexamplebase.h | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index e05d89ec..70225b11 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -365,3 +365,46 @@ public: }; +// OS specific macros for the example main entry points +#if defined(_WIN32) +// Windows entry point +#define VULKAN_EXAMPLE_MAIN(example, enabledfeatures) \ +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) \ +{ \ + example = new VulkanExample(); \ + example->setupWindow(hInstance, WndProc); \ + example->initSwapchain(); \ + example->prepare(); \ + example->renderLoop(); \ + delete(example); \ + return 0; \ +} +#elif defined(__ANDROID__) +// Android entry point +// A note on app_dummy(): This is required as the compiler may otherwise remove the main entry point of the application +#define VULKAN_EXAMPLE_MAIN(example, enabledfeatures) \ +void android_main(android_app* state) \ +{ \ + app_dummy(); \ + example = new VulkanExample(); \ + state->userData = vulkanExample; \ + state->onAppCmd = VulkanExample::handleAppCommand; \ + state->onInputEvent = VulkanExample::handleAppInput; \ + vulkanExample->androidApp = state; \ + example->renderLoop(); \ + delete(example); \ +} +#elif defined(__linux__) +// Linux entry point +// todo: extract command line arguments +int main(const int argc, const char *argv[]) \ +{ \ + example = new VulkanExample(); \ + example->setupWindow(); \ + example->initSwapchain(); \ + example->prepare(); \ + example->renderLoop(); \ + delete(example); \ + return 0; \ +} +#endif \ No newline at end of file