diff --git a/editor/src/main.cpp b/editor/src/main.cpp index 2a5fe35..6cb37ae 100644 --- a/editor/src/main.cpp +++ b/editor/src/main.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -15,24 +16,27 @@ using namespace Nova; int main() { Debug::get_logger()->set_level(spdlog::level::trace); - auto wd = WindowDriver::create(); - auto rd = RenderDriver::create(RenderAPI::VULKAN, wd); + try { + auto wd = WindowDriver::create(); + auto rd = RenderDriver::create(RenderAPI::VULKAN, wd); - auto window = wd->create_window("Nova", 1280, 720); - auto surface = rd->create_surface(window); + auto window = wd->create_window("Nova", 1280, 720); + auto surface = rd->create_surface(window); - // TODO: select_device should probably consider what surface is - // being used as not all devices support all surfaces. alternatively - // the caller chould check if the device supports the surface - rd->select_device(RenderDevice::AUTO); + auto device = RenderDevice::choose_device(rd, surface); + rd->select_device(device); - while (wd->get_window_count() > 0) { - wd->poll_events(); + while (wd->get_window_count() > 0) { + wd->poll_events(); + } + + rd->destroy_surface(surface); + + delete rd; + delete wd; + return EXIT_SUCCESS; + } catch (const std::exception& e) { + NOVA_CRITICAL("Unhandled exception: {}", e.what()); + return EXIT_FAILURE; } - - rd->destroy_surface(surface); - - delete rd; - delete wd; - return EXIT_SUCCESS; }