1 #include <stdio.h>
2 #include "SDL.h"
3 
print_info(const SDL_VideoInfo * info)4 void print_info(const SDL_VideoInfo* info)
5 {
6   printf("hw_available: %d\n", info->hw_available);
7   printf("wm_available: %d\n", info->wm_available);
8   printf("blit_hw: %d\n", info->blit_hw);
9   printf("blit_hw_CC: %d\n", info->blit_hw_CC);
10   printf("blit_hw_A: %d\n", info->blit_hw_A);
11   printf("blit_sw: %d\n", info->blit_sw);
12   printf("blit_sw_CC: %d\n", info->blit_sw_CC);
13   printf("blit_sw_A: %d\n", info->blit_sw_A);
14   printf("blit_fill: %d\n", info->blit_fill);
15   printf("video_mem: %d\n", info->video_mem);
16   printf("current_w: %d\n", info->current_w);
17   printf("current_h: %d\n", info->current_h);
18   printf("Recommended depth: %d\n", info->vfmt->BitsPerPixel);
19   SDL_Surface *screen = SDL_GetVideoSurface();
20   if (screen != NULL)
21       printf("Current depth: %d\n", screen->format->BitsPerPixel);
22   printf("\n");
23 }
24 
main(void)25 int main(void)
26 {
27   const SDL_VideoInfo* info = NULL;
28   SDL_Init(SDL_INIT_VIDEO);
29 
30   info = SDL_GetVideoInfo();
31   print_info(info);
32 
33   SDL_SetVideoMode(0, 0, info->vfmt->BitsPerPixel, 0);
34 
35   info = SDL_GetVideoInfo();
36   print_info(info);
37 
38   printf("Requesting 8bit:\n");
39   SDL_SetVideoMode(800, 600, 8, 0);
40 
41   info = SDL_GetVideoInfo();
42   print_info(info);
43 
44   printf("Requesting 16bit:\n");
45   SDL_SetVideoMode(800, 600, 16, 0);
46 
47   info = SDL_GetVideoInfo();
48   print_info(info);
49 
50   printf("Requesting 24bit:\n");
51   SDL_SetVideoMode(800, 600, 24, 0);
52 
53   info = SDL_GetVideoInfo();
54   print_info(info);
55 
56   printf("Requesting 32bit:\n");
57   SDL_SetVideoMode(800, 600, 32, 0);
58 
59   info = SDL_GetVideoInfo();
60   print_info(info);
61 
62   SDL_Quit();
63   return 0;
64 }
65