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