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