Use SDL_Log instead of fprintf(stderr) so errors show up on mobile platforms
authorSam Lantinga <slouken@libsdl.org>
Fri, 26 Oct 2018 15:08:22 -0700
changeset 6196f43400b7d77
parent 618 cbf3b5d96be6
child 620 083e81296e65
Use SDL_Log instead of fprintf(stderr) so errors show up on mobile platforms
showimage.c
     1.1 --- a/showimage.c	Fri Oct 26 15:07:24 2018 -0700
     1.2 +++ b/showimage.c	Fri Oct 26 15:08:22 2018 -0700
     1.3 @@ -64,7 +64,7 @@
     1.4  
     1.5      /* Check command line usage */
     1.6      if ( ! argv[1] ) {
     1.7 -        fprintf(stderr, "Usage: %s [-fullscreen] [-save file.png] <image_file> ...\n", argv[0]);
     1.8 +        SDL_Log("Usage: %s [-fullscreen] [-save file.png] <image_file> ...\n", argv[0]);
     1.9          return(1);
    1.10      }
    1.11  
    1.12 @@ -77,12 +77,12 @@
    1.13      }
    1.14  
    1.15      if (SDL_Init(SDL_INIT_VIDEO) == -1) {
    1.16 -        fprintf(stderr, "SDL_Init(SDL_INIT_VIDEO) failed: %s\n", SDL_GetError());
    1.17 +        SDL_Log("SDL_Init(SDL_INIT_VIDEO) failed: %s\n", SDL_GetError());
    1.18          return(2);
    1.19      }
    1.20  
    1.21      if (SDL_CreateWindowAndRenderer(0, 0, flags, &window, &renderer) < 0) {
    1.22 -        fprintf(stderr, "SDL_CreateWindowAndRenderer() failed: %s\n", SDL_GetError());
    1.23 +        SDL_Log("SDL_CreateWindowAndRenderer() failed: %s\n", SDL_GetError());
    1.24          return(2);
    1.25      }
    1.26  
    1.27 @@ -100,7 +100,7 @@
    1.28          /* Open the image file */
    1.29          texture = IMG_LoadTexture(renderer, argv[i]);
    1.30          if (!texture) {
    1.31 -            fprintf(stderr, "Couldn't load %s: %s\n", argv[i], SDL_GetError());
    1.32 +            SDL_Log("Couldn't load %s: %s\n", argv[i], SDL_GetError());
    1.33              continue;
    1.34          }
    1.35          SDL_QueryTexture(texture, NULL, NULL, &w, &h);
    1.36 @@ -119,10 +119,10 @@
    1.37                      result = IMG_SavePNG(surface, saveFile);
    1.38                  }
    1.39                  if ( result < 0 ) {
    1.40 -                    fprintf(stderr, "Couldn't save %s: %s\n", saveFile, SDL_GetError());
    1.41 +                    SDL_Log("Couldn't save %s: %s\n", saveFile, SDL_GetError());
    1.42                  }
    1.43              } else {
    1.44 -                fprintf(stderr, "Couldn't load %s: %s\n", argv[i], SDL_GetError());
    1.45 +                SDL_Log("Couldn't load %s: %s\n", argv[i], SDL_GetError());
    1.46              }
    1.47          }
    1.48