progs/xdemos: fix up GLX extension checking
authorJesse Barnes <jbarnes@virtuousgeek.org>
Fri, 5 Mar 2010 19:21:12 +0000 (11:21 -0800)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Fri, 5 Mar 2010 19:22:05 +0000 (11:22 -0800)
A few of my programs were using the client string in addition to the
main extensions string to see if a feature was present.  Correct this to
only check for the currently available and working extensions.

progs/xdemos/glsync.c
progs/xdemos/msctest.c
progs/xdemos/omlsync.c

index c00ba9e..3751373 100644 (file)
@@ -63,10 +63,9 @@ void (*swap_interval)();
 
 static int GLXExtensionSupported(Display *dpy, const char *extension)
 {
-       const char *extensionsString, *client_extensions, *pos;
+       const char *extensionsString, *pos;
 
        extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
-       client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
 
        pos = strstr(extensionsString, extension);
 
@@ -74,12 +73,6 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
            (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
                return 1;
 
-       pos = strstr(client_extensions, extension);
-
-       if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
-           (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
-               return 1;
-
        return 0;
 }
 
@@ -235,7 +228,7 @@ int main(int argc, char *argv[])
 
        XMapWindow(disp, winGL);
        ret = glXMakeCurrent(disp, winGL, context);
-       if (ret) {
+       if (!ret) {
                fprintf(stderr, "failed to make context current: %d\n", ret);
        }
 
index 001ecf0..11b0434 100644 (file)
@@ -45,10 +45,9 @@ void (*wait_sync)(Display *dpy, Window winGL, int64_t target_msc, int64_t diviso
 
 static int GLXExtensionSupported(Display *dpy, const char *extension)
 {
-       const char *extensionsString, *client_extensions, *pos;
+       const char *extensionsString, *pos;
 
        extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
-       client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
 
        pos = strstr(extensionsString, extension);
 
@@ -56,12 +55,6 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
            (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
                return 1;
 
-       pos = strstr(client_extensions, extension);
-
-       if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
-           (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
-               return 1;
-
        return 0;
 }
 
@@ -167,8 +160,8 @@ int main(int argc, char *argv[])
 
        glXMakeCurrent(disp, winGL, context);
 
-       get_sync_values = glXGetProcAddress((unsigned char *)"glXGetSyncValuesOML");
-       wait_sync = glXGetProcAddress((unsigned char *)"glXWaitForMscOML");
+       get_sync_values = (void *)glXGetProcAddress((unsigned char *)"glXGetSyncValuesOML");
+       wait_sync = (void *)glXGetProcAddress((unsigned char *)"glXWaitForMscOML");
 
        if (!get_sync_values || !wait_sync) {
                fprintf(stderr, "failed to get sync values function\n");
index f2c1d13..a2baf4a 100644 (file)
@@ -73,10 +73,9 @@ int (*glXSwapInterval)(int interval);
 
 static int GLXExtensionSupported(Display *dpy, const char *extension)
 {
-       const char *extensionsString, *client_extensions, *pos;
+       const char *extensionsString, *pos;
 
        extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
-       client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
 
        pos = strstr(extensionsString, extension);
 
@@ -84,12 +83,6 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
            (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
                return 1;
 
-       pos = strstr(client_extensions, extension);
-
-       if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
-           (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
-               return 1;
-
        return 0;
 }