test/testnative.c
changeset 7639 9406b7dd2f2d
parent 7517 965d57022c01
child 8149 681eb46b8ac4
     1.1 --- a/test/testnative.c	Mon Aug 12 22:00:21 2013 -0700
     1.2 +++ b/test/testnative.c	Wed Aug 14 23:30:10 2013 -0700
     1.3 @@ -58,7 +58,7 @@
     1.4      /* Load the sprite image */
     1.5      temp = SDL_LoadBMP(file);
     1.6      if (temp == NULL) {
     1.7 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
     1.8 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
     1.9          return 0;
    1.10      }
    1.11  
    1.12 @@ -70,7 +70,7 @@
    1.13      /* Create textures from the image */
    1.14      sprite = SDL_CreateTextureFromSurface(renderer, temp);
    1.15      if (!sprite) {
    1.16 -        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
    1.17 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
    1.18          SDL_FreeSurface(temp);
    1.19          return 0;
    1.20      }
    1.21 @@ -131,8 +131,11 @@
    1.22      int sprite_w, sprite_h;
    1.23      SDL_Event event;
    1.24  
    1.25 +	/* Enable standard application logging */
    1.26 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    1.27 +
    1.28      if (SDL_VideoInit(NULL) < 0) {
    1.29 -        fprintf(stderr, "Couldn't initialize SDL video: %s\n",
    1.30 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n",
    1.31                  SDL_GetError());
    1.32          exit(1);
    1.33      }
    1.34 @@ -146,19 +149,19 @@
    1.35          }
    1.36      }
    1.37      if (!factory) {
    1.38 -        fprintf(stderr, "Couldn't find native window code for %s driver\n",
    1.39 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n",
    1.40                  driver);
    1.41          quit(2);
    1.42      }
    1.43 -    printf("Creating native window for %s driver\n", driver);
    1.44 +    SDL_Log("Creating native window for %s driver\n", driver);
    1.45      native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H);
    1.46      if (!native_window) {
    1.47 -        fprintf(stderr, "Couldn't create native window\n");
    1.48 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n");
    1.49          quit(3);
    1.50      }
    1.51      window = SDL_CreateWindowFrom(native_window);
    1.52      if (!window) {
    1.53 -        fprintf(stderr, "Couldn't create SDL window: %s\n", SDL_GetError());
    1.54 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError());
    1.55          quit(4);
    1.56      }
    1.57      SDL_SetWindowTitle(window, "SDL Native Window Test");
    1.58 @@ -166,7 +169,7 @@
    1.59      /* Create the renderer */
    1.60      renderer = SDL_CreateRenderer(window, -1, 0);
    1.61      if (!renderer) {
    1.62 -        fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
    1.63 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
    1.64          quit(5);
    1.65      }
    1.66  
    1.67 @@ -185,7 +188,7 @@
    1.68      positions = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
    1.69      velocities = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
    1.70      if (!positions || !velocities) {
    1.71 -        fprintf(stderr, "Out of memory!\n");
    1.72 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
    1.73          quit(2);
    1.74      }
    1.75      srand(time(NULL));