From 945d17b6e92605de158839c488ebcafc19ac9aa6 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Thu, 20 Sep 2012 15:53:22 +0100 Subject: OpenGL: Add runtime check for OS X version and improve logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apple recommend adding NSOpenGLProfileVersion3_2Core when asking for a 3.2 Core profile context and NSOpenGLProfileVersionLegacy in all other cases. Also added a missing runtime check for OS X 10.7 or newer. Fixes a potential crash if Qt was built on 10.7/8 but executed on 10.6. Change-Id: I4c09d2dbbe8df25a3553cc01b468dabab0f8eaa4 Reviewed-by: Björn Breitmeyer Reviewed-by: Morten Johan Sørvig --- src/platformsupport/cglconvenience/cglconvenience.mm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm index 7ca9b6025e..3367373183 100644 --- a/src/platformsupport/cglconvenience/cglconvenience.mm +++ b/src/platformsupport/cglconvenience/cglconvenience.mm @@ -89,17 +89,22 @@ void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format) attrs.append(NSOpenGLPFADoubleBuffer); - if (format.profile() == QSurfaceFormat::CoreProfile) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if ((format.majorVersion() == 3 && format.minorVersion() >= 2) - || format.majorVersion() > 3 ) { + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { + if (format.profile() == QSurfaceFormat::CoreProfile + && ((format.majorVersion() == 3 && format.minorVersion() >= 2) + || format.majorVersion() > 3)) { attrs << NSOpenGLPFAOpenGLProfile; attrs << NSOpenGLProfileVersion3_2Core; + } else { + attrs << NSOpenGLPFAOpenGLProfile; + attrs << NSOpenGLProfileVersionLegacy; } + } #else + if (format.profile() == QSurfaceFormat::CoreProfile) qWarning("Mac OSX >= 10.7 is needed for OpenGL Core Profile support"); #endif - } if (format.depthBufferSize() > 0) attrs << NSOpenGLPFADepthSize << format.depthBufferSize(); -- cgit v1.2.3