OpenGL: Fix QGLFormat::openGLVersionFlags() on OS X
authorSean Harmer <sean.harmer@kdab.com>
Thu, 20 Sep 2012 14:55:46 +0000 (15:55 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 26 Sep 2012 17:20:58 +0000 (19:20 +0200)
OS X is limited to OpenGL 3.2 and we have to explicitly request a Core
profile context to get the full set of available versions as OS X does
not implement the Compatibility profile.

Change-Id: I8c2a6dc272416cbaf8fee44adbc4471417bf4510
Reviewed-by: Björn Breitmeyer <bjoern.breitmeyer@kdab.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
src/opengl/qgl_qpa.cpp

index edaa4c6..cc8d573 100644 (file)
@@ -314,8 +314,17 @@ QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
 #if !defined(QT_OPENGL_ES)
     // On desktop, request latest released version
     QSurfaceFormat format;
+#if defined(Q_OS_MAC)
+    // OS X is limited to OpenGL 3.2 Core Profile at present
+    // so set that here. If we use compatibility profile it
+    // only reports 2.x contexts.
+    format.setMajorVersion(3);
+    format.setMinorVersion(2);
+    format.setProfile(QSurfaceFormat::CoreProfile);
+#else
     format.setMajorVersion(4);
     format.setMinorVersion(3);
+#endif
     d->context->setFormat(format);
 #endif
     d->context->create();