diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2015-06-05 14:25:48 +0300 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2015-06-05 14:25:51 +0300 |
commit | 06e19e6fb191afa794f8018b67252940bc097fdd (patch) | |
tree | df7255fdb839338b600407e2b30be34f32c2e4f5 /overlay_gl | |
parent | 859da4dabec070959b5c06f8d32512990d7ec9c2 (diff) |
Check for Mesa rather than GLX > 1.2 when determining glXQueryDrawable GLX_WIDTH/GLX_HEIGHT availability.
You cannot query for GLX_WIDTH and GLX_HEIGHT using glXQueryDrawable in Mesa.
It simply fails with an error, and crashes the program:
X Error of failed request: GLXBadDrawable
Major opcode of failed request: 156 (GLX)
Minor opcode of failed request: 29 (X_GLXGetDrawableAttributes)
Serial number of failed request: 41
Current serial number in output stream: 41
The old check to only allow using glXQueryDrawable using GLX > 1.2
presumably worked for older Mesa versions, but now, Mesa advertises
GLX > 1.2.
That makes the overlay practically unusable when using Mesa.
This commit changes the code path to detect Mesa instead of GLX > 1.2,
and makes the overlay work correctly on Mesa once again.
Diffstat (limited to 'overlay_gl')
-rw-r--r-- | overlay_gl/init_unix.c | 20 | ||||
-rw-r--r-- | overlay_gl/overlay.c | 2 |
2 files changed, 14 insertions, 8 deletions
diff --git a/overlay_gl/init_unix.c b/overlay_gl/init_unix.c index 8df8a14eb..208057e11 100644 --- a/overlay_gl/init_unix.c +++ b/overlay_gl/init_unix.c @@ -80,31 +80,37 @@ void glXSwapBuffers(Display * dpy, GLXDrawable draw) { c->dpy = dpy; c->draw = draw; - c->bGlx = false; + c->bMesa = false; c->bValid = false; int major, minor; if (glXQueryVersion(dpy, &major, &minor)) { ods("GLX version %d.%d", major, minor); c->bValid = true; - if ((major > 1) || (major==1 && minor >= 3)) { - c->bGlx = true; + } + + const char *version = (const char *) glGetString(GL_VERSION); + if (version) { + ods("GL version string: %s", version); + if (strstr(version, "Mesa") != NULL) { + c->bMesa = true; } } + contexts = c; newContext(c); } if (c->bValid) { GLuint width, height; - if (c->bGlx) { - glXQueryDrawable(dpy, draw, GLX_WIDTH, (unsigned int *) &width); - glXQueryDrawable(dpy, draw, GLX_HEIGHT, (unsigned int *) &height); - } else { + if (c->bMesa) { GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); width = viewport[2]; height = viewport[3]; + } else { + glXQueryDrawable(dpy, draw, GLX_WIDTH, (unsigned int *) &width); + glXQueryDrawable(dpy, draw, GLX_HEIGHT, (unsigned int *) &height); } drawContext(c, width, height); diff --git a/overlay_gl/overlay.c b/overlay_gl/overlay.c index 9890b5ce8..847270d06 100644 --- a/overlay_gl/overlay.c +++ b/overlay_gl/overlay.c @@ -108,7 +108,7 @@ typedef struct _Context { unsigned int uiMappedLength; bool bValid; - bool bGlx; + bool bMesa; GLuint uiProgram; |