blob: d4bc7e808363b45afa32238686a9961105cbb120 [file] [log] [blame]
Brian Paul21666e32002-10-05 18:30:13 +00001
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
20static void
21PrintConfigs(Display *dpy, int screen, Bool horizFormat)
22{
Brian Paulf72e4422005-01-04 00:58:29 +000023 FBCONFIG *fbConfigs;
Brian Paul21666e32002-10-05 18:30:13 +000024 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[] = {
Brian Paulf72e4422005-01-04 00:58:29 +000030 GLX_RENDER_TYPE, 0,
31 GLX_DRAWABLE_TYPE, 0,
Brian Paul21666e32002-10-05 18:30:13 +000032#if 0
Brian Paulf72e4422005-01-04 00:58:29 +000033 GLX_RENDER_TYPE, GLX_RGBA_BIT,
34 GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
Brian Paul21666e32002-10-05 18:30:13 +000035 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 */
Brian Paulf72e4422005-01-04 00:58:29 +000046 fbConfigs = ChooseFBConfig(dpy, screen, fbAttribs, &nConfigs);
47 if (!nConfigs || !fbConfigs) {
48 printf("Error: glxChooseFBConfig failed\n");
Brian Paul21666e32002-10-05 18:30:13 +000049 return;
50 }
51
52 printf("Number of fbconfigs: %d\n", nConfigs);
53
54 if (horizFormat) {
55 printf(" ID VisualType Depth Lvl RGB CI DB Stereo R G B A");
Brian Paulf72e4422005-01-04 00:58:29 +000056 printf(" Z S AR AG AB AA MSbufs MSnum Pbuffer Float\n");
Brian Paul21666e32002-10-05 18:30:13 +000057 }
58
59 /* Print config info */
60 for (i=0;i<nConfigs;i++) {
Brian Paulf72e4422005-01-04 00:58:29 +000061 PrintFBConfigInfo(dpy, screen, fbConfigs[i], horizFormat);
Brian Paul21666e32002-10-05 18:30:13 +000062 }
63
64 /* free the list */
65 XFree(fbConfigs);
66}
67
68
69
70static void
71PrintUsage(void)
72{
73 printf("Options:\n");
74 printf(" -display <display-name> specify X display name\n");
75 printf(" -t print in tabular format\n");
76 printf(" -v print in verbose format\n");
77 printf(" -help print this information\n");
78}
79
80
81int
82main(int argc, char *argv[])
83{
84 Display *dpy;
85 int scrn;
86 char *dpyName = NULL;
87 Bool horizFormat = True;
88 int i;
89
90 for (i=1; i<argc; i++) {
91 if (strcmp(argv[i],"-display")==0) {
92 if (i+1<argc) {
93 dpyName = argv[i+1];
94 i++;
95 }
96 }
97 else if (strcmp(argv[i],"-t")==0) {
98 /* tabular format */
99 horizFormat = True;
100 }
101 else if (strcmp(argv[i],"-v")==0) {
102 /* verbose format */
103 horizFormat = False;
104 }
105 else if (strcmp(argv[i],"-help")==0) {
106 PrintUsage();
107 return 0;
108 }
109 else {
110 printf("Unknown option: %s\n", argv[i]);
111 }
112 }
113
114 dpy = XOpenDisplay(dpyName);
115
116 if (!dpy) {
117 printf("Error: couldn't open display %s\n", dpyName ? dpyName : ":0");
118 return 1;
119 }
120
121 scrn = DefaultScreen(dpy);
122 PrintConfigs(dpy, scrn, horizFormat);
123 XCloseDisplay(dpy);
124 return 0;
125}