diff options
author | Tomi Korpipaa <tomi.korpipaa@qt.io> | 2017-11-28 14:52:35 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2017-11-28 13:05:18 +0000 |
commit | c49afe176ba07082aa1eaba3c6a2b014a02e0827 (patch) | |
tree | e9a23636d29bca6c4734bd15a353bd24b5bc27f7 /examples | |
parent | a55ada093ccd3f90cec0456d6da14243b998bd8a (diff) |
Fix viewer scaling in macOS
Task-number: QT3DS-497
Change-Id: Id1ece6334a123960c796a4b7be238c680f2690e0
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/studio3d/widgetviewer/main.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/studio3d/widgetviewer/main.cpp b/examples/studio3d/widgetviewer/main.cpp index dd0b3a57..9ad8eed9 100644 --- a/examples/studio3d/widgetviewer/main.cpp +++ b/examples/studio3d/widgetviewer/main.cpp @@ -55,6 +55,22 @@ int main(int argc, char *argv[]) { + // to enable QOpenGLWidget to work on macOS, we must set the default + // QSurfaceFormat before QApplication is created. Otherwise context-sharing + // fails and QOpenGLWidget breaks. + + // fortunately, we know which OpenGL version we can use on macOS, so we + // can simply hard-code it here. +#if defined(Q_OS_MACOS) + QSurfaceFormat openGL33Format; + openGL33Format.setRenderableType(QSurfaceFormat::OpenGL); + openGL33Format.setProfile(QSurfaceFormat::CoreProfile); + openGL33Format.setMajorVersion(3); + openGL33Format.setMinorVersion(3); + openGL33Format.setStencilBufferSize(8); + QSurfaceFormat::setDefaultFormat(openGL33Format); +#endif + // Enable high DPI scaling QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |