mesa: fix build
[mesa.git] / progs / xdemos / pbinfo.c
1
2 /*
3 * Print list of fbconfigs and test each to see if a pbuffer can be created
4 * for that config.
5 *
6 * Brian Paul
7 * April 1997
8 * Updated on 5 October 2002.
9 */
10
11
12 #include <X11/Xlib.h>
13 #include <stdio.h>
14 #include <string.h>
15 #include "pbutil.h"
16
17
18
19
20 static void
21 PrintConfigs(Display *dpy, int screen, Bool horizFormat)
22 {
23 FBCONFIG *fbConfigs;
24 int nConfigs;
25 int i;
26
27 fbConfigs = GetAllFBConfigs(dpy, screen, &nConfigs);
28 if (!nConfigs || !fbConfigs) {
29 printf("Error: glxGetFBConfigs failed\n");
30 return;
31 }
32
33 printf("Number of fbconfigs: %d\n", nConfigs);
34
35 if (horizFormat) {
36 printf(" ID VisualType Depth Lvl RGB CI DB Stereo R G B A");
37 printf(" Z S AR AG AB AA MSbufs MSnum Pbuffer Float\n");
38 }
39
40 /* Print config info */
41 for (i = 0; i < nConfigs; i++) {
42 PrintFBConfigInfo(dpy, screen, fbConfigs[i], horizFormat);
43 }
44
45 /* free the list */
46 XFree(fbConfigs);
47 }
48
49
50
51 static void
52 PrintUsage(void)
53 {
54 printf("Options:\n");
55 printf(" -display <display-name> specify X display name\n");
56 printf(" -t print in tabular format\n");
57 printf(" -v print in verbose format\n");
58 printf(" -help print this information\n");
59 }
60
61
62 int
63 main(int argc, char *argv[])
64 {
65 Display *dpy;
66 int scrn;
67 char *dpyName = NULL;
68 Bool horizFormat = True;
69 int i;
70
71 for (i=1; i<argc; i++) {
72 if (strcmp(argv[i],"-display")==0) {
73 if (i+1<argc) {
74 dpyName = argv[i+1];
75 i++;
76 }
77 }
78 else if (strcmp(argv[i],"-t")==0) {
79 /* tabular format */
80 horizFormat = True;
81 }
82 else if (strcmp(argv[i],"-v")==0) {
83 /* verbose format */
84 horizFormat = False;
85 }
86 else if (strcmp(argv[i],"-help")==0) {
87 PrintUsage();
88 return 0;
89 }
90 else {
91 printf("Unknown option: %s\n", argv[i]);
92 }
93 }
94
95 dpy = XOpenDisplay(dpyName);
96
97 if (!dpy) {
98 printf("Error: couldn't open display %s\n", XDisplayName(dpyName));
99 return 1;
100 }
101
102 scrn = DefaultScreen(dpy);
103 PrintConfigs(dpy, scrn, horizFormat);
104 XCloseDisplay(dpy);
105 return 0;
106 }