test/testvidinfo.c
branchSDL-1.3
changeset 1725 98a3207ddde8
parent 1668 4da1ee79c9af
equal deleted inserted replaced
1724:6c63fc2bd986 1725:98a3207ddde8
   415 
   415 
   416 int
   416 int
   417 main(int argc, char *argv[])
   417 main(int argc, char *argv[])
   418 {
   418 {
   419     const SDL_VideoInfo *info;
   419     const SDL_VideoInfo *info;
   420     int i, n;
   420     int i, d, n;
   421     const char *driver;
   421     const char *driver;
   422     const SDL_DisplayMode *mode;
   422     const SDL_DisplayMode *mode;
   423     int bpp;
   423     int bpp;
   424     Uint32 Rmask, Gmask, Bmask, Amask;
   424     Uint32 Rmask, Gmask, Bmask, Amask;
   425     int nmodes;
   425     int nmodes;
   446     driver = SDL_GetCurrentVideoDriver();
   446     driver = SDL_GetCurrentVideoDriver();
   447     if (driver) {
   447     if (driver) {
   448         printf("Video driver: %s\n", driver);
   448         printf("Video driver: %s\n", driver);
   449     }
   449     }
   450     printf("Number of displays: %d\n", SDL_GetNumVideoDisplays());
   450     printf("Number of displays: %d\n", SDL_GetNumVideoDisplays());
   451     mode = SDL_GetDesktopDisplayMode();
   451     for (d = 0; d < SDL_GetNumVideoDisplays(); ++d) {
   452     SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask, &Gmask, &Bmask,
   452         printf("Display %d:\n", d);
   453                                &Amask);
   453         SDL_SelectVideoDisplay(d);
   454     printf("Current display: %dx%d@%dHz, %d bits-per-pixel\n", mode->w,
   454 
   455            mode->h, mode->refresh_rate, bpp);
   455         mode = SDL_GetDesktopDisplayMode();
   456     if (Rmask || Gmask || Bmask) {
   456         SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask, &Gmask, &Bmask,
   457         printf("	Red Mask = 0x%.8x\n", Rmask);
   457                                    &Amask);
   458         printf("	Green Mask = 0x%.8x\n", Gmask);
   458         printf("  Current mode: %dx%d@%dHz, %d bits-per-pixel\n", mode->w,
   459         printf("	Blue Mask = 0x%.8x\n", Bmask);
   459                mode->h, mode->refresh_rate, bpp);
   460         if (Amask)
   460         if (Rmask || Gmask || Bmask) {
   461             printf("	Alpha Mask = 0x%.8x\n", Amask);
   461             printf("      Red Mask = 0x%.8x\n", Rmask);
   462     }
   462             printf("      Green Mask = 0x%.8x\n", Gmask);
   463     /* Print available fullscreen video modes */
   463             printf("      Blue Mask = 0x%.8x\n", Bmask);
   464     nmodes = SDL_GetNumDisplayModes();
   464             if (Amask)
   465     if (nmodes == 0) {
   465                 printf("      Alpha Mask = 0x%.8x\n", Amask);
   466         printf("No available fullscreen video modes\n");
   466         }
   467     } else {
   467 
   468         printf("Fullscreen video modes:\n");
   468         /* Print available fullscreen video modes */
   469         for (i = 0; i < nmodes; ++i) {
   469         nmodes = SDL_GetNumDisplayModes();
   470             mode = SDL_GetDisplayMode(i);
   470         if (nmodes == 0) {
   471             SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask,
   471             printf("No available fullscreen video modes\n");
   472                                        &Gmask, &Bmask, &Amask);
   472         } else {
   473             printf("Mode %d: %dx%d@%dHz, %d bits-per-pixel\n", i,
   473             printf("  Fullscreen video modes:\n");
   474                    mode->w, mode->h, mode->refresh_rate, bpp);
   474             for (i = 0; i < nmodes; ++i) {
   475             if (Rmask || Gmask || Bmask) {
   475                 mode = SDL_GetDisplayMode(i);
   476                 printf("	Red Mask = 0x%.8x\n", Rmask);
   476                 SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask,
   477                 printf("	Green Mask = 0x%.8x\n", Gmask);
   477                                            &Gmask, &Bmask, &Amask);
   478                 printf("	Blue Mask = 0x%.8x\n", Bmask);
   478                 printf("    Mode %d: %dx%d@%dHz, %d bits-per-pixel\n", i,
   479                 if (Amask)
   479                        mode->w, mode->h, mode->refresh_rate, bpp);
   480                     printf("	Alpha Mask = 0x%.8x\n", Amask);
   480                 if (Rmask || Gmask || Bmask) {
   481             }
   481                     printf("        Red Mask = 0x%.8x\n", Rmask);
   482         }
   482                     printf("        Green Mask = 0x%.8x\n", Gmask);
   483     }
   483                     printf("        Blue Mask = 0x%.8x\n", Bmask);
       
   484                     if (Amask)
       
   485                         printf("        Alpha Mask = 0x%.8x\n", Amask);
       
   486                 }
       
   487             }
       
   488         }
       
   489     }
       
   490 
   484     info = SDL_GetVideoInfo();
   491     info = SDL_GetVideoInfo();
   485     if (info->wm_available) {
   492     if (info->wm_available) {
   486         printf("A window manager is available\n");
   493         printf("A window manager is available\n");
   487     }
   494     }
   488     if (info->hw_available) {
   495     if (info->hw_available) {