#include #include #include #include enum class CompositorCategory { Windows, MacOS, XCB, Wayland }; static CompositorCategory GetOSCompositorCategory() { const QString platform_name = QGuiApplication::platformName(); if (platform_name == QStringLiteral("windows")) return CompositorCategory::Windows; if (platform_name == QStringLiteral("xcb")) return CompositorCategory::XCB; if (platform_name == QStringLiteral("wayland") || platform_name == QStringLiteral("wayland-egl")) return CompositorCategory::Wayland; if (platform_name == QStringLiteral("cocoa") || platform_name == QStringLiteral("ios")) return CompositorCategory::MacOS; warn("Unknown Qt platform!"); return CompositorCategory::Windows; } RenderWidget::RenderWidget() { setAttribute(Qt::WA_NativeWindow); setAttribute(Qt::WA_PaintOnScreen); if (GetOSCompositorCategory() == CompositorCategory::Wayland) { setAttribute(Qt::WA_DontCreateNativeAncestors); } if (GetOSCompositorCategory() == CompositorCategory::MacOS) { windowHandle()->setSurfaceType(QWindow::MetalSurface); } else { windowHandle()->setSurfaceType(QWindow::VulkanSurface); } if (!Vulkan::Context::init_loader(nullptr)) { panic("Could not initialize Vulkan ICD"); } qtVkInstanceFactory = std::make_unique(); windowHandle()->setVulkanInstance(&qtVkInstanceFactory->handle); windowHandle()->create(); wsiPlatform = std::make_shared(windowHandle()); windowInfo = std::make_shared(windowHandle()); n64::Core &core = n64::Core::GetInstance(); core.parallel.Init(wsiPlatform, windowInfo, qtVkInstanceFactory.get(), core.GetMem().GetRDRAMPtr()); }