diff options
Diffstat (limited to 'examples/studio3d/qmldynamickeyframes/main.cpp')
-rw-r--r-- | examples/studio3d/qmldynamickeyframes/main.cpp | 12 |
1 files changed, 12 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); |