summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-01-16 10:18:00 +0100
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2015-01-19 08:10:28 +0100
commit5bb2e84a764f611cf4470f2ddc0bb427c4d110cc (patch)
tree91c96a0447b73c729642f0058dc626727254568c /src/plugins/platforms
parent3f17d0349b2d9c85491a6caaaee82918959ef5ef (diff)
Fall back to ANGLE on OpenGL 1.x
Apparently on some cards, that only provide OpenGL 1.4, the check for OpenGL 2 specific functions is not sufficient (presumably some old extensions provide the functions and so the test passes, even though it really shouldn't) To avoid crashing the apps later on, we should check the context version and activate the fall back to ANGLE if it's below 2.0. Task-number: QTBUG-43870 Change-Id: Id0e3d8ad1f632334ba03bbb1a4802413f28436dc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
index ac886b6bee..f6caf8b06e 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
@@ -43,6 +43,7 @@
# include <QtCore/qt_windows.h>
# include <private/qsystemlibrary_p.h>
# include <d3d9.h>
+# include <GL/gl.h>
#endif
QT_BEGIN_NAMESPACE
@@ -326,6 +327,37 @@ bool QWindowsOpenGLTester::testDesktopGL()
goto cleanup;
// Now that there is finally a context current, try doing something useful.
+
+ // Check the version. If we got 1.x then it's all hopeless and we can stop right here.
+ typedef const GLubyte * (APIENTRY * GetString_t)(GLenum name);
+ GetString_t GetString = reinterpret_cast<GetString_t>(::GetProcAddress(lib, "glGetString"));
+ if (GetString) {
+ const char *versionStr = (const char *) GetString(GL_VERSION);
+ if (versionStr) {
+ const QByteArray version(versionStr);
+ const int majorDot = version.indexOf('.');
+ if (majorDot != -1) {
+ int minorDot = version.indexOf('.', majorDot + 1);
+ if (minorDot == -1)
+ minorDot = version.size();
+ const int major = version.mid(0, majorDot).toInt();
+ const int minor = version.mid(majorDot + 1, minorDot - majorDot - 1).toInt();
+ qCDebug(lcQpaGl, "Basic wglCreateContext gives version %d.%d", major, minor);
+ // Try to be as lenient as possible. Missing version, bogus values and
+ // such are all accepted. The driver may still be functional. Only
+ // check for known-bad cases, like versions "1.4.0 ...".
+ if (major == 1) {
+ result = false;
+ qCDebug(lcQpaGl, "OpenGL version too low");
+ }
+ }
+ }
+ } else {
+ result = false;
+ qCDebug(lcQpaGl, "OpenGL 1.x entry points not found");
+ }
+
+ // Check for a shader-specific function.
if (WGL_GetProcAddress("glCreateShader")) {
result = true;
qCDebug(lcQpaGl, "OpenGL 2.0 entry points available");