-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathmain.cpp
executable file
·57 lines (48 loc) · 1.79 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <QApplication> // QtCharts require QtWidgets QApplication ... interesting
#include <QOpenGLContext>
#include <QQmlApplicationEngine>
#include <QQuickStyle>
int main(int argc, char* argv[])
{
#ifdef Q_OS_WIN
QQuickStyle::setStyle("Universal");
#else
QQuickStyle::setStyle("Material");
#endif
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // Good for QuickControls, bad for canvas items
QApplication app(argc, argv); // Opengl dynamic module requires creating app first
QSurfaceFormat format;
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { // Learn OpenGL
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setVersion(4, 3);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setSamples(4);
} else if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { // Learn OpenGLES??
format.setRenderableType(QSurfaceFormat::OpenGLES);
format.setVersion(3, 0);
format.setSamples(0);
}
format.setAlphaBufferSize(0);
format.setDepthBufferSize(0);
format.setStencilBufferSize(0);
format.setSwapBehavior(QSurfaceFormat::TripleBuffer);
format.setSwapInterval(0); // Full speed rendering
QSurfaceFormat::setDefaultFormat(format);
QQmlApplicationEngine engine;
engine.addImportPath(QLatin1String("qrc:/com/github/midoriyakumo"));
#ifdef NO_APP_QRC
#ifdef Q_OS_ANDROID
engine.load(QUrl(QLatin1String("file:/sdcard/Documents/QML Projects/Examples/LearnOpenGL/app.qml")));
#else
engine.load(QUrl(QLatin1String("../qml/app.qml")));
#endif
#else
engine.load(QUrl(QLatin1String("qrc:/qml/app.qml")));
engine.rootObjects().at(0)->setProperty("qrcAppOn", true);
#endif
#ifndef NO_ASSETS_QRC
engine.rootObjects().at(0)->setProperty("qrcAssetsOn", true);
#endif
engine.rootObjects().at(0)->setProperty("title", "LearnOpenGL-Qt3D");
return app.exec();
}