test/controllermap.c
changeset 8202 b84a1f55075e
parent 8201 4a16c26b6055
child 8631 2ce6d7f3cf40
     1.1 --- a/test/controllermap.c	Mon Feb 10 09:26:22 2014 -0300
     1.2 +++ b/test/controllermap.c	Mon Feb 10 11:29:48 2014 -0500
     1.3 @@ -101,7 +101,7 @@
     1.4  {
     1.5      SDL_Window *window = NULL;
     1.6      SDL_Renderer *screen = NULL;
     1.7 -    SDL_Texture *target, *background, *button, *axis, *marker;
     1.8 +    SDL_Texture *background, *button, *axis, *marker;
     1.9      const char *name = NULL;
    1.10      SDL_bool retval = SDL_FALSE;
    1.11      SDL_bool done = SDL_FALSE, next=SDL_FALSE;
    1.12 @@ -152,12 +152,14 @@
    1.13          return SDL_FALSE;
    1.14      }
    1.15      
    1.16 -    target = SDL_CreateTexture(screen, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, MAP_WIDTH, MAP_HEIGHT);
    1.17      background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE);
    1.18      button = LoadTexture(screen, "button.bmp", SDL_TRUE);
    1.19      axis = LoadTexture(screen, "axis.bmp", SDL_TRUE);
    1.20      SDL_RaiseWindow(window);
    1.21  
    1.22 +    /* scale for platforms that don't give you the window size you asked for. */
    1.23 +    SDL_RenderSetLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT);
    1.24 +
    1.25      /* Print info about the joystick we are watching */
    1.26      name = SDL_JoystickName(joystick);
    1.27      SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
    1.28 @@ -206,7 +208,9 @@
    1.29          dst.y = step->y;
    1.30          SDL_QueryTexture(marker, NULL, NULL, &dst.w, &dst.h);
    1.31          next=SDL_FALSE;
    1.32 -        
    1.33 +
    1.34 +        SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE);
    1.35 +
    1.36          while (!done && !next) {
    1.37              if (SDL_GetTicks() - alpha_ticks > 5) {
    1.38                  alpha_ticks = SDL_GetTicks();
    1.39 @@ -219,13 +223,11 @@
    1.40                  }
    1.41              }
    1.42              
    1.43 -            SDL_SetRenderTarget(screen, target);
    1.44 +            SDL_RenderClear(screen);
    1.45              SDL_RenderCopy(screen, background, NULL, NULL);
    1.46              SDL_SetTextureAlphaMod(marker, alpha);
    1.47              SDL_SetTextureColorMod(marker, 10, 255, 21);
    1.48              SDL_RenderCopyEx(screen, marker, NULL, &dst, step->angle, NULL, 0);
    1.49 -            SDL_SetRenderTarget(screen, NULL);
    1.50 -            SDL_RenderCopy(screen, target, NULL, NULL);
    1.51              SDL_RenderPresent(screen);
    1.52              
    1.53              if (SDL_PollEvent(&event)) {