Added os specific example main entry point macros
This commit is contained in:
parent
5803e166f5
commit
0ca94918db
1 changed files with 43 additions and 0 deletions
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue