test/testgl2.c
changeset 7639 9406b7dd2f2d
parent 7517 965d57022c01
child 7746 6a05d7352575
     1.1 --- a/test/testgl2.c	Mon Aug 12 22:00:21 2013 -0700
     1.2 +++ b/test/testgl2.c	Wed Aug 14 23:30:10 2013 -0700
     1.3 @@ -181,6 +181,9 @@
     1.4      Uint32 then, now, frames;
     1.5      int status;
     1.6  
     1.7 +    /* Enable standard application logging */
     1.8 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
     1.9 +
    1.10      /* Initialize parameters */
    1.11      fsaa = 0;
    1.12      accel = -1;
    1.13 @@ -206,7 +209,7 @@
    1.14              }
    1.15          }
    1.16          if (consumed < 0) {
    1.17 -            fprintf(stderr, "Usage: %s %s [--fsaa n] [--accel n]\n", argv[0],
    1.18 +            SDL_Log("Usage: %s %s [--fsaa n] [--accel n]\n", argv[0],
    1.19                      SDLTest_CommonUsage(state));
    1.20              quit(1);
    1.21          }
    1.22 @@ -235,7 +238,7 @@
    1.23      /* Create OpenGL context */
    1.24      context = SDL_GL_CreateContext(state->windows[0]);
    1.25      if (!context) {
    1.26 -        fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
    1.27 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
    1.28          quit(2);
    1.29      }
    1.30  
    1.31 @@ -249,63 +252,63 @@
    1.32      }
    1.33  
    1.34      SDL_GetCurrentDisplayMode(0, &mode);
    1.35 -    printf("Screen BPP    : %d\n", SDL_BITSPERPIXEL(mode.format));
    1.36 -    printf("Swap Interval : %d\n", SDL_GL_GetSwapInterval());
    1.37 -    printf("\n");
    1.38 -    printf("Vendor        : %s\n", glGetString(GL_VENDOR));
    1.39 -    printf("Renderer      : %s\n", glGetString(GL_RENDERER));
    1.40 -    printf("Version       : %s\n", glGetString(GL_VERSION));
    1.41 -    printf("Extensions    : %s\n", glGetString(GL_EXTENSIONS));
    1.42 -    printf("\n");
    1.43 +    SDL_Log("Screen BPP    : %d\n", SDL_BITSPERPIXEL(mode.format));
    1.44 +    SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval());
    1.45 +    SDL_Log("\n");
    1.46 +    SDL_Log("Vendor        : %s\n", glGetString(GL_VENDOR));
    1.47 +    SDL_Log("Renderer      : %s\n", glGetString(GL_RENDERER));
    1.48 +    SDL_Log("Version       : %s\n", glGetString(GL_VERSION));
    1.49 +    SDL_Log("Extensions    : %s\n", glGetString(GL_EXTENSIONS));
    1.50 +    SDL_Log("\n");
    1.51  
    1.52      status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
    1.53      if (!status) {
    1.54 -        printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
    1.55 +        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
    1.56      } else {
    1.57 -        printf("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
    1.58 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
    1.59      }
    1.60      status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
    1.61      if (!status) {
    1.62 -        printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
    1.63 +        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
    1.64      } else {
    1.65 -        printf("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
    1.66 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
    1.67      }
    1.68      status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
    1.69      if (!status) {
    1.70 -        printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
    1.71 +        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
    1.72      } else {
    1.73 -        printf("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
    1.74 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
    1.75      }
    1.76      status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
    1.77      if (!status) {
    1.78 -        printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
    1.79 +        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
    1.80      } else {
    1.81 -        printf("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
    1.82 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
    1.83      }
    1.84      if (fsaa) {
    1.85          status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
    1.86          if (!status) {
    1.87 -            printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
    1.88 +            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
    1.89          } else {
    1.90 -            printf("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
    1.91 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
    1.92                     SDL_GetError());
    1.93          }
    1.94          status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
    1.95          if (!status) {
    1.96 -            printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
    1.97 +            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
    1.98                     value);
    1.99          } else {
   1.100 -            printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
   1.101 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
   1.102                     SDL_GetError());
   1.103          }
   1.104      }
   1.105      if (accel >= 0) {
   1.106          status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
   1.107          if (!status) {
   1.108 -            printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
   1.109 +            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
   1.110                     value);
   1.111          } else {
   1.112 -            printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
   1.113 +			SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
   1.114                     SDL_GetError());
   1.115          }
   1.116      }
   1.117 @@ -343,7 +346,7 @@
   1.118      /* Print out some timing information */
   1.119      now = SDL_GetTicks();
   1.120      if (now > then) {
   1.121 -        printf("%2.2f frames per second\n",
   1.122 +        SDL_Log("%2.2f frames per second\n",
   1.123                 ((double) frames * 1000) / (now - then));
   1.124      }
   1.125      quit(0);
   1.126 @@ -355,7 +358,7 @@
   1.127  int
   1.128  main(int argc, char *argv[])
   1.129  {
   1.130 -    printf("No OpenGL support on this system\n");
   1.131 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
   1.132      return 1;
   1.133  }
   1.134