test/testscale.c
changeset 7639 9406b7dd2f2d
parent 7517 965d57022c01
child 7787 e6f3e8fc96ea
equal deleted inserted replaced
7638:783d1cff9b20 7639:9406b7dd2f2d
    46     SDL_Texture *texture;
    46     SDL_Texture *texture;
    47 
    47 
    48     /* Load the sprite image */
    48     /* Load the sprite image */
    49     temp = SDL_LoadBMP(file);
    49     temp = SDL_LoadBMP(file);
    50     if (temp == NULL) {
    50     if (temp == NULL) {
    51         fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
    51         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
    52         return NULL;
    52         return NULL;
    53     }
    53     }
    54 
    54 
    55     /* Set transparent pixel as the pixel at (0,0) */
    55     /* Set transparent pixel as the pixel at (0,0) */
    56     if (transparent) {
    56     if (transparent) {
    77     }
    77     }
    78 
    78 
    79     /* Create textures from the image */
    79     /* Create textures from the image */
    80     texture = SDL_CreateTextureFromSurface(renderer, temp);
    80     texture = SDL_CreateTextureFromSurface(renderer, temp);
    81     if (!texture) {
    81     if (!texture) {
    82         fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
    82         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
    83         SDL_FreeSurface(temp);
    83         SDL_FreeSurface(temp);
    84         return NULL;
    84         return NULL;
    85     }
    85     }
    86     SDL_FreeSurface(temp);
    86     SDL_FreeSurface(temp);
    87 
    87 
   127     int i, done;
   127     int i, done;
   128     SDL_Event event;
   128     SDL_Event event;
   129     int frames;
   129     int frames;
   130     Uint32 then, now;
   130     Uint32 then, now;
   131 
   131 
       
   132     /* Enable standard application logging */
       
   133     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
       
   134 
   132     /* Initialize test framework */
   135     /* Initialize test framework */
   133     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   136     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   134     if (!state) {
   137     if (!state) {
   135         return 1;
   138         return 1;
   136     }
   139     }
   137     for (i = 1; i < argc;) {
   140     for (i = 1; i < argc;) {
   138         int consumed;
   141         int consumed;
   139 
   142 
   140         consumed = SDLTest_CommonArg(state, i);
   143         consumed = SDLTest_CommonArg(state, i);
   141         if (consumed == 0) {
   144         if (consumed == 0) {
   142             fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
   145             SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
   143             return 1;
   146             return 1;
   144         }
   147         }
   145         i += consumed;
   148         i += consumed;
   146     }
   149     }
   147     if (!SDLTest_CommonInit(state)) {
   150     if (!SDLTest_CommonInit(state)) {
   181 
   184 
   182     /* Print out some timing information */
   185     /* Print out some timing information */
   183     now = SDL_GetTicks();
   186     now = SDL_GetTicks();
   184     if (now > then) {
   187     if (now > then) {
   185         double fps = ((double) frames * 1000) / (now - then);
   188         double fps = ((double) frames * 1000) / (now - then);
   186         printf("%2.2f frames per second\n", fps);
   189         SDL_Log("%2.2f frames per second\n", fps);
   187     }
   190     }
   188 
   191 
   189     SDL_stack_free(drawstates);
   192     SDL_stack_free(drawstates);
   190 
   193 
   191     quit(0);
   194     quit(0);