sdl: fall back to open gl if vulkan init fails
This commit is contained in:
parent
49627eaf53
commit
417b470cbb
|
@ -691,7 +691,8 @@ bool VulkanContext::Init()
|
|||
std::vector<const char *> 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);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
#include <SDL2/SDL.h>
|
||||
#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 <windows.h>
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue