summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dispatch_common.c26
-rw-r--r--src/dispatch_common.h1
-rwxr-xr-xsrc/gen_dispatch.py2
3 files changed, 22 insertions, 7 deletions
diff --git a/src/dispatch_common.c b/src/dispatch_common.c
index 4bd432e..a32b30b 100644
--- a/src/dispatch_common.c
+++ b/src/dispatch_common.c
@@ -138,21 +138,35 @@ epoxy_is_glx(void)
return true; /* XXX */
}
-PUBLIC int
-epoxy_glx_version(void)
+/**
+ * If we can determine the GLX version from the current context, then
+ * return that, otherwise return a version that will just send us on
+ * to dlsym() or get_proc_address().
+ */
+int
+epoxy_conservative_glx_version(void)
{
Display *dpy = glXGetCurrentDisplay();
GLXContext ctx = glXGetCurrentContext();
+ int screen;
+
+ if (!dpy || !ctx)
+ return 14;
+
+ glXQueryContext(dpy, ctx, GLX_SCREEN, &screen);
+
+ return epoxy_glx_version(dpy, screen);
+}
+
+PUBLIC int
+epoxy_glx_version(Display *dpy, int screen)
+{
int server_major, server_minor;
int client_major, client_minor;
int server, client;
const char *version_string;
- int screen = 0;
int ret;
- /* XXX: What if there's no current context? */
- glXQueryContext(dpy, ctx, GLX_SCREEN, &screen);
-
version_string = glXQueryServerString(dpy, screen, GLX_VERSION);
ret = sscanf(version_string, "%d.%d", &server_major, &server_minor);
assert(ret == 2);
diff --git a/src/dispatch_common.h b/src/dispatch_common.h
index cf90248..ed3fa5b 100644
--- a/src/dispatch_common.h
+++ b/src/dispatch_common.h
@@ -49,6 +49,7 @@ struct api {
bool epoxy_is_glx(void);
void *epoxy_get_proc_address(const char *name);
+int epoxy_conservative_glx_version(void);
void *epoxy_dlsym(const char *name);
void epoxy_glx_autoinit(void);
void epoxy_platform_autoinit(void);
diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py
index b402745..8b9cc54 100755
--- a/src/gen_dispatch.py
+++ b/src/gen_dispatch.py
@@ -292,7 +292,7 @@ class Generator(object):
# We could just always use GPA, but dlsym() is a more
# efficient lookup.
if version > 13:
- condition = condition + ' && epoxy_glx_version() >= {0}'.format(version)
+ condition = condition + ' && epoxy_conservative_glx_version() >= {0}'.format(version)
loader = self.gpa_loader
else:
loader = self.dlsym_loader