summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2005-01-27 01:24:41 +0000
committerEric Anholt <anholt@freebsd.org>2005-01-27 01:24:41 +0000
commitf02f7e4cd2d2a628d59def61835ed9fa06de4c4f (patch)
tree30e8fa42b80376856163e0275bb6fb16d3c0abf2 /main.c
parent56890198e02cb2d63e6ca64264a4f2252c272978 (diff)
Add a simple manpage, and add commandline options for verbosity and display.
Diffstat (limited to 'main.c')
-rw-r--r--main.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/main.c b/main.c
index 68f9a81..c951270 100644
--- a/main.c
+++ b/main.c
@@ -27,12 +27,13 @@
#include <stdio.h>
#include <err.h>
#include <string.h>
+#include <getopt.h>
extern int num_ops;
extern int num_colors;
extern color4d colors[];
-int is_verbose = FALSE; /* XXX: Make me a command line arg */
+int is_verbose = FALSE;
/* Number of times to repeat operations so that pixmaps will tend to get moved
* into offscreen memory and allow hardware acceleration.
@@ -103,16 +104,41 @@ describe_format(char *desc, int len, XRenderPictFormat *format)
}
}
+
+static void
+usage (char *program)
+{
+ fprintf(stderr, "usage: %s [-d display] [-v]\n", program);
+ exit(1);
+}
+
int main(int argc, char **argv)
{
Display *dpy;
XEvent ev;
- int i, maj, min;
+ int i, o, maj, min;
XWindowAttributes a;
XSetWindowAttributes as;
picture_info window;
+ char *display = NULL;
+
+ while ((o = getopt (argc, argv, "d:v")) != -1) {
+ switch (o) {
+ case 'd':
+ display = optarg;
+ break;
+ case 'v':
+ is_verbose = TRUE;
+ break;
+ default:
+ usage(argv[0]);
+ break;
+ }
+ }
- dpy = XOpenDisplay(0);
+ dpy = XOpenDisplay(display);
+ if (dpy == NULL)
+ errx(1, "Couldn't open display.");
if (!XRenderQueryExtension(dpy, &i, &i))
errx(1, "Render extension missing.");
@@ -150,7 +176,6 @@ int main(int argc, char **argv)
XSelectInput(dpy, window.d, ExposureMask);
XMapWindow(dpy, window.d);
-
/* We have to premultiply the alpha into the r, g, b values of the
* sample colors. Render colors are premultiplied with alpha, so r,g,b
* can never be greater than alpha.