From 60c40261511f75ad903756dec5c253ada74022d6 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Fri, 12 Jun 2015 23:10:19 -1000 Subject: [PATCH] Check minor and major versions from GL_VERSION GL_MAJOR_VERSION is only supported on OpenGL 3.0+ Fixes #116 --- src/mcedit2/util/qglcontext.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/mcedit2/util/qglcontext.py b/src/mcedit2/util/qglcontext.py index a94cfda..9487c9b 100644 --- a/src/mcedit2/util/qglcontext.py +++ b/src/mcedit2/util/qglcontext.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera from OpenGL import GL from PySide import QtOpenGL, QtGui import logging +import re log = logging.getLogger(__name__) @@ -39,10 +40,13 @@ def validateQGLContext(context): # Qt 4.8.6 on OS X always returns (1, 0) for the QGLFormat's major and minor versions. # (QTBUG-40415) - # Check GL_MAJOR_VERSION and GL_MINOR_VERSION instead. - - major = GL.glGetInteger(GL.GL_MAJOR_VERSION) - minor = GL.glGetInteger(GL.GL_MINOR_VERSION) + # Check GL_VERSION instead. + + version = GL.glGetString(GL.GL_VERSION) + match = re.match(r'^(\d+)\.(\d+)', version) + major, minor = match.groups() + major = int(major) + minor = int(minor) detailedText = "Obtained a GL context with this format:\n" detailedText += "Valid: %s\n" % (context.isValid(),) @@ -52,7 +56,7 @@ def validateQGLContext(context): detailedText += "Double buffer: %s\n" % (actualFormat.doubleBuffer(), ) detailedText += "\n" detailedText += "Driver info:\n" - detailedText += "GL_VERSION: %s (%s, %s)\n" % (GL.glGetString(GL.GL_VERSION), major, minor) + detailedText += "GL_VERSION: %s (%s, %s)\n" % (version, major, minor) detailedText += "GL_VENDOR: %s\n" % GL.glGetString(GL.GL_VENDOR) detailedText += "GL_RENDERER: %s\n" % GL.glGetString(GL.GL_RENDERER)