test/testoverlay2.c
changeset 7639 9406b7dd2f2d
parent 7517 965d57022c01
child 7677 871d43c6968a
     1.1 --- a/test/testoverlay2.c	Mon Aug 12 22:00:21 2013 -0700
     1.2 +++ b/test/testoverlay2.c	Wed Aug 14 23:30:10 2013 -0700
     1.3 @@ -209,19 +209,18 @@
     1.4  static void
     1.5  PrintUsage(char *argv0)
     1.6  {
     1.7 -    fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0);
     1.8 -    fprintf(stderr, "\n");
     1.9 -    fprintf(stderr, "Where 'arg' is any of the following options:\n");
    1.10 -    fprintf(stderr, "\n");
    1.11 -    fprintf(stderr, "    -fps <frames per second>\n");
    1.12 -    fprintf(stderr, "    -nodelay\n");
    1.13 -    fprintf(stderr, "    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
    1.14 -    fprintf(stderr, "    -scale <scale factor> (initial scale of the overlay)\n");
    1.15 -    fprintf(stderr, "    -help (shows this help)\n");
    1.16 -    fprintf(stderr, "\n");
    1.17 -    fprintf(stderr,
    1.18 -            "Press ESC to exit, or SPACE to freeze the movie while application running.\n");
    1.19 -    fprintf(stderr, "\n");
    1.20 +    SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0);
    1.21 +    SDL_Log("\n");
    1.22 +    SDL_Log("Where 'arg' is any of the following options:\n");
    1.23 +    SDL_Log("\n");
    1.24 +    SDL_Log("    -fps <frames per second>\n");
    1.25 +    SDL_Log("    -nodelay\n");
    1.26 +    SDL_Log("    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
    1.27 +    SDL_Log("    -scale <scale factor> (initial scale of the overlay)\n");
    1.28 +    SDL_Log("    -help (shows this help)\n");
    1.29 +    SDL_Log("\n");
    1.30 +    SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n");
    1.31 +    SDL_Log("\n");
    1.32  }
    1.33  
    1.34  int
    1.35 @@ -246,8 +245,11 @@
    1.36      int scale = 5;
    1.37      SDL_bool done = SDL_FALSE;
    1.38  
    1.39 +    /* Enable standard application logging */
    1.40 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    1.41 +
    1.42      if (SDL_Init(SDL_INIT_VIDEO) < 0) {
    1.43 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    1.44 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
    1.45          return 3;
    1.46      }
    1.47  
    1.48 @@ -256,19 +258,19 @@
    1.49              if (argv[2]) {
    1.50                  fps = atoi(argv[2]);
    1.51                  if (fps == 0) {
    1.52 -                    fprintf(stderr,
    1.53 +                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
    1.54                              "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
    1.55                      quit(10);
    1.56                  }
    1.57                  if ((fps < 0) || (fps > 1000)) {
    1.58 -                    fprintf(stderr,
    1.59 +                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
    1.60                              "The -fps option must be in range from 1 to 1000, default is 12.\n");
    1.61                      quit(10);
    1.62                  }
    1.63                  argv += 2;
    1.64                  argc -= 2;
    1.65              } else {
    1.66 -                fprintf(stderr,
    1.67 +                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
    1.68                          "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
    1.69                  quit(10);
    1.70              }
    1.71 @@ -280,19 +282,19 @@
    1.72              if (argv[2]) {
    1.73                  scale = atoi(argv[2]);
    1.74                  if (scale == 0) {
    1.75 -                    fprintf(stderr,
    1.76 +                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
    1.77                              "The -scale option requires an argument [from 1 to 50], default is 5.\n");
    1.78                      quit(10);
    1.79                  }
    1.80                  if ((scale < 0) || (scale > 50)) {
    1.81 -                    fprintf(stderr,
    1.82 +                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
    1.83                              "The -scale option must be in range from 1 to 50, default is 5.\n");
    1.84                      quit(10);
    1.85                  }
    1.86                  argv += 2;
    1.87                  argc -= 2;
    1.88              } else {
    1.89 -                fprintf(stderr,
    1.90 +                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
    1.91                          "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
    1.92                  quit(10);
    1.93              }
    1.94 @@ -301,7 +303,7 @@
    1.95              PrintUsage(argv[0]);
    1.96              quit(0);
    1.97          } else {
    1.98 -            fprintf(stderr, "Unrecognized option: %s.\n", argv[1]);
    1.99 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]);
   1.100              quit(10);
   1.101          }
   1.102          break;
   1.103 @@ -309,7 +311,7 @@
   1.104  
   1.105      RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
   1.106      if (RawMooseData == NULL) {
   1.107 -        fprintf(stderr, "Can't allocate memory for movie !\n");
   1.108 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
   1.109          free(RawMooseData);
   1.110          quit(1);
   1.111      }
   1.112 @@ -317,7 +319,7 @@
   1.113      /* load the trojan moose images */
   1.114      handle = SDL_RWFromFile("moose.dat", "rb");
   1.115      if (handle == NULL) {
   1.116 -        fprintf(stderr, "Can't find the file moose.dat !\n");
   1.117 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
   1.118          free(RawMooseData);
   1.119          quit(2);
   1.120      }
   1.121 @@ -335,21 +337,21 @@
   1.122                                window_w, window_h,
   1.123                                SDL_WINDOW_RESIZABLE);
   1.124      if (!window) {
   1.125 -        fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError());
   1.126 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
   1.127          free(RawMooseData);
   1.128          quit(4);
   1.129      }
   1.130  
   1.131      renderer = SDL_CreateRenderer(window, -1, 0);
   1.132      if (!renderer) {
   1.133 -        fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError());
   1.134 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
   1.135          free(RawMooseData);
   1.136          quit(4);
   1.137      }
   1.138  
   1.139      MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
   1.140      if (!MooseTexture) {
   1.141 -        fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError());
   1.142 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
   1.143          free(RawMooseData);
   1.144          quit(5);
   1.145      }