allocate application on heap instead of stack and delete it
This prevents problems with Vulkan debug layers that don't like Vulkan calls to happen during C++ app shutdown.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#include "WickedEngine.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
wi::Application application;
|
||||
wi::Application* application;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
application = new wi::Application();
|
||||
// SDL window setup:
|
||||
sdl2::sdlsystem_ptr_t system = sdl2::make_sdlsystem(SDL_INIT_EVERYTHING | SDL_INIT_EVENTS);
|
||||
sdl2::window_ptr_t window = sdl2::make_window(
|
||||
@@ -16,22 +17,22 @@ int main(int argc, char *argv[])
|
||||
SDL_Event event;
|
||||
|
||||
// set SDL window to engine:
|
||||
application.SetWindow(window.get());
|
||||
application->SetWindow(window.get());
|
||||
|
||||
// process command line string:
|
||||
wi::arguments::Parse(argc, argv);
|
||||
|
||||
// just show some basic info:
|
||||
application.infoDisplay.active = true;
|
||||
application.infoDisplay.watermark = true;
|
||||
application.infoDisplay.resolution = true;
|
||||
application.infoDisplay.fpsinfo = true;
|
||||
application->infoDisplay.active = true;
|
||||
application->infoDisplay.watermark = true;
|
||||
application->infoDisplay.resolution = true;
|
||||
application->infoDisplay.fpsinfo = true;
|
||||
|
||||
bool quit = false;
|
||||
while (!quit)
|
||||
{
|
||||
SDL_PumpEvents();
|
||||
application.Run();
|
||||
application->Run();
|
||||
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
@@ -48,7 +49,7 @@ int main(int argc, char *argv[])
|
||||
quit = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
application.SetWindow(application.window);
|
||||
application->SetWindow(application->window);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -62,6 +63,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
wi::jobsystem::ShutDown(); // waits for jobs to finish before shutdown
|
||||
|
||||
// explicitly deleting prevents issues with Vulkan debug layers (debugdevice)
|
||||
// which don't like vulkan calls happening during C++ application shutdown
|
||||
delete application;
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user