progs/xdemos: fix up GLX extension checking

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.
This commit is contained in:
Jesse Barnes
2010-03-05 11:21:12 -08:00
parent 1ca968363d
commit f846a008e9
3 changed files with 6 additions and 27 deletions

View File

@@ -63,19 +63,12 @@ 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);
if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
(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;
@@ -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);
}

View File

@@ -45,19 +45,12 @@ 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);
if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
(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;
@@ -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");

View File

@@ -73,19 +73,12 @@ 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);
if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
(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;