Browse Source

Backed out 0869362ccc3c

The render target usage in controllermap is required if you are forced to use
the app at a different resolution than the one the art has been made for, for
example on Android, where you don't control the resolution.
(The coordinates for each button are hardcoded to the art size, and appear out
of place otherwise)
Gabriel Jacobo 11 years ago
parent
commit
9268c7a1b3
1 changed files with 5 additions and 1 deletions
  1. 5 1
      test/controllermap.c

+ 5 - 1
test/controllermap.c

@@ -101,7 +101,7 @@ WatchJoystick(SDL_Joystick * joystick)
 {
 {
     SDL_Window *window = NULL;
     SDL_Window *window = NULL;
     SDL_Renderer *screen = NULL;
     SDL_Renderer *screen = NULL;
-    SDL_Texture *background, *button, *axis, *marker;
+    SDL_Texture *target, *background, *button, *axis, *marker;
     const char *name = NULL;
     const char *name = NULL;
     SDL_bool retval = SDL_FALSE;
     SDL_bool retval = SDL_FALSE;
     SDL_bool done = SDL_FALSE, next=SDL_FALSE;
     SDL_bool done = SDL_FALSE, next=SDL_FALSE;
@@ -152,6 +152,7 @@ WatchJoystick(SDL_Joystick * joystick)
         return SDL_FALSE;
         return SDL_FALSE;
     }
     }
     
     
+    target = SDL_CreateTexture(screen, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, MAP_WIDTH, MAP_HEIGHT);
     background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE);
     background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE);
     button = LoadTexture(screen, "button.bmp", SDL_TRUE);
     button = LoadTexture(screen, "button.bmp", SDL_TRUE);
     axis = LoadTexture(screen, "axis.bmp", SDL_TRUE);
     axis = LoadTexture(screen, "axis.bmp", SDL_TRUE);
@@ -218,10 +219,13 @@ WatchJoystick(SDL_Joystick * joystick)
                 }
                 }
             }
             }
             
             
+            SDL_SetRenderTarget(screen, target);
             SDL_RenderCopy(screen, background, NULL, NULL);
             SDL_RenderCopy(screen, background, NULL, NULL);
             SDL_SetTextureAlphaMod(marker, alpha);
             SDL_SetTextureAlphaMod(marker, alpha);
             SDL_SetTextureColorMod(marker, 10, 255, 21);
             SDL_SetTextureColorMod(marker, 10, 255, 21);
             SDL_RenderCopyEx(screen, marker, NULL, &dst, step->angle, NULL, 0);
             SDL_RenderCopyEx(screen, marker, NULL, &dst, step->angle, NULL, 0);
+            SDL_SetRenderTarget(screen, NULL);
+            SDL_RenderCopy(screen, target, NULL, NULL);
             SDL_RenderPresent(screen);
             SDL_RenderPresent(screen);
             
             
             if (SDL_PollEvent(&event)) {
             if (SDL_PollEvent(&event)) {