summaryrefslogtreecommitdiffstats
path: root/examples/studio3d/qmlstreamer/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/studio3d/qmlstreamer/main.cpp')
-rw-r--r--examples/studio3d/qmlstreamer/main.cpp12
1 files changed, 12 insertions, 0 deletions
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);