Add graphics backend selection

This commit is contained in:
2026-07-13 10:19:29 +08:00
parent c74cc92879
commit 341283b1cd
8 changed files with 176 additions and 3 deletions
+13 -1
View File
@@ -41,6 +41,7 @@ extern "C" {
#include <QIcon>
#include <QSurfaceFormat>
#include "config/config.h"
#include "core.h"
#include "common/commandlineparser.h"
#include "common/debug.h"
@@ -300,7 +301,8 @@ int main(int argc, char *argv[])
startup_params.set_startup_project(project_argument->GetSetting());
// Set OpenGL display profile
// Set OpenGL display profile. Oak's render pipeline still uses OpenGL
// internally even when Vulkan is requested as the Qt graphics backend.
QSurfaceFormat format;
// Tries to cover all bases. If drivers don't support 3.2, they should fallback to the closest
@@ -338,6 +340,16 @@ int main(int argc, char *argv[])
a.reset(new QCoreApplication(argc, argv));
}
olive::Config::Load();
const QString graphics_backend =
olive::Config::Current()[QStringLiteral("GraphicsBackend")]
.toString()
.toLower();
qputenv("QSG_RHI_BACKEND",
graphics_backend == QStringLiteral("vulkan")
? QByteArrayLiteral("vulkan")
: QByteArrayLiteral("opengl"));
if (auto *gui_app = qobject_cast<QGuiApplication *>(a.get())) {
gui_app->setWindowIcon(QIcon(QStringLiteral(":/graphics/oak-logo.png")));
}