test/testrendertarget.c
changeset 6785 c094c438c0a6
parent 6247 b6212690f78d
child 7013 fe82d15464d1
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)
   137     SDL_Event event;
   136     SDL_Event event;
   138     int frames;
   137     int frames;
   139     Uint32 then, now;
   138     Uint32 then, now;
   140 
   139 
   141     /* Initialize test framework */
   140     /* Initialize test framework */
   142     state = CommonCreateState(argv, SDL_INIT_VIDEO);
   141     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   143     if (!state) {
   142     if (!state) {
   144         return 1;
   143         return 1;
   145     }
   144     }
   146     for (i = 1; i < argc;) {
   145     for (i = 1; i < argc;) {
   147         int consumed;
   146         int consumed;
   148 
   147 
   149         consumed = CommonArg(state, i);
   148         consumed = SDLTest_CommonArg(state, i);
   150         if (consumed == 0) {
   149         if (consumed == 0) {
   151             fprintf(stderr, "Usage: %s %s\n", argv[0], CommonUsage(state));
   150             fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
   152             return 1;
   151             return 1;
   153         }
   152         }
   154         i += consumed;
   153         i += consumed;
   155     }
   154     }
   156     if (!CommonInit(state)) {
   155     if (!SDLTest_CommonInit(state)) {
   157         quit(2);
   156         quit(2);
   158     }
   157     }
   159 
   158 
   160     drawstates = SDL_stack_alloc(DrawState, state->num_windows);
   159     drawstates = SDL_stack_alloc(DrawState, state->num_windows);
   161     for (i = 0; i < state->num_windows; ++i) {
   160     for (i = 0; i < state->num_windows; ++i) {
   179     done = 0;
   178     done = 0;
   180     while (!done) {
   179     while (!done) {
   181         /* Check for events */
   180         /* Check for events */
   182         ++frames;
   181         ++frames;
   183         while (SDL_PollEvent(&event)) {
   182         while (SDL_PollEvent(&event)) {
   184             CommonEvent(state, &event, &done);
   183             SDLTest_CommonEvent(state, &event, &done);
   185         }
   184         }
   186         for (i = 0; i < state->num_windows; ++i) {
   185         for (i = 0; i < state->num_windows; ++i) {
   187             Draw(&drawstates[i]);
   186             Draw(&drawstates[i]);
   188         }
   187         }
   189     }
   188     }