Error handling.

This commit is contained in:
BearOso 2023-02-02 14:57:48 -06:00
parent fd3a9dba14
commit 246a44a940
2 changed files with 22 additions and 8 deletions

View File

@ -927,8 +927,13 @@ static void S9xInitDriver()
if (driver->init())
{
delete driver;
gui_config->display_driver = "none";
driver = new S9xGTKDisplayDriver(top_level, gui_config);
driver->init();
gui_config->display_driver = "none";
Gtk::MessageDialog dialog("Couldn't load display driver. Using default.");
dialog.run();
}
pool = NULL;

View File

@ -53,9 +53,10 @@ static vk::UniqueInstance create_instance_preamble(const char *wsi_extension)
#ifdef VK_USE_PLATFORM_WIN32_KHR
bool Context::init_win32(HINSTANCE hinstance, HWND hwnd, int preferred_device)
{
if (instance)
return false;
instance = create_instance_preamble(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
if (!instance)
return false;
auto win32_surface_create_info = vk::Win32SurfaceCreateInfoKHR{}
.setHinstance(hinstance)
.setHwnd(hwnd);
@ -69,10 +70,14 @@ bool Context::init_win32(HINSTANCE hinstance, HWND hwnd, int preferred_device)
#ifdef VK_USE_PLATFORM_XLIB_KHR
bool Context::init_Xlib(Display *dpy, Window xid, int preferred_device)
{
if (instance)
return false;
instance = create_instance_preamble(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
if (!instance)
return false;
surface = instance->createXlibSurfaceKHRUnique({ {}, dpy, xid });
if (!surface)
return false;
return init(preferred_device);
}
#endif
@ -80,13 +85,17 @@ bool Context::init_Xlib(Display *dpy, Window xid, int preferred_device)
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
bool Context::init_wayland(wl_display *dpy, wl_surface *parent, int initial_width, int initial_height, int preferred_device)
{
if (instance)
return false;
instance = create_instance_preamble(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
if (!instance)
return false;
auto wayland_surface_create_info = vk::WaylandSurfaceCreateInfoKHR{}
.setSurface(parent)
.setDisplay(dpy);
surface = instance->createWaylandSurfaceKHRUnique(wayland_surface_create_info);
if (!surface)
return false;
init_device(preferred_device);
init_vma();
init_command_pool();