|
|
@@ -1,4 +1,3 @@
|
|
|
-// System/Qt headers
|
|
|
#include <QGuiApplication>
|
|
|
#include <QQmlApplicationEngine>
|
|
|
#include <QOpenGLContext>
|
|
|
@@ -9,21 +8,18 @@
|
|
|
#include <QQmlContext>
|
|
|
#include <QSGRendererInterface>
|
|
|
|
|
|
-// App headers
|
|
|
#include "app/game_engine.h"
|
|
|
#include "ui/gl_view.h"
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
|
- // Force desktop OpenGL + GLX path BEFORE any window is created.
|
|
|
if (qEnvironmentVariableIsSet("WAYLAND_DISPLAY") && qEnvironmentVariableIsSet("DISPLAY")) {
|
|
|
- qputenv("QT_QPA_PLATFORM", "xcb"); // prefer XCB/GLX over Wayland/EGL when XWayland is present
|
|
|
+ qputenv("QT_QPA_PLATFORM", "xcb");
|
|
|
}
|
|
|
- qputenv("QT_OPENGL", "desktop"); // desktop GL, not GLES/EGL
|
|
|
- qputenv("QSG_RHI_BACKEND", "opengl"); // OpenGL RHI
|
|
|
+ qputenv("QT_OPENGL", "desktop");
|
|
|
+ qputenv("QSG_RHI_BACKEND", "opengl");
|
|
|
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
|
|
|
|
|
|
- // Request desktop GL 3.3 core.
|
|
|
QSurfaceFormat fmt;
|
|
|
fmt.setVersion(3, 3);
|
|
|
fmt.setProfile(QSurfaceFormat::CoreProfile);
|
|
|
@@ -37,9 +33,7 @@ int main(int argc, char *argv[])
|
|
|
auto gameEngine = new GameEngine();
|
|
|
|
|
|
QQmlApplicationEngine engine;
|
|
|
- // Expose to QML BEFORE loading (safer if QML binds early).
|
|
|
engine.rootContext()->setContextProperty("game", gameEngine);
|
|
|
- // Register our GLView item so QML can embed the GL scene inside the scene graph
|
|
|
qmlRegisterType<GLView>("StandardOfIron", 1, 0, "GLView");
|
|
|
engine.load(QUrl(QStringLiteral("qrc:/StandardOfIron/ui/qml/Main.qml")));
|
|
|
if (engine.rootObjects().isEmpty()) {
|
|
|
@@ -55,11 +49,8 @@ int main(int argc, char *argv[])
|
|
|
return -2;
|
|
|
}
|
|
|
|
|
|
- // Let Qt Quick manage the clear; keep window color default.
|
|
|
-
|
|
|
gameEngine->setWindow(window);
|
|
|
|
|
|
- // Informative logging (no current-context check here).
|
|
|
QObject::connect(window, &QQuickWindow::sceneGraphInitialized, window, [window]() {
|
|
|
if (auto *ri = window->rendererInterface()) {
|
|
|
auto api = ri->graphicsApi();
|
|
|
@@ -78,12 +69,8 @@ int main(int argc, char *argv[])
|
|
|
app.exit(3);
|
|
|
});
|
|
|
|
|
|
-
|
|
|
qDebug() << "Application started successfully";
|
|
|
qDebug() << "Assets directory:" << QDir::currentPath() + "/assets";
|
|
|
|
|
|
return app.exec();
|
|
|
}
|
|
|
-
|
|
|
-// no Q_OBJECT in this TU anymore
|
|
|
-
|