diff --git a/core/rend/vulkan/vulkan_context.cpp b/core/rend/vulkan/vulkan_context.cpp index ef1c978d0..65ccce0a7 100644 --- a/core/rend/vulkan/vulkan_context.cpp +++ b/core/rend/vulkan/vulkan_context.cpp @@ -691,7 +691,8 @@ bool VulkanContext::Init() std::vector extensions; extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME); #if defined(USE_SDL) - sdl_recreate_window(SDL_WINDOW_VULKAN); + if (!sdl_recreate_window(SDL_WINDOW_VULKAN)) + return false; uint32_t extensionsCount = 0; SDL_Vulkan_GetInstanceExtensions((SDL_Window *)window, &extensionsCount, NULL); extensions.resize(extensionsCount + 1); diff --git a/core/sdl/sdl.cpp b/core/sdl/sdl.cpp index 1b0cc0e89..e2ad7dbb5 100644 --- a/core/sdl/sdl.cpp +++ b/core/sdl/sdl.cpp @@ -271,7 +271,7 @@ static void get_window_state() SDL_GetWindowSize(window, &window_width, &window_height); } -void sdl_recreate_window(u32 flags) +bool sdl_recreate_window(u32 flags) { int x = SDL_WINDOWPOS_UNDEFINED; int y = SDL_WINDOWPOS_UNDEFINED; @@ -295,8 +295,11 @@ void sdl_recreate_window(u32 flags) flags |= SDL_WINDOW_MAXIMIZED; #endif window = SDL_CreateWindow("Flycast", x, y, window_width, window_height, flags); - if (!window) - die("error creating SDL window"); + if (window == nullptr) + { + ERROR_LOG(COMMON, "Window creation failed: %s", SDL_GetError()); + return false; + } #ifndef _WIN32 // Set the window icon @@ -305,7 +308,7 @@ void sdl_recreate_window(u32 flags) pixels[i] = reicast_icon[i + 2]; SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(pixels, 48, 48, 32, 4 * 48, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); if (surface == NULL) - INFO_LOG(COMMON, "Creating surface failed: %s", SDL_GetError()); + INFO_LOG(COMMON, "Creating icon surface failed: %s", SDL_GetError()); else { SDL_SetWindowIcon(window, surface); @@ -317,6 +320,8 @@ void sdl_recreate_window(u32 flags) theVulkanContext.SetWindow(window, nullptr); #endif theGLContext.SetWindow(window); + + return true; } void sdl_window_create() diff --git a/core/sdl/sdl.h b/core/sdl/sdl.h index 27dd3bb53..2601ddd2c 100644 --- a/core/sdl/sdl.h +++ b/core/sdl/sdl.h @@ -2,12 +2,12 @@ #include #include "types.h" -extern void input_sdl_init(); -extern void input_sdl_handle(); -extern void sdl_window_create(); -extern void sdl_window_set_text(const char* text); -extern void sdl_window_destroy(); -extern void sdl_recreate_window(u32 flags); +void input_sdl_init(); +void input_sdl_handle(); +void sdl_window_create(); +void sdl_window_set_text(const char* text); +void sdl_window_destroy(); +bool sdl_recreate_window(u32 flags); #ifdef _WIN32 #include diff --git a/core/wsi/sdl.cpp b/core/wsi/sdl.cpp index 21ae11580..4bc58c620 100644 --- a/core/wsi/sdl.cpp +++ b/core/wsi/sdl.cpp @@ -47,7 +47,8 @@ bool SDLGLGraphicsContext::Init() SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - sdl_recreate_window(SDL_WINDOW_OPENGL); + if (!sdl_recreate_window(SDL_WINDOW_OPENGL)) + return false; glcontext = SDL_GL_CreateContext(window); if (!glcontext)