test/testscale.c
changeset 6785 c094c438c0a6
parent 5535 96594ac5fd1a
child 7517 965d57022c01
equal deleted inserted replaced
6784:8fd20f04d5d9 6785:c094c438c0a6
    13 
    13 
    14 #include <stdlib.h>
    14 #include <stdlib.h>
    15 #include <stdio.h>
    15 #include <stdio.h>
    16 #include <time.h>
    16 #include <time.h>
    17 
    17 
    18 #include "SDL.h"
    18 #include "SDL_test_common.h"
    19 #include "common.h"
       
    20 
    19 
    21 #define WINDOW_WIDTH    640
    20 #define WINDOW_WIDTH    640
    22 #define WINDOW_HEIGHT   480
    21 #define WINDOW_HEIGHT   480
    23 
    22 
    24 static CommonState *state;
    23 static SDLTest_CommonState *state;
    25 
    24 
    26 typedef struct {
    25 typedef struct {
    27     SDL_Window *window;
    26     SDL_Window *window;
    28     SDL_Renderer *renderer;
    27     SDL_Renderer *renderer;
    29     SDL_Texture *background;
    28     SDL_Texture *background;
    34 
    33 
    35 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    34 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    36 static void
    35 static void
    37 quit(int rc)
    36 quit(int rc)
    38 {
    37 {
    39     CommonQuit(state);
    38     SDLTest_CommonQuit(state);
    40     exit(rc);
    39     exit(rc);
    41 }
    40 }
    42 
    41 
    43 SDL_Texture *
    42 SDL_Texture *
    44 LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
    43 LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
   129     SDL_Event event;
   128     SDL_Event event;
   130     int frames;
   129     int frames;
   131     Uint32 then, now;
   130     Uint32 then, now;
   132 
   131 
   133     /* Initialize test framework */
   132     /* Initialize test framework */
   134     state = CommonCreateState(argv, SDL_INIT_VIDEO);
   133     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   135     if (!state) {
   134     if (!state) {
   136         return 1;
   135         return 1;
   137     }
   136     }
   138     for (i = 1; i < argc;) {
   137     for (i = 1; i < argc;) {
   139         int consumed;
   138         int consumed;
   140 
   139 
   141         consumed = CommonArg(state, i);
   140         consumed = SDLTest_CommonArg(state, i);
   142         if (consumed == 0) {
   141         if (consumed == 0) {
   143             fprintf(stderr, "Usage: %s %s\n", argv[0], CommonUsage(state));
   142             fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
   144             return 1;
   143             return 1;
   145         }
   144         }
   146         i += consumed;
   145         i += consumed;
   147     }
   146     }
   148     if (!CommonInit(state)) {
   147     if (!SDLTest_CommonInit(state)) {
   149         quit(2);
   148         quit(2);
   150     }
   149     }
   151 
   150 
   152     drawstates = SDL_stack_alloc(DrawState, state->num_windows);
   151     drawstates = SDL_stack_alloc(DrawState, state->num_windows);
   153     for (i = 0; i < state->num_windows; ++i) {
   152     for (i = 0; i < state->num_windows; ++i) {
   171     done = 0;
   170     done = 0;
   172     while (!done) {
   171     while (!done) {
   173         /* Check for events */
   172         /* Check for events */
   174         ++frames;
   173         ++frames;
   175         while (SDL_PollEvent(&event)) {
   174         while (SDL_PollEvent(&event)) {
   176             CommonEvent(state, &event, &done);
   175             SDLTest_CommonEvent(state, &event, &done);
   177         }
   176         }
   178         for (i = 0; i < state->num_windows; ++i) {
   177         for (i = 0; i < state->num_windows; ++i) {
   179             Draw(&drawstates[i]);
   178             Draw(&drawstates[i]);
   180         }
   179         }
   181     }
   180     }