summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2017-11-28 14:52:35 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2017-11-28 13:05:18 +0000
commitc49afe176ba07082aa1eaba3c6a2b014a02e0827 (patch)
treee9a23636d29bca6c4734bd15a353bd24b5bc27f7
parenta55ada093ccd3f90cec0456d6da14243b998bd8a (diff)
Fix viewer scaling in macOS
Task-number: QT3DS-497 Change-Id: Id1ece6334a123960c796a4b7be238c680f2690e0 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--examples/studio3d/widgetviewer/main.cpp16
-rw-r--r--src/Runtime/Source/Viewer/Qt3DSViewerApp.cpp2
2 files changed, 16 insertions, 2 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);
diff --git a/src/Runtime/Source/Viewer/Qt3DSViewerApp.cpp b/src/Runtime/Source/Viewer/Qt3DSViewerApp.cpp
index 95658b3c..91bd1f28 100644
--- a/src/Runtime/Source/Viewer/Qt3DSViewerApp.cpp
+++ b/src/Runtime/Source/Viewer/Qt3DSViewerApp.cpp
@@ -520,13 +520,11 @@ void Q3DSViewerApp::Resize(int width, int height)
QSize newSize(width, height);
m_Impl.m_WindowSystem->SetWindowDimensions(newSize);
-#if !defined(Q_OS_MACOS)
if (m_Impl.m_appInitSuccessful && m_Impl.m_tegraApp
&& m_Impl.m_tegraApp->GetTegraRenderEngine()) {
QResizeEvent event = QResizeEvent(newSize, oldSize);
m_Impl.m_tegraApp->HandleMessage(&event);
}
-#endif
}
void Q3DSViewerApp::HandleKeyInput(Q3DStudio::EKeyCode inKeyCode, bool isPressed)