Xcode-iPhoneOS/Demos/src/keyboard.c
changeset 5364 fec676157db5
parent 5081 25d4feb7c127
     1.1 --- a/Xcode-iPhoneOS/Demos/src/keyboard.c	Sun Feb 20 14:16:11 2011 -0800
     1.2 +++ b/Xcode-iPhoneOS/Demos/src/keyboard.c	Sun Feb 20 14:22:27 2011 -0800
     1.3 @@ -23,6 +23,7 @@
     1.4  void cleanup(void);
     1.5  void drawBlank(int x, int y);
     1.6  
     1.7 +static SDL_Renderer *renderer;
     1.8  static int numChars = 0;        /* number of characters we've typed so far */
     1.9  static SDL_bool lastCharWasColon = 0;   /* we use this to detect sequences such as :) */
    1.10  static SDL_Color bg_color = { 50, 50, 100, 255 };       /* color of background */
    1.11 @@ -157,7 +158,7 @@
    1.12          { GLYPH_SIZE_IMAGE * index, 0, GLYPH_SIZE_IMAGE, GLYPH_SIZE_IMAGE };
    1.13      SDL_Rect dstRect = { x, y, GLYPH_SIZE_SCREEN, GLYPH_SIZE_SCREEN };
    1.14      drawBlank(x, y);
    1.15 -    SDL_RenderCopy(texture, &srcRect, &dstRect);
    1.16 +    SDL_RenderCopy(renderer, texture, &srcRect, &dstRect);
    1.17  }
    1.18  
    1.19  /*  draws the cursor icon at the current end position of the text */
    1.20 @@ -174,9 +175,9 @@
    1.21  drawBlank(int x, int y)
    1.22  {
    1.23      SDL_Rect rect = { x, y, GLYPH_SIZE_SCREEN, GLYPH_SIZE_SCREEN };
    1.24 -    SDL_SetRenderDrawColor(bg_color.r, bg_color.g, bg_color.b,
    1.25 +    SDL_SetRenderDrawColor(renderer, bg_color.r, bg_color.g, bg_color.b,
    1.26                             bg_color.unused);
    1.27 -    SDL_RenderFill(&rect);
    1.28 +    SDL_RenderFillRect(renderer, &rect);
    1.29  }
    1.30  
    1.31  /* moves backwards one character, erasing the last one put down */
    1.32 @@ -219,7 +220,7 @@
    1.33          SDL_BlitSurface(surface, NULL, converted, NULL);
    1.34          /* create our texture */
    1.35          texture =
    1.36 -            SDL_CreateTextureFromSurface(SDL_PIXELFORMAT_ABGR8888, converted);
    1.37 +            SDL_CreateTextureFromSurface(renderer, converted);
    1.38          if (texture == 0) {
    1.39              printf("texture creation failed: %s\n", SDL_GetError());
    1.40          } else {
    1.41 @@ -248,16 +249,16 @@
    1.42      /* create window */
    1.43      window = SDL_CreateWindow("iPhone keyboard test", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
    1.44      /* create renderer */
    1.45 -    SDL_CreateRenderer(window, 0, 0);
    1.46 +    renderer = SDL_CreateRenderer(window, -1, 0);
    1.47  
    1.48      /* load up our font */
    1.49      loadFont();
    1.50  
    1.51      /* draw the background, we'll just paint over it */
    1.52 -    SDL_SetRenderDrawColor(bg_color.r, bg_color.g, bg_color.b,
    1.53 +    SDL_SetRenderDrawColor(renderer, bg_color.r, bg_color.g, bg_color.b,
    1.54                             bg_color.unused);
    1.55 -    SDL_RenderFill(NULL);
    1.56 -    SDL_RenderPresent();
    1.57 +    SDL_RenderFillRect(renderer, NULL);
    1.58 +    SDL_RenderPresent(renderer);
    1.59  
    1.60      int done = 0;
    1.61      /* loop till we get SDL_Quit */
    1.62 @@ -293,7 +294,7 @@
    1.63              }
    1.64              /* check if the key was a colon */
    1.65              /* draw our updates to the screen */
    1.66 -            SDL_RenderPresent();
    1.67 +            SDL_RenderPresent(renderer);
    1.68              break;
    1.69  #ifdef __IPHONEOS__
    1.70          case SDL_MOUSEBUTTONUP: