void (*video_sync_get)();
void (*video_sync)();
+void (*swap_interval)();
static int GLXExtensionSupported(Display *dpy, const char *extension)
{
extern char *optarg;
extern int optind, opterr, optopt;
-static char optstr[] = "w:h:s:v";
+static char optstr[] = "w:h:s:vi:";
enum sync_type {
none = 0,
printf("\t\tn: none\n");
printf("\t\ts: SGI video sync extension\n");
printf("\t\tb: buffer swap\n");
+ printf("\t-i<swap interval>\n");
printf("\t-v: verbose (print count)\n");
exit(-1);
}
Atom wmDelete;
enum sync_type waitforsync = none;
int width = 500, height = 500, verbose = 0,
- countonly = 0;
+ countonly = 0, interval = 1;
int c, i = 1;
opterr = 0;
case 'v':
verbose = 1;
break;
+ case 'i':
+ interval = atoi(optarg);
+ break;
default:
usage(argv[0]);
break;
video_sync_get = glXGetProcAddress((unsigned char *)"glXGetVideoSyncSGI");
video_sync = glXGetProcAddress((unsigned char *)"glXWaitVideoSyncSGI");
- if (!video_sync_get || !video_sync) {
+ swap_interval = glXGetProcAddress((unsigned char *)"glXSwapIntervalSGI");
+
+ if (!video_sync_get || !video_sync || !swap_interval) {
fprintf(stderr, "failed to get sync functions\n");
return -1;
}
+ swap_interval(interval);
+ fprintf(stderr, "set swap interval to %d\n", interval);
video_sync_get(&count);
count++;
while (i++) {
continue;
}
+ if (verbose) {
+ video_sync_get(&count);
+ fprintf(stderr, "current count: %d\n", count);
+ }
+
/* Alternate colors to make tearing obvious */
if (i & 1)
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);