diff options
author | Tomi Korpipaa <tomi.korpipaa@qt.io> | 2017-11-29 10:08:22 +0200 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@qt.io> | 2017-11-29 08:16:38 +0000 |
commit | 345a80d2f346b73b09bd63122a68b545c60194d1 (patch) | |
tree | 05832d169cc1535a464814c9220f2f557ae15ac3 | |
parent | 520548872b7a54d9e47801abe03a4622354d93f5 (diff) |
Fix qml examples for macOS
Task-number: QT3DS-583
Change-Id: If51b8caf3cf5c3f8422cf17fa45fdfece10f2668
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r-- | examples/studio3d/qmldynamickeyframes/main.cpp | 12 | ||||
-rw-r--r-- | examples/studio3d/qmlstreamer/main.cpp | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/examples/studio3d/qmldynamickeyframes/main.cpp b/examples/studio3d/qmldynamickeyframes/main.cpp index adddbdce..12e3fa3c 100644 --- a/examples/studio3d/qmldynamickeyframes/main.cpp +++ b/examples/studio3d/qmldynamickeyframes/main.cpp @@ -64,6 +64,18 @@ int main(int argc, char *argv[]) #ifdef USE_EMBEDDED_FONTS qputenv("QT_QPA_FONTDIR","."); #endif + // To enable QOpenGLWidget to work on macOS, we must set the default + // QSurfaceFormat before QApplication is created. Otherwise context-sharing + // fails and QOpenGLWidget breaks. +#if defined(Q_OS_MACOS) + QSurfaceFormat openGLFormat; + openGLFormat.setRenderableType(QSurfaceFormat::OpenGL); + openGLFormat.setProfile(QSurfaceFormat::CoreProfile); + openGLFormat.setMajorVersion(4); + openGLFormat.setMinorVersion(1); + openGLFormat.setStencilBufferSize(8); + QSurfaceFormat::setDefaultFormat(openGLFormat); +#endif QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); diff --git a/examples/studio3d/qmlstreamer/main.cpp b/examples/studio3d/qmlstreamer/main.cpp index 82b640a8..09cd9f8b 100644 --- a/examples/studio3d/qmlstreamer/main.cpp +++ b/examples/studio3d/qmlstreamer/main.cpp @@ -62,6 +62,18 @@ int main(int argc, char *argv[]) #ifdef USE_EMBEDDED_FONTS qputenv("QT_QPA_FONTDIR","."); #endif + // To enable QOpenGLWidget to work on macOS, we must set the default + // QSurfaceFormat before QApplication is created. Otherwise context-sharing + // fails and QOpenGLWidget breaks. +#if defined(Q_OS_MACOS) + QSurfaceFormat openGLFormat; + openGLFormat.setRenderableType(QSurfaceFormat::OpenGL); + openGLFormat.setProfile(QSurfaceFormat::CoreProfile); + openGLFormat.setMajorVersion(4); + openGLFormat.setMinorVersion(1); + openGLFormat.setStencilBufferSize(8); + QSurfaceFormat::setDefaultFormat(openGLFormat); +#endif QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); |