Window shows up!
This commit is contained in:
@@ -1,10 +1,49 @@
|
||||
#include <Core.hpp>
|
||||
#include <KaizenGui.hpp>
|
||||
#include <RenderWidget.hpp>
|
||||
#include <Core.hpp>
|
||||
#include <QGuiApplication>
|
||||
|
||||
RenderWidget::RenderWidget(QWindow *window) {
|
||||
wsiPlatform = std::make_shared<QtWSIPlatform>(window);
|
||||
windowInfo = std::make_shared<QtPrdpWindowInfo>(window);
|
||||
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<QtInstanceFactory>();
|
||||
|
||||
windowHandle()->setVulkanInstance(&qtVkInstanceFactory->handle);
|
||||
windowHandle()->create();
|
||||
|
||||
wsiPlatform = std::make_shared<QtWSIPlatform>(windowHandle());
|
||||
windowInfo = std::make_shared<QtPrdpWindowInfo>(windowHandle());
|
||||
n64::Core &core = n64::Core::GetInstance();
|
||||
core.parallel.Init(wsiPlatform, windowInfo, core.GetMem().GetRDRAMPtr());
|
||||
core.parallel.Init(wsiPlatform, windowInfo, qtVkInstanceFactory.get(), core.GetMem().GetRDRAMPtr());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user