Browse Source

added -s option to control when glXSwapBuffers() is called

tags/mesa_3_5
Brian Paul 25 years ago
parent
commit
fac5fd258c
1 changed files with 39 additions and 5 deletions
  1. 39
    5
      progs/xdemos/manywin.c

+ 39
- 5
progs/xdemos/manywin.c View File

/* $Id: manywin.c,v 1.1 2000/06/13 19:41:30 brianp Exp $ */
/* $Id: manywin.c,v 1.2 2000/12/02 20:33:05 brianp Exp $ */


/* /*
* Create N GLX windows/contexts and render to them in round-robin * Create N GLX windows/contexts and render to them in round-robin
#define MAX_HEADS 200 #define MAX_HEADS 200
static struct head Heads[MAX_HEADS]; static struct head Heads[MAX_HEADS];
static int NumHeads = 0; static int NumHeads = 0;
static GLboolean SwapSeparate = GL_TRUE;





static void static void
glEnd(); glEnd();
glPopMatrix(); glPopMatrix();


glXSwapBuffers(h->Dpy, h->Win);
if (!SwapSeparate)
glXSwapBuffers(h->Dpy, h->Win);
} }




static void
Swap(struct head *h)
{
glXSwapBuffers(h->Dpy, h->Win);
}



static void static void
Resize(const struct head *h, unsigned int width, unsigned int height) Resize(const struct head *h, unsigned int width, unsigned int height)
switch (event.type) { switch (event.type) {
case Expose: case Expose:
Redraw(h); Redraw(h);
if (SwapSeparate)
Swap(h);
break; break;
case ConfigureNotify: case ConfigureNotify:
Resize(h, event.xconfigure.width, event.xconfigure.height); Resize(h, event.xconfigure.width, event.xconfigure.height);
printf("window mismatch\n"); printf("window mismatch\n");
} }
} }
Redraw(h);
}

/* redraw all windows */
for (i = 0; i < NumHeads; i++) {
Redraw(&Heads[i]);
}
/* swapbuffers on all windows, if not already done */
if (SwapSeparate) {
for (i = 0; i < NumHeads; i++) {
Swap(&Heads[i]);
}
} }
usleep(1); usleep(1);
} }
struct head *h; struct head *h;
printf("manywin: open N simultaneous glx windows\n"); printf("manywin: open N simultaneous glx windows\n");
printf("Usage:\n"); printf("Usage:\n");
printf(" manywin numWindows\n");
printf(" manywin [-s] numWindows\n");
printf("Options:\n");
printf(" -s = swap immediately after drawing (see src code)\n");
printf("Example:\n"); printf("Example:\n");
printf(" manywin 10\n"); printf(" manywin 10\n");
return 0; return 0;
} }
else { else {
int n = atoi(argv[1]);
int n = 3;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-s") == 0) {
SwapSeparate = GL_FALSE;
}
else {
n = atoi(argv[i]);
}
}
if (n < 1)
n = 1;

printf("%d windows\n", n); printf("%d windows\n", n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
char name[100]; char name[100];

Loading…
Cancel
Save