Move entry point macros to separate header (#1120)
* Move entry point macros to separate header * Minor code cleanup * Updated macos CI
This commit is contained in:
parent
4d2117d3d9
commit
c598b1e7ab
5 changed files with 212 additions and 176 deletions
|
|
@ -414,152 +414,4 @@ public:
|
|||
#endif
|
||||
};
|
||||
|
||||
// OS specific macros for the example main entry points
|
||||
#if defined(_WIN32)
|
||||
// Windows entry point
|
||||
#define VULKAN_EXAMPLE_MAIN() \
|
||||
VulkanExample *vulkanExample; \
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) \
|
||||
{ \
|
||||
if (vulkanExample != NULL) \
|
||||
{ \
|
||||
vulkanExample->handleMessages(hWnd, uMsg, wParam, lParam); \
|
||||
} \
|
||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam)); \
|
||||
} \
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) \
|
||||
{ \
|
||||
for (int32_t i = 0; i < __argc; i++) { VulkanExample::args.push_back(__argv[i]); }; \
|
||||
vulkanExample = new VulkanExample(); \
|
||||
vulkanExample->initVulkan(); \
|
||||
vulkanExample->setupWindow(hInstance, WndProc); \
|
||||
vulkanExample->prepare(); \
|
||||
vulkanExample->renderLoop(); \
|
||||
delete(vulkanExample); \
|
||||
return 0; \
|
||||
}
|
||||
#elif defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
// Android entry point
|
||||
#define VULKAN_EXAMPLE_MAIN() \
|
||||
VulkanExample *vulkanExample; \
|
||||
void android_main(android_app* state) \
|
||||
{ \
|
||||
vulkanExample = new VulkanExample(); \
|
||||
state->userData = vulkanExample; \
|
||||
state->onAppCmd = VulkanExample::handleAppCommand; \
|
||||
state->onInputEvent = VulkanExample::handleAppInput; \
|
||||
androidApp = state; \
|
||||
vks::android::getDeviceConfig(); \
|
||||
vulkanExample->renderLoop(); \
|
||||
delete(vulkanExample); \
|
||||
}
|
||||
#elif defined(_DIRECT2DISPLAY)
|
||||
// Linux entry point with direct to display wsi
|
||||
#define VULKAN_EXAMPLE_MAIN() \
|
||||
VulkanExample *vulkanExample; \
|
||||
static void handleEvent() \
|
||||
{ \
|
||||
} \
|
||||
int main(const int argc, const char *argv[]) \
|
||||
{ \
|
||||
for (size_t i = 0; i < argc; i++) { VulkanExample::args.push_back(argv[i]); }; \
|
||||
vulkanExample = new VulkanExample(); \
|
||||
vulkanExample->initVulkan(); \
|
||||
vulkanExample->prepare(); \
|
||||
vulkanExample->renderLoop(); \
|
||||
delete(vulkanExample); \
|
||||
return 0; \
|
||||
}
|
||||
#elif defined(VK_USE_PLATFORM_DIRECTFB_EXT)
|
||||
#define VULKAN_EXAMPLE_MAIN() \
|
||||
VulkanExample *vulkanExample; \
|
||||
static void handleEvent(const DFBWindowEvent *event) \
|
||||
{ \
|
||||
if (vulkanExample != NULL) \
|
||||
{ \
|
||||
vulkanExample->handleEvent(event); \
|
||||
} \
|
||||
} \
|
||||
int main(const int argc, const char *argv[]) \
|
||||
{ \
|
||||
for (size_t i = 0; i < argc; i++) { VulkanExample::args.push_back(argv[i]); }; \
|
||||
vulkanExample = new VulkanExample(); \
|
||||
vulkanExample->initVulkan(); \
|
||||
vulkanExample->setupWindow(); \
|
||||
vulkanExample->prepare(); \
|
||||
vulkanExample->renderLoop(); \
|
||||
delete(vulkanExample); \
|
||||
return 0; \
|
||||
}
|
||||
#elif (defined(VK_USE_PLATFORM_WAYLAND_KHR) || defined(VK_USE_PLATFORM_HEADLESS_EXT))
|
||||
#define VULKAN_EXAMPLE_MAIN() \
|
||||
VulkanExample *vulkanExample; \
|
||||
int main(const int argc, const char *argv[]) \
|
||||
{ \
|
||||
for (size_t i = 0; i < argc; i++) { VulkanExample::args.push_back(argv[i]); }; \
|
||||
vulkanExample = new VulkanExample(); \
|
||||
vulkanExample->initVulkan(); \
|
||||
vulkanExample->setupWindow(); \
|
||||
vulkanExample->prepare(); \
|
||||
vulkanExample->renderLoop(); \
|
||||
delete(vulkanExample); \
|
||||
return 0; \
|
||||
}
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
#define VULKAN_EXAMPLE_MAIN() \
|
||||
VulkanExample *vulkanExample; \
|
||||
static void handleEvent(const xcb_generic_event_t *event) \
|
||||
{ \
|
||||
if (vulkanExample != NULL) \
|
||||
{ \
|
||||
vulkanExample->handleEvent(event); \
|
||||
} \
|
||||
} \
|
||||
int main(const int argc, const char *argv[]) \
|
||||
{ \
|
||||
for (size_t i = 0; i < argc; i++) { VulkanExample::args.push_back(argv[i]); }; \
|
||||
vulkanExample = new VulkanExample(); \
|
||||
vulkanExample->initVulkan(); \
|
||||
vulkanExample->setupWindow(); \
|
||||
vulkanExample->prepare(); \
|
||||
vulkanExample->renderLoop(); \
|
||||
delete(vulkanExample); \
|
||||
return 0; \
|
||||
}
|
||||
#elif (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
#if defined(VK_EXAMPLE_XCODE_GENERATED)
|
||||
#define VULKAN_EXAMPLE_MAIN() \
|
||||
VulkanExample *vulkanExample; \
|
||||
int main(const int argc, const char *argv[]) \
|
||||
{ \
|
||||
@autoreleasepool \
|
||||
{ \
|
||||
for (size_t i = 0; i < argc; i++) { VulkanExample::args.push_back(argv[i]); }; \
|
||||
vulkanExample = new VulkanExample(); \
|
||||
vulkanExample->initVulkan(); \
|
||||
vulkanExample->setupWindow(nullptr); \
|
||||
vulkanExample->prepare(); \
|
||||
vulkanExample->renderLoop(); \
|
||||
delete(vulkanExample); \
|
||||
} \
|
||||
return 0; \
|
||||
}
|
||||
#else
|
||||
#define VULKAN_EXAMPLE_MAIN()
|
||||
#endif
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_SCREEN_QNX)
|
||||
#define VULKAN_EXAMPLE_MAIN() \
|
||||
VulkanExample *vulkanExample; \
|
||||
int main(const int argc, const char *argv[]) \
|
||||
{ \
|
||||
for (int i = 0; i < argc; i++) { VulkanExample::args.push_back(argv[i]); }; \
|
||||
vulkanExample = new VulkanExample(); \
|
||||
vulkanExample->initVulkan(); \
|
||||
vulkanExample->setupWindow(); \
|
||||
vulkanExample->prepare(); \
|
||||
vulkanExample->renderLoop(); \
|
||||
delete(vulkanExample); \
|
||||
return 0; \
|
||||
}
|
||||
#endif
|
||||
#include "Entrypoints.h"
|
||||
Loading…
Add table
Add a link
Reference in a new issue