summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-09-08 10:27:47 +0200
committerJüri Valdmann <juri.valdmann@qt.io>2019-09-11 10:25:27 +0200
commitbc34784d053ebf9b0d167e9398052fcc80d8af87 (patch)
treec0c98a0e831155798111f4f0dc90e564bab299d9 /src/plugins/platforms
parent0fd6595d5e63fe1db429a0f242c7e98c6d2855f7 (diff)
Handle robustness with OpenGL < 4.0
We need to have the right idea of robustness, so check for extension. Fixes: QTBUG-78107 Change-Id: I26987269e5c50bee20e2e3cc6d75f91a6c9af25e Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
index 5e5fefca90..2b77062b16 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
@@ -63,6 +63,7 @@
QT_BEGIN_NAMESPACE
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
+typedef const GLubyte *(*glGetStringiProc)(GLenum, GLuint);
#ifndef GLX_CONTEXT_CORE_PROFILE_BIT_ARB
#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
@@ -145,6 +146,27 @@ static inline QByteArray getGlString(GLenum param)
return QByteArray();
}
+static bool hasGlExtension(const QSurfaceFormat &format, const char *ext)
+{
+ if (format.majorVersion() < 3) {
+ auto exts = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
+ return exts && strstr(exts, ext);
+ } else {
+ auto glGetStringi = reinterpret_cast<glGetStringiProc>(
+ glXGetProcAddress(reinterpret_cast<const GLubyte*>("glGetStringi")));
+ if (glGetStringi) {
+ GLint n = 0;
+ glGetIntegerv(GL_NUM_EXTENSIONS, &n);
+ for (GLint i = 0; i < n; ++i) {
+ const char *p = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
+ if (p && !strcmp(p, ext))
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
static void updateFormatFromContext(QSurfaceFormat &format)
{
// Update the version, profile, and context bit of the format
@@ -163,7 +185,7 @@ static void updateFormatFromContext(QSurfaceFormat &format)
format.setOption(QSurfaceFormat::StereoBuffers);
if (format.renderableType() == QSurfaceFormat::OpenGL) {
- if (format.version() >= qMakePair(4, 0)) {
+ if (hasGlExtension(format, "GL_ARB_robustness")) {
GLint value = 0;
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &value);
if (value == GL_LOSE_CONTEXT_ON_RESET_ARB)