#include <Qt3DQuickExtras/qt3dquickwindow.h>
#include <Qt3DQuick/QQmlAspectEngine>
#include <QGuiApplication>
#include <QQmlEngine>
#include <QQmlContext>
#include <QOpenGLContext>
#include <QQuickView>
int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
// Set to 1 to use Qt3DQuickWindow only
// Set to 2 to use default QQuickView+Scene3D
// Set to 3 to set a custom format to QtQuickView and use QQuickView+Scene3D
// Set to 4 to set a custom format as a default and use QQuickView+Scene3D
#define MODE 3
#if MODE == 1
Qt3DExtras::Quick::Qt3DQuickWindow view;
// Expose the window as a context property so we can set the aspect ratio
view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view);
view.setSource(QUrl("qrc:/WireMain.qml"));
view.show();
#endif
#if MODE == 2
QQuickView view;
view.resize(800, 600);
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:/main.qml"));
view.show();
#endif
#if MODE == 3
QSurfaceFormat format;
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
}
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setSamples(4);
QQuickView view;
view.setFormat(format);
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:/main.qml"));
view.setColor("#000000");
view.show();
#endif
#if MODE == 4
QSurfaceFormat format;
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
}
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setSamples(4);
QSurfaceFormat::setDefaultFormat(format);
QQmlApplicationEngine engine;
engine.load(QUrl(QLatin1String("qrc:/qml/main.qml")));
#endif
return app.exec();
}