This commit is contained in:
parent
f09993bc15
commit
f86ff6dd27
2 changed files with 63 additions and 36 deletions
|
|
@ -370,7 +370,6 @@ void android_main(android_app* state) \
|
|||
}
|
||||
#elif defined(_DIRECT2DISPLAY)
|
||||
// Linux entry point with direct to display wsi
|
||||
// todo: extract command line arguments
|
||||
#define VULKAN_EXAMPLE_MAIN() \
|
||||
VulkanExample *vulkanExample; \
|
||||
static void handleEvent() \
|
||||
|
|
@ -378,6 +377,7 @@ 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->initSwapchain(); \
|
||||
|
|
@ -388,7 +388,6 @@ int main(const int argc, const char *argv[]) \
|
|||
}
|
||||
#elif defined(__linux__)
|
||||
// Linux entry point
|
||||
// todo: extract command line arguments
|
||||
#define VULKAN_EXAMPLE_MAIN() \
|
||||
VulkanExample *vulkanExample; \
|
||||
static void handleEvent(const xcb_generic_event_t *event) \
|
||||
|
|
|
|||
|
|
@ -1090,64 +1090,92 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
VulkanExample *vulkanExample;
|
||||
// OS specific macros for the example main entry points
|
||||
// Most of the code base is shared for the different supported operating systems, but stuff like message handling diffes
|
||||
|
||||
#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 != nullptr)
|
||||
if (vulkanExample != NULL)
|
||||
{
|
||||
vulkanExample->handleMessages(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||
}
|
||||
#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
|
||||
static void handleEvent(const xcb_generic_event_t *event)
|
||||
{
|
||||
if (vulkanExample != nullptr)
|
||||
{
|
||||
vulkanExample->handleEvent(event);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Main entry point
|
||||
#if defined(_WIN32)
|
||||
// Windows entry point
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
|
||||
{
|
||||
for (size_t i = 0; i < __argc; i++) { VulkanExample::args.push_back(__argv[i]); };
|
||||
vulkanExample = new VulkanExample();
|
||||
vulkanExample->initVulkan();
|
||||
vulkanExample->setupWindow(hInstance, WndProc);
|
||||
vulkanExample->initSwapchain();
|
||||
vulkanExample->prepare();
|
||||
vulkanExample->renderLoop();
|
||||
delete(vulkanExample);
|
||||
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()
|
||||
VulkanExample *vulkanExample;
|
||||
void android_main(android_app* state)
|
||||
#elif defined(__linux__)
|
||||
// Linux entry point
|
||||
int main(const int argc, const char *argv[])
|
||||
#endif
|
||||
{
|
||||
#if defined(__ANDROID__)
|
||||
// Removing this may cause the compiler to omit the main entry point
|
||||
// which would make the application crash at start
|
||||
app_dummy();
|
||||
#endif
|
||||
vulkanExample = new VulkanExample();
|
||||
#if defined(_WIN32)
|
||||
vulkanExample->setupWindow(hInstance, WndProc);
|
||||
#elif defined(__ANDROID__)
|
||||
// Attach vulkan example to global android application state
|
||||
state->userData = vulkanExample;
|
||||
state->onAppCmd = VulkanExample::handleAppCommand;
|
||||
state->onInputEvent = VulkanExample::handleAppInput;
|
||||
androidApp = state;
|
||||
#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
|
||||
vulkanExample->setupWindow();
|
||||
#endif
|
||||
#if !defined(__ANDROID__)
|
||||
vulkanExample->renderLoop();
|
||||
delete(vulkanExample);
|
||||
}
|
||||
#elif defined(_DIRECT2DISPLAY)
|
||||
|
||||
// Linux entry point with direct to display wsi
|
||||
// Direct to Displays (D2D) is used on embedded platforms
|
||||
#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->initSwapchain();
|
||||
vulkanExample->prepare();
|
||||
#endif
|
||||
vulkanExample->renderLoop();
|
||||
delete(vulkanExample);
|
||||
#if !defined(__ANDROID__)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
|
||||
// Linux entry point
|
||||
#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->initSwapchain();
|
||||
vulkanExample->prepare();
|
||||
vulkanExample->renderLoop();
|
||||
delete(vulkanExample);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue