From 101a6bda4573237f0a31b1b947ea1af0fa7fb37c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 20 Oct 2015 12:54:48 +0200 Subject: Fix GL_VERSION parsing when using WGL Unlike other platforms and the EGL path, this one tries to parse GL_VERSION on its own. Unfortunately it breaks for certain version strings: we cannot assume more than major.minor in the beginning and so looking for a second dot is wrong. For example, "2.1 Mesa 7.11-devel" is parsed as major "2", minor "1 Mesa 7" (result in 0), leading to a version of 2.0 instead of 2.1. To overcome this, use the common helper function in QPlatformOpenGLContext. Change-Id: I460f4276a3a06659b542e0c076ddc1ada3122907 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsglcontext.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index a7c14ed2ac..e372acc747 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -856,16 +856,11 @@ QWindowsOpenGLContextFormat QWindowsOpenGLContextFormat::current() { QWindowsOpenGLContextFormat result; const QByteArray version = QOpenGLStaticContext::getGlString(GL_VERSION); - const int majorDot = version.indexOf('.'); - if (majorDot != -1) { - int minorDot = version.indexOf('.', majorDot + 1); - if (minorDot == -1) - minorDot = version.size(); - result.version = (version.mid(0, majorDot).toInt() << 8) - + version.mid(majorDot + 1, minorDot - majorDot - 1).toInt(); - } else { + int major, minor; + if (QPlatformOpenGLContext::parseOpenGLVersion(version, major, minor)) + result.version = (major << 8) + minor; + else result.version = 0x0200; - } result.profile = QSurfaceFormat::NoProfile; if (result.version < 0x0300) { result.options |= QSurfaceFormat::DeprecatedFunctions; -- cgit v1.2.3