Ejemplo n.º 1
0
Archivo: wglinfo.c Proyecto: iquiw/xsrc
int
main(int argc, char *argv[])
{
   HDC hdc;
   InfoMode mode = Normal;
   GLboolean findBest = GL_FALSE;
   GLboolean limits = GL_FALSE;
   GLboolean singleLine = GL_FALSE;
   int i;

   for (i = 1; i < argc; i++) {
      if (strcmp(argv[i], "-t") == 0) {
         mode = Wide;
      }
      else if (strcmp(argv[i], "-v") == 0) {
         mode = Verbose;
      }
      else if (strcmp(argv[i], "-b") == 0) {
         findBest = GL_TRUE;
      }
      else if (strcmp(argv[i], "-l") == 0) {
         limits = GL_TRUE;
      }
      else if (strcmp(argv[i], "-h") == 0) {
         usage();
         return 0;
      }
      else if(strcmp(argv[i], "-s") == 0) {
         singleLine = GL_TRUE;
      }
      else {
         printf("Unknown option `%s'\n", argv[i]);
         usage();
         return 0;
      }
   }

   hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);

   if (findBest) {
      int b;
      b = find_best_visual(hdc);
      printf("%d\n", b);
   }
   else {
      print_screen_info(hdc, limits, singleLine);
      printf("\n");
      print_visual_info(hdc, mode);
   }

   return 0;
}
Ejemplo n.º 2
0
int
main(int argc, char *argv[])
{
   char *displayName = NULL;
   Display *dpy;
   int numScreens, scrnum;
   InfoMode mode = Normal;
   GLboolean findBest = GL_FALSE;
   GLboolean limits = GL_FALSE;
   Bool allowDirect = True;
   int i;

   for (i = 1; i < argc; i++) {
      if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) {
         displayName = argv[i + 1];
         i++;
      }
      else if (strcmp(argv[i], "-t") == 0) {
         mode = Wide;
      }
      else if (strcmp(argv[i], "-v") == 0) {
         mode = Verbose;
      }
      else if (strcmp(argv[i], "-b") == 0) {
         findBest = GL_TRUE;
      }
      else if (strcmp(argv[i], "-i") == 0) {
         allowDirect = False;
      }
      else if (strcmp(argv[i], "-l") == 0) {
         limits = GL_TRUE;
      }
      else if (strcmp(argv[i], "-h") == 0) {
         usage();
         return 0;
      }
      else {
         printf("Unknown option `%s'\n", argv[i]);
         usage();
         return 0;
      }
   }

   dpy = XOpenDisplay(displayName);
   if (!dpy) {
      fprintf(stderr, "Error: unable to open display %s\n", displayName);
      return -1;
   }

   if (findBest) {
      int b;
      mesa_hack(dpy, 0);
      b = find_best_visual(dpy, 0);
      printf("%d\n", b);
   }
   else {
      numScreens = ScreenCount(dpy);
      print_display_info(dpy);
      for (scrnum = 0; scrnum < numScreens; scrnum++) {
         mesa_hack(dpy, scrnum);
         print_screen_info(dpy, scrnum, allowDirect, limits);
         printf("\n");
         print_visual_info(dpy, scrnum, mode);
         if (scrnum + 1 < numScreens)
            printf("\n\n");
      }
   }

   XCloseDisplay(dpy);

   return 0;
}
Ejemplo n.º 3
0
static struct DriverInstance*
X11_new_instance(const char* server_name,
                 int xpos, int ypos,
                 int width, int height, int mmx_supported,
                 char* error_text, int text_len)
{
  struct DriverInstance* sh = (struct DriverInstance*) malloc(sizeof(*sh));
  int screen;
  int err;
  const char* server_name_ptr;

  if (width > MAX_RES_X || height > MAX_RES_Y)
    {
      snprintf(error_text, text_len,
               "Max resolution (%ix%i) exceeded by given resolution (%i,%i)",
               MAX_RES_X, MAX_RES_Y, width, height);
      free(sh);
      return 0;
    }

  sh->mmx_supported   =  mmx_supported;
  sh->width           =  width;
  sh->height          =  height;
  sh->used_extensions =  0;
  sh->data            =  0;
  sh->data_size       =  0;
  sh->ximage          =  0;
  sh->image_width     =  0;
  sh->image_height    =  0;
  sh->shminfo.shmaddr =  0;
  sh->xv_port         =  0xffffffff;
  sh->xv_format_id    = -1;
  sh->xv_image        =  0;
  
  if (strcmp(server_name,"default") == 0)
    server_name_ptr = getenv("DISPLAY"); //use the DISPLAY environment variable
  else
    server_name_ptr = server_name; // use the userdefined display

  if (server_name_ptr == 0)
    {
      snprintf(error_text, text_len,
               "Don't know which display to use. Set the DISPLAY variable!");
      free(sh);
      return 0;
    }

  DEBUG_PRINTF("x11output: Connecting to '%s'...\n", server_name_ptr);

  sh->display = XOpenDisplay(server_name_ptr);
  if (sh->display == NULL)
    {
      snprintf(error_text, text_len,
               "Cannot connect to X server '%s'", server_name);
      free(sh);
      return 0;
    }
  
  if (check_xshm_extension(sh->display))
    {
      if (init_xshm_stuff(sh, error_text, text_len) != 0)
	  sh->used_extensions |= USE_XSHM;
      else
	  printf(" x11output: could not init XShm: '%s', turning off xshm\n",
		 error_text);
    }

  if (check_xv_extension(sh->display))
    {
      sh->used_extensions |= USE_XV;
    }

  screen = DefaultScreen(sh->display);
  sh->win = XCreateSimpleWindow(sh->display,
                                RootWindow(sh->display, screen),
                                xpos, ypos,
                                width, height,
                                0,
                                BlackPixel(sh->display, screen),
                                WhitePixel(sh->display, screen));
  //TODO: error handling
  
  XMapWindow(sh->display, sh->win);
  
  sh->gc = XCreateGC(sh->display, sh->win, 0, NULL);

  err = find_best_visual(sh->display, &sh->vis);
  if (err)
    {
      snprintf(error_text, text_len, "Could not find matching visual\n"
               "XServer must be set up at 24 bit depth or 16 bit depth");
      XDestroyWindow(sh->display, sh->win);
      deinit_xv_stuff(sh);
      free(sh);
      return 0;
    }

  if (sh->vis.depth == 16)
    {
      printf(" x11output: Screen set to 16bit color-depth. You might want to "
	     "switch\n to 24bit for better performance\n");
    }

  if ((sh->used_extensions & USE_XV) == USE_XV)
    {
      if (init_xv_stuff(sh, error_text, text_len) == 0)
        {
          printf(" x11output: turning off Xv support: '%s'\n",
                 error_text);

          sh->used_extensions &= ~USE_XV;
        }
    }

  if ((sh->used_extensions & USE_XSHM) == USE_XSHM)
    {
      if ((sh->used_extensions & USE_XV) == 0)
        {
          /* create shared memory ximage */
          sh->ximage = XShmCreateImage (sh->display,
                                        sh->vis.visual,
                                        sh->vis.depth,
                                        ZPixmap, 0, 
                                        &sh->shminfo, width, height);
          
          if (sh->ximage == 0)
            {
              snprintf(error_text, text_len, "Could not create xshm image");
              deinit_xv_stuff(sh);
              deinit_xshm_stuff(sh);
              XDestroyWindow(sh->display, sh->win);
              free(sh);
              return 0;
            }
          sh->ximage->data = sh->shminfo.shmaddr;
        }
    }

  if (sh->used_extensions & USE_XV)
    printf(" x11output: using Xv extension\n");

  if (sh->used_extensions & USE_XSHM)
    printf(" x11output: using XShm extension\n");

  XFlush( sh->display );

  return sh;
}
Ejemplo n.º 4
0
int
main(int argc, char *argv[])
{
   char *displayName = NULL;
   Display *dpy;
   int numScreens, scrnum;
   InfoMode mode = Normal;
   Bool findBest = False;
   Bool limits = False;
   Bool allowDirect = True;
   Bool singleLine = False;
   Bool coreWorked;
   int i;

   for (i = 1; i < argc; i++) {
      if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) {
         displayName = argv[i + 1];
         i++;
      }
      else if (strcmp(argv[i], "-t") == 0) {
         mode = Wide;
      }
      else if (strcmp(argv[i], "-v") == 0) {
         mode = Verbose;
      }
      else if (strcmp(argv[i], "-b") == 0) {
         findBest = True;
      }
      else if (strcmp(argv[i], "-i") == 0) {
         allowDirect = False;
      }
      else if (strcmp(argv[i], "-l") == 0) {
         limits = True;
      }
      else if (strcmp(argv[i], "-h") == 0) {
         usage();
         return 0;
      }
      else if (strcmp(argv[i], "-s") == 0) {
         singleLine = True;
      }
      else {
         printf("Unknown option `%s'\n", argv[i]);
         usage();
         return 0;
      }
   }

   dpy = XOpenDisplay(displayName);
   if (!dpy) {
      fprintf(stderr, "Error: unable to open display %s\n", XDisplayName(displayName));
      return -1;
   }

   if (findBest) {
      int b;
      mesa_hack(dpy, 0);
      b = find_best_visual(dpy, 0);
      printf("%d\n", b);
   }
   else {
      numScreens = ScreenCount(dpy);
      print_display_info(dpy);
      for (scrnum = 0; scrnum < numScreens; scrnum++) {
         mesa_hack(dpy, scrnum);
         coreWorked = print_screen_info(dpy, scrnum, allowDirect, True, False, limits, singleLine, False);
         print_screen_info(dpy, scrnum, allowDirect, False, False, limits, singleLine, coreWorked);
         print_screen_info(dpy, scrnum, allowDirect, False, True, False, singleLine, True);

         printf("\n");
         print_visual_info(dpy, scrnum, mode);
#ifdef GLX_VERSION_1_3
         print_fbconfig_info(dpy, scrnum, mode);
#endif
         if (scrnum + 1 < numScreens)
            printf("\n\n");
      }
   }

   XCloseDisplay(dpy);

   return 0;
}