Brian Paul | 21666e3 | 2002-10-05 18:30:13 +0000 | [diff] [blame] | 1 | /* $Id: pbinfo.c,v 1.1 2002/10/05 18:30:13 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 | 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 | } |