f0b2f0eed4c85e3c6e60e4ff8eff9a3b81600d29
[mesa.git] / progs / xdemos / pbinfo.c
1 /* $Id: pbinfo.c,v 1.2 2003/04/21 14:51:16 brianp Exp $ */
2
3 /*
4 * Print list of fbconfigs and test each to see if a pbuffer can be created
5 * for that config.
6 *
7 * Brian Paul
8 * April 1997
9 * Updated on 5 October 2002.
10 */
11
12
13 #include <X11/Xlib.h>
14 #include <stdio.h>
15 #include <string.h>
16 #include "pbutil.h"
17
18
19
20
21 static void
22 PrintConfigs(Display *dpy, int screen, Bool horizFormat)
23 {
24 GLXFBConfigSGIX *fbConfigs;
25 int nConfigs;
26 int i;
27 /* Note: you may want to tweek the attribute list to select a different
28 * set of fbconfigs.
29 */
30 int fbAttribs[] = {
31 GLX_RENDER_TYPE_SGIX, 0,
32 GLX_DRAWABLE_TYPE_SGIX, 0,
33 #if 0
34 GLX_RENDER_TYPE_SGIX, GLX_RGBA_BIT_SGIX,
35 GLX_DRAWABLE_TYPE_SGIX, GLX_PIXMAP_BIT_SGIX,
36 GLX_RED_SIZE, 1,
37 GLX_GREEN_SIZE, 1,
38 GLX_BLUE_SIZE, 1,
39 GLX_DEPTH_SIZE, 1,
40 GLX_DOUBLEBUFFER, 0,
41 GLX_STENCIL_SIZE, 0,
42 #endif
43 None};
44
45
46 /* Get list of possible frame buffer configurations */
47 #if 0
48 /* SGIX method */
49 fbConfigs = glXChooseFBConfigSGIX(dpy, screen, fbAttribs, &nConfigs);
50 #else
51 /* GLX 1.3 method */
52 (void) fbAttribs;
53 fbConfigs = glXGetFBConfigs(dpy, screen, &nConfigs);
54 #endif
55
56 if (nConfigs==0 || !fbConfigs) {
57 printf("Error: glxChooseFBConfigSGIX failed\n");
58 return;
59 }
60
61 printf("Number of fbconfigs: %d\n", nConfigs);
62
63 if (horizFormat) {
64 printf(" ID VisualType Depth Lvl RGB CI DB Stereo R G B A");
65 printf(" Z S AR AG AB AA MSbufs MSnum Pbuffer\n");
66 }
67
68 /* Print config info */
69 for (i=0;i<nConfigs;i++) {
70 PrintFBConfigInfo(dpy, fbConfigs[i], horizFormat);
71 }
72
73 /* free the list */
74 XFree(fbConfigs);
75 }
76
77
78
79 static void
80 PrintUsage(void)
81 {
82 printf("Options:\n");
83 printf(" -display <display-name> specify X display name\n");
84 printf(" -t print in tabular format\n");
85 printf(" -v print in verbose format\n");
86 printf(" -help print this information\n");
87 }
88
89
90 int
91 main(int argc, char *argv[])
92 {
93 Display *dpy;
94 int scrn;
95 char *dpyName = NULL;
96 Bool horizFormat = True;
97 int i;
98
99 for (i=1; i<argc; i++) {
100 if (strcmp(argv[i],"-display")==0) {
101 if (i+1<argc) {
102 dpyName = argv[i+1];
103 i++;
104 }
105 }
106 else if (strcmp(argv[i],"-t")==0) {
107 /* tabular format */
108 horizFormat = True;
109 }
110 else if (strcmp(argv[i],"-v")==0) {
111 /* verbose format */
112 horizFormat = False;
113 }
114 else if (strcmp(argv[i],"-help")==0) {
115 PrintUsage();
116 return 0;
117 }
118 else {
119 printf("Unknown option: %s\n", argv[i]);
120 }
121 }
122
123 dpy = XOpenDisplay(dpyName);
124
125 if (!dpy) {
126 printf("Error: couldn't open display %s\n", dpyName ? dpyName : ":0");
127 return 1;
128 }
129
130 scrn = DefaultScreen(dpy);
131 PrintConfigs(dpy, scrn, horizFormat);
132 XCloseDisplay(dpy);
133 return 0;
134 }