summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2000-12-02 20:33:05 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2000-12-02 20:33:05 +0000
commitfac5fd258ca18f28290419f9de3f279f7b4a6ede (patch)
tree3b98f0ed304a03cc5b4d031a14bb6d3c13d3e22a /progs
parent785390137287cca1fd6ae61a4914cb71854396a8 (diff)
added -s option to control when glXSwapBuffers() is called
Diffstat (limited to 'progs')
-rw-r--r--progs/xdemos/manywin.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/progs/xdemos/manywin.c b/progs/xdemos/manywin.c
index 29462257fb8..797029cc4cb 100644
--- a/progs/xdemos/manywin.c
+++ b/progs/xdemos/manywin.c
@@ -1,4 +1,4 @@
-/* $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
@@ -50,6 +50,8 @@ struct head {
#define MAX_HEADS 200
static struct head Heads[MAX_HEADS];
static int NumHeads = 0;
+static GLboolean SwapSeparate = GL_TRUE;
+
static void
@@ -187,10 +189,17 @@ Redraw(struct head *h)
glEnd();
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
Resize(const struct head *h, unsigned int width, unsigned int height)
@@ -222,6 +231,8 @@ EventLoop(void)
switch (event.type) {
case Expose:
Redraw(h);
+ if (SwapSeparate)
+ Swap(h);
break;
case ConfigureNotify:
Resize(h, event.xconfigure.width, event.xconfigure.height);
@@ -236,7 +247,17 @@ EventLoop(void)
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);
}
@@ -265,13 +286,26 @@ main(int argc, char *argv[])
struct head *h;
printf("manywin: open N simultaneous glx windows\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(" manywin 10\n");
return 0;
}
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);
for (i = 0; i < n; i++) {
char name[100];