test/testdraw2.c
changeset 6785 c094c438c0a6
parent 5535 96594ac5fd1a
child 7191 75360622e65f
equal deleted inserted replaced
6784:8fd20f04d5d9 6785:c094c438c0a6
    14 
    14 
    15 #include <stdlib.h>
    15 #include <stdlib.h>
    16 #include <stdio.h>
    16 #include <stdio.h>
    17 #include <time.h>
    17 #include <time.h>
    18 
    18 
    19 #include "common.h"
    19 #include "SDL_test_common.h"
    20 
    20 
    21 #define NUM_OBJECTS	100
    21 #define NUM_OBJECTS	100
    22 
    22 
    23 static CommonState *state;
    23 static SDLTest_CommonState *state;
    24 static int num_objects;
    24 static int num_objects;
    25 static SDL_bool cycle_color;
    25 static SDL_bool cycle_color;
    26 static SDL_bool cycle_alpha;
    26 static SDL_bool cycle_alpha;
    27 static int cycle_direction = 1;
    27 static int cycle_direction = 1;
    28 static int current_alpha = 255;
    28 static int current_alpha = 255;
   178 
   178 
   179     /* Initialize parameters */
   179     /* Initialize parameters */
   180     num_objects = NUM_OBJECTS;
   180     num_objects = NUM_OBJECTS;
   181 
   181 
   182     /* Initialize test framework */
   182     /* Initialize test framework */
   183     state = CommonCreateState(argv, SDL_INIT_VIDEO);
   183     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   184     if (!state) {
   184     if (!state) {
   185         return 1;
   185         return 1;
   186     }
   186     }
   187     for (i = 1; i < argc;) {
   187     for (i = 1; i < argc;) {
   188         int consumed;
   188         int consumed;
   189 
   189 
   190         consumed = CommonArg(state, i);
   190         consumed = SDLTest_CommonArg(state, i);
   191         if (consumed == 0) {
   191         if (consumed == 0) {
   192             consumed = -1;
   192             consumed = -1;
   193             if (SDL_strcasecmp(argv[i], "--blend") == 0) {
   193             if (SDL_strcasecmp(argv[i], "--blend") == 0) {
   194                 if (argv[i + 1]) {
   194                 if (argv[i + 1]) {
   195                     if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
   195                     if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
   218             }
   218             }
   219         }
   219         }
   220         if (consumed < 0) {
   220         if (consumed < 0) {
   221             fprintf(stderr,
   221             fprintf(stderr,
   222                     "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
   222                     "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
   223                     argv[0], CommonUsage(state));
   223                     argv[0], SDLTest_CommonUsage(state));
   224             return 1;
   224             return 1;
   225         }
   225         }
   226         i += consumed;
   226         i += consumed;
   227     }
   227     }
   228     if (!CommonInit(state)) {
   228     if (!SDLTest_CommonInit(state)) {
   229         return 2;
   229         return 2;
   230     }
   230     }
   231 
   231 
   232     /* Create the windows and initialize the renderers */
   232     /* Create the windows and initialize the renderers */
   233     for (i = 0; i < state->num_windows; ++i) {
   233     for (i = 0; i < state->num_windows; ++i) {
   245     done = 0;
   245     done = 0;
   246     while (!done) {
   246     while (!done) {
   247         /* Check for events */
   247         /* Check for events */
   248         ++frames;
   248         ++frames;
   249         while (SDL_PollEvent(&event)) {
   249         while (SDL_PollEvent(&event)) {
   250             CommonEvent(state, &event, &done);
   250             SDLTest_CommonEvent(state, &event, &done);
   251         }
   251         }
   252         for (i = 0; i < state->num_windows; ++i) {
   252         for (i = 0; i < state->num_windows; ++i) {
   253             SDL_Renderer *renderer = state->renderers[i];
   253             SDL_Renderer *renderer = state->renderers[i];
   254             SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
   254             SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
   255             SDL_RenderClear(renderer);
   255             SDL_RenderClear(renderer);
   260 
   260 
   261             SDL_RenderPresent(renderer);
   261             SDL_RenderPresent(renderer);
   262         }
   262         }
   263     }
   263     }
   264 
   264 
   265     CommonQuit(state);
   265     SDLTest_CommonQuit(state);
   266 
   266 
   267     /* Print out some timing information */
   267     /* Print out some timing information */
   268     now = SDL_GetTicks();
   268     now = SDL_GetTicks();
   269     if (now > then) {
   269     if (now > then) {
   270         double fps = ((double) frames * 1000) / (now - then);
   270         double fps = ((double) frames * 1000) / (now - then);