diff --git a/src/modules/love/callbacks.lua b/src/modules/love/callbacks.lua index eaf53c4ce..d6672cee0 100644 --- a/src/modules/love/callbacks.lua +++ b/src/modules/love/callbacks.lua @@ -233,7 +233,7 @@ function love.errorhandler(msg) success, status = pcall(love.window.setMode, 800, 600) end if not success or not status then - love.window.showMessageBox("Error during startup", msg, "error", false) + love.window.showMessageBox("Initialization error", msg, "error", false) return end end diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 4ed2ccb58..f3b09669c 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -84,7 +84,6 @@ Window::Window() #ifdef LOVE_GRAPHICS_METAL , metalView(nullptr) #endif - , displayedWindowError(false) , contextAttribs() { if (!SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_EVENTS)) @@ -425,8 +424,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla if (failed) { - std::string title = "Unable to create renderer"; - std::string message = "This program requires a graphics card and video drivers which support OpenGL 3.3 or OpenGL ES 3.0."; + std::string message = "This program requires a graphics card and video drivers which support Vulkan, OpenGL 3.3, or OpenGL ES 3.0."; if (!glversion.empty()) message += "\n\nDetected OpenGL version:\n" + glversion; @@ -435,16 +433,9 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla else if (!windowerror.empty()) message += "\n\nSDL window creation error: " + windowerror; - std::cerr << title << std::endl << message << std::endl; + close(false); - // Display a message box with the error, but only once. - if (!displayedWindowError) - { - showMessageBox(title, message, MESSAGEBOX_ERROR, false); - displayedWindowError = true; - } - - close(); + throw love::Exception("Unable to create renderer.\n%s", message.c_str()); return false; } @@ -677,8 +668,15 @@ bool Window::setWindow(int width, int height, WindowSettings *settings) context = (void *) SDL_Metal_GetLayer(metalView); #endif - // TODO: try/catch - graphics->setMode(context, backbufferSettings); + try + { + graphics->setMode(context, backbufferSettings); + } + catch (std::exception &e) + { + close(false); + throw love::Exception("Failed to initialize graphics.\n%s", e.what()); + } } else { diff --git a/src/modules/window/sdl/Window.h b/src/modules/window/sdl/Window.h index c8d5ae70d..84b327a31 100644 --- a/src/modules/window/sdl/Window.h +++ b/src/modules/window/sdl/Window.h @@ -187,7 +187,6 @@ private: graphics::Renderer windowRenderer = graphics::RENDERER_NONE; - bool displayedWindowError; ContextAttribs contextAttribs; StrongRef graphics;