test/testgles.c
changeset 7639 9406b7dd2f2d
parent 7517 965d57022c01
child 7787 e6f3e8fc96ea
     1.1 --- a/test/testgles.c	Mon Aug 12 22:00:21 2013 -0700
     1.2 +++ b/test/testgles.c	Wed Aug 14 23:30:10 2013 -0700
     1.3 @@ -110,6 +110,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 = 0;
    1.13 @@ -143,7 +146,7 @@
    1.14              }
    1.15          }
    1.16          if (consumed < 0) {
    1.17 -            fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
    1.18 +            SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
    1.19                      SDLTest_CommonUsage(state));
    1.20              quit(1);
    1.21          }
    1.22 @@ -169,7 +172,7 @@
    1.23  
    1.24      context = SDL_calloc(state->num_windows, sizeof(context));
    1.25      if (context == NULL) {
    1.26 -        fprintf(stderr, "Out of memory!\n");
    1.27 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
    1.28          quit(2);
    1.29      }
    1.30  
    1.31 @@ -177,7 +180,7 @@
    1.32      for (i = 0; i < state->num_windows; i++) {
    1.33          context[i] = SDL_GL_CreateContext(state->windows[i]);
    1.34          if (!context[i]) {
    1.35 -            fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
    1.36 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
    1.37              quit(2);
    1.38          }
    1.39      }
    1.40 @@ -189,65 +192,65 @@
    1.41      }
    1.42  
    1.43      SDL_GetCurrentDisplayMode(0, &mode);
    1.44 -    printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
    1.45 -    printf("\n");
    1.46 -    printf("Vendor     : %s\n", glGetString(GL_VENDOR));
    1.47 -    printf("Renderer   : %s\n", glGetString(GL_RENDERER));
    1.48 -    printf("Version    : %s\n", glGetString(GL_VERSION));
    1.49 -    printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
    1.50 -    printf("\n");
    1.51 +    SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
    1.52 +    SDL_Log("\n");
    1.53 +    SDL_Log("Vendor     : %s\n", glGetString(GL_VENDOR));
    1.54 +    SDL_Log("Renderer   : %s\n", glGetString(GL_RENDERER));
    1.55 +    SDL_Log("Version    : %s\n", glGetString(GL_VERSION));
    1.56 +    SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
    1.57 +    SDL_Log("\n");
    1.58  
    1.59      status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
    1.60      if (!status) {
    1.61 -        printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
    1.62 +        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
    1.63      } else {
    1.64 -        fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n",
    1.65 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n",
    1.66                  SDL_GetError());
    1.67      }
    1.68      status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
    1.69      if (!status) {
    1.70 -        printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
    1.71 +        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
    1.72      } else {
    1.73 -        fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
    1.74 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
    1.75                  SDL_GetError());
    1.76      }
    1.77      status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
    1.78      if (!status) {
    1.79 -        printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
    1.80 +        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
    1.81      } else {
    1.82 -        fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
    1.83 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
    1.84                  SDL_GetError());
    1.85      }
    1.86      status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
    1.87      if (!status) {
    1.88 -        printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
    1.89 +        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
    1.90      } else {
    1.91 -        fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
    1.92 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
    1.93                  SDL_GetError());
    1.94      }
    1.95      if (fsaa) {
    1.96          status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
    1.97          if (!status) {
    1.98 -            printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
    1.99 +            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
   1.100          } else {
   1.101 -            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
   1.102 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
   1.103                      SDL_GetError());
   1.104          }
   1.105          status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
   1.106          if (!status) {
   1.107 -            printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
   1.108 +            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
   1.109                     value);
   1.110          } else {
   1.111 -            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
   1.112 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
   1.113                      SDL_GetError());
   1.114          }
   1.115      }
   1.116      if (accel) {
   1.117          status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
   1.118          if (!status) {
   1.119 -            printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
   1.120 +            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
   1.121          } else {
   1.122 -            fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
   1.123 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
   1.124                      SDL_GetError());
   1.125          }
   1.126      }
   1.127 @@ -258,7 +261,7 @@
   1.128  
   1.129          status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
   1.130          if (status) {
   1.131 -            printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   1.132 +            SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   1.133  
   1.134              /* Continue for next window */
   1.135              continue;
   1.136 @@ -292,7 +295,7 @@
   1.137                              if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
   1.138                                  status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
   1.139                                  if (status) {
   1.140 -                                    printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   1.141 +                                    SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   1.142                                      break;
   1.143                                  }
   1.144                                  /* Change view port to the new window dimensions */
   1.145 @@ -311,7 +314,7 @@
   1.146          for (i = 0; i < state->num_windows; ++i) {
   1.147              status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
   1.148              if (status) {
   1.149 -                printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   1.150 +                SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   1.151  
   1.152                  /* Continue for next window */
   1.153                  continue;
   1.154 @@ -324,7 +327,7 @@
   1.155      /* Print out some timing information */
   1.156      now = SDL_GetTicks();
   1.157      if (now > then) {
   1.158 -        printf("%2.2f frames per second\n",
   1.159 +        SDL_Log("%2.2f frames per second\n",
   1.160                 ((double) frames * 1000) / (now - then));
   1.161      }
   1.162      quit(0);
   1.163 @@ -336,7 +339,7 @@
   1.164  int
   1.165  main(int argc, char *argv[])
   1.166  {
   1.167 -    printf("No OpenGL ES support on this system\n");
   1.168 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n");
   1.169      return 1;
   1.170  }
   1.171