diff --git a/SakuraCore/src/Application.cpp b/SakuraCore/src/Application.cpp index bab04ee..86e4dc4 100644 --- a/SakuraCore/src/Application.cpp +++ b/SakuraCore/src/Application.cpp @@ -50,7 +50,11 @@ bool Application::Init() { m_AppData.windowdata.eventCallback = [this](Event &event) { RaiseEvent(event); }; m_Window.push_back(std::make_shared(m_AppData.windowdata)); - m_Window[0]->Create(); + bool isSuccessful = m_Window[0]->Create(); + if (!isSuccessful) { + Shutdown(); + return false; + } m_Renderer = SDL_CreateRenderer(GetSDLWindow(), nullptr); if (!m_Renderer) { diff --git a/SakuraCore/src/Window.cpp b/SakuraCore/src/Window.cpp index 778dfb7..b036c98 100644 --- a/SakuraCore/src/Window.cpp +++ b/SakuraCore/src/Window.cpp @@ -12,8 +12,7 @@ namespace SakuraVNE { Window::Window(const WindowData &data) : m_Data(data) {} Window::~Window() { Destroy(); } -void Window::Create(std::span flags) { - // TODO: maybe get an unknow amount of parameters / an array of window flags? or just provide a seperate function for it +bool Window::Create(std::span flags) { SDL_WindowFlags windowFlags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY); for (auto &flag : flags) { @@ -24,9 +23,7 @@ void Window::Create(std::span flags) { if (!m_Handle) { LOG_ERROR("SDL window could not be created! {0}", SDL_GetError()); - // FIX: there has to be a better way to shutdown this cannot be correct, because i just quit the sdl stuff but the init continues - Application::Get().Shutdown(); - return; + return false; } else { LOG_INFO("SDl window created"); } @@ -40,6 +37,8 @@ void Window::Create(std::span flags) { } else { LOG_WARN("SDL window position not set. Will not attempt to set window position."); } + + return true; } void Window::ProcessEvent(const SDL_Event &event) { diff --git a/SakuraCore/src/Window.h b/SakuraCore/src/Window.h index 6269b90..37c57d5 100644 --- a/SakuraCore/src/Window.h +++ b/SakuraCore/src/Window.h @@ -26,7 +26,7 @@ public: Window(const WindowData &data = WindowData()); ~Window(); - void Create(std::span flags = {}); + bool Create(std::span flags = {}); void Destroy(); void Update();