home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / examples / opengl / overlay_x11 / utilities / sovinfo / sovinfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-07  |  2.6 KB  |  96 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1996. */
  3.  
  4. /* This program is freely distributable without licensing fees 
  5.    and is provided without guarantee or warrantee expressed or 
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. /* compile: cc -o sovinfo sovinfo.c sovLayerUtil.c -lX11 */
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include "sovLayerUtil.h"
  13.  
  14. int
  15. main(int argc, char *argv[])
  16. {
  17.   Display *dpy;
  18.   char *display_name, *arg, *class;
  19.   sovVisualInfo template, *lvinfo;
  20.   int nVisuals, i, overlaysOnly = 0;
  21.  
  22.   display_name = NULL;
  23.   for (i = 1; i < argc; i++) {
  24.     arg = argv[i];
  25.     if (!strcmp(arg, "-display")) {
  26.       if (++i >= argc) {
  27.         fprintf(stderr, "sovinfo: missing argument to -display\n");
  28.         exit(1);
  29.       }
  30.       display_name = argv[i];
  31.     } else if (!strcmp(arg, "-overlays_only")) {
  32.       overlaysOnly = 1;
  33.     } else {
  34.       fprintf(stderr,
  35.         "usage: sovinfo [-display dpy] [-overlays_only]\n");
  36.       exit(1);
  37.     }
  38.   }
  39.   dpy = XOpenDisplay(display_name);
  40.   if (dpy == NULL) {
  41.     fprintf(stderr, "sovinfo: cannot open display %s\n",
  42.       XDisplayName(NULL));
  43.     exit(1);
  44.   }
  45.   lvinfo = sovGetVisualInfo(dpy, 0L, &template, &nVisuals);
  46.   for (i = 0; i < nVisuals; i++) {
  47.     if (!overlaysOnly || lvinfo[i].layer > 0) {
  48.       printf("  Visual ID: 0x%x\n", lvinfo[i].vinfo.visualid);
  49.       printf("    screen: %d\n", lvinfo[i].vinfo.screen);
  50.       printf("    depth: %d\n", lvinfo[i].vinfo.depth);
  51.       switch (lvinfo[i].vinfo.class) {
  52.       case StaticGray:
  53.         class = "StaticGray";
  54.         break;
  55.       case GrayScale:
  56.         class = "GrayScale";
  57.         break;
  58.       case StaticColor:
  59.         class = "StaticColor";
  60.         break;
  61.       case PseudoColor:
  62.         class = "PseudoColor";
  63.         break;
  64.       case TrueColor:
  65.         class = "TrueColor";
  66.         break;
  67.       case DirectColor:
  68.         class = "DirectColor";
  69.         break;
  70.       default:
  71.         class = "Unknown";
  72.         break;
  73.       }
  74.       printf("    class: %s\n", class);
  75.       switch (lvinfo[i].type) {
  76.       case None:
  77.         printf("    transparent type: None\n");
  78.         break;
  79.       case TransparentPixel:
  80.         printf("    transparent type: TransparentPixel\n");
  81.         printf("    pixel value: %d\n", lvinfo[i].value);
  82.         break;
  83.       case TransparentMask:
  84.         printf("    transparent type: TransparentMask\n");
  85.         printf("    transparency mask: %0x%x\n", lvinfo[i].value);
  86.         break;
  87.       default:
  88.         printf("    transparent type: Unknown or invalid\n");
  89.         break;
  90.       }
  91.       printf("    layer: %d\n", lvinfo[i].layer);
  92.     }
  93.   }
  94.   return 0;
  95. }
  96.