Fixed bug 1137, updated the keyboard demo with latest rendering API changes.
authorSam Lantinga <slouken@libsdl.org>
Sun, 20 Feb 2011 14:22:27 -0800
changeset 5364fec676157db5
parent 5363 96799a165806
child 5365 db3c6ebcc954
Fixed bug 1137, updated the keyboard demo with latest rendering API changes.
Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj
Xcode-iPhoneOS/Demos/src/keyboard.c
     1.1 --- a/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj	Sun Feb 20 14:16:11 2011 -0800
     1.2 +++ b/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj	Sun Feb 20 14:22:27 2011 -0800
     1.3 @@ -975,11 +975,7 @@
     1.4  				GCC_PREFIX_HEADER = "";
     1.5  				INFOPLIST_FILE = Info.plist;
     1.6  				INSTALL_PATH = "$(HOME)/Applications";
     1.7 -				LIBRARY_SEARCH_PATHS = (
     1.8 -					"$(inherited)",
     1.9 -					"\\\\\\\"$(SRCROOT)\\\\\\\"",
    1.10 -					"\"$(SRCROOT)/../SDL/build/Debug-iphoneos\"",
    1.11 -				);
    1.12 +				LIBRARY_SEARCH_PATHS = "$(inherited)";
    1.13  				PREBINDING = NO;
    1.14  				PRODUCT_NAME = Keyboard;
    1.15  				SDKROOT = iphoneos;
    1.16 @@ -998,11 +994,7 @@
    1.17  				GCC_PREFIX_HEADER = "";
    1.18  				INFOPLIST_FILE = Info.plist;
    1.19  				INSTALL_PATH = "$(HOME)/Applications";
    1.20 -				LIBRARY_SEARCH_PATHS = (
    1.21 -					"$(inherited)",
    1.22 -					"\\\\\\\"$(SRCROOT)\\\\\\\"",
    1.23 -					"\"$(SRCROOT)/../SDL/build/Debug-iphoneos\"",
    1.24 -				);
    1.25 +				LIBRARY_SEARCH_PATHS = "$(inherited)";
    1.26  				PREBINDING = NO;
    1.27  				PRODUCT_NAME = Fireworks;
    1.28  				SDKROOT = iphoneos;
     2.1 --- a/Xcode-iPhoneOS/Demos/src/keyboard.c	Sun Feb 20 14:16:11 2011 -0800
     2.2 +++ b/Xcode-iPhoneOS/Demos/src/keyboard.c	Sun Feb 20 14:22:27 2011 -0800
     2.3 @@ -23,6 +23,7 @@
     2.4  void cleanup(void);
     2.5  void drawBlank(int x, int y);
     2.6  
     2.7 +static SDL_Renderer *renderer;
     2.8  static int numChars = 0;        /* number of characters we've typed so far */
     2.9  static SDL_bool lastCharWasColon = 0;   /* we use this to detect sequences such as :) */
    2.10  static SDL_Color bg_color = { 50, 50, 100, 255 };       /* color of background */
    2.11 @@ -157,7 +158,7 @@
    2.12          { GLYPH_SIZE_IMAGE * index, 0, GLYPH_SIZE_IMAGE, GLYPH_SIZE_IMAGE };
    2.13      SDL_Rect dstRect = { x, y, GLYPH_SIZE_SCREEN, GLYPH_SIZE_SCREEN };
    2.14      drawBlank(x, y);
    2.15 -    SDL_RenderCopy(texture, &srcRect, &dstRect);
    2.16 +    SDL_RenderCopy(renderer, texture, &srcRect, &dstRect);
    2.17  }
    2.18  
    2.19  /*  draws the cursor icon at the current end position of the text */
    2.20 @@ -174,9 +175,9 @@
    2.21  drawBlank(int x, int y)
    2.22  {
    2.23      SDL_Rect rect = { x, y, GLYPH_SIZE_SCREEN, GLYPH_SIZE_SCREEN };
    2.24 -    SDL_SetRenderDrawColor(bg_color.r, bg_color.g, bg_color.b,
    2.25 +    SDL_SetRenderDrawColor(renderer, bg_color.r, bg_color.g, bg_color.b,
    2.26                             bg_color.unused);
    2.27 -    SDL_RenderFill(&rect);
    2.28 +    SDL_RenderFillRect(renderer, &rect);
    2.29  }
    2.30  
    2.31  /* moves backwards one character, erasing the last one put down */
    2.32 @@ -219,7 +220,7 @@
    2.33          SDL_BlitSurface(surface, NULL, converted, NULL);
    2.34          /* create our texture */
    2.35          texture =
    2.36 -            SDL_CreateTextureFromSurface(SDL_PIXELFORMAT_ABGR8888, converted);
    2.37 +            SDL_CreateTextureFromSurface(renderer, converted);
    2.38          if (texture == 0) {
    2.39              printf("texture creation failed: %s\n", SDL_GetError());
    2.40          } else {
    2.41 @@ -248,16 +249,16 @@
    2.42      /* create window */
    2.43      window = SDL_CreateWindow("iPhone keyboard test", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
    2.44      /* create renderer */
    2.45 -    SDL_CreateRenderer(window, 0, 0);
    2.46 +    renderer = SDL_CreateRenderer(window, -1, 0);
    2.47  
    2.48      /* load up our font */
    2.49      loadFont();
    2.50  
    2.51      /* draw the background, we'll just paint over it */
    2.52 -    SDL_SetRenderDrawColor(bg_color.r, bg_color.g, bg_color.b,
    2.53 +    SDL_SetRenderDrawColor(renderer, bg_color.r, bg_color.g, bg_color.b,
    2.54                             bg_color.unused);
    2.55 -    SDL_RenderFill(NULL);
    2.56 -    SDL_RenderPresent();
    2.57 +    SDL_RenderFillRect(renderer, NULL);
    2.58 +    SDL_RenderPresent(renderer);
    2.59  
    2.60      int done = 0;
    2.61      /* loop till we get SDL_Quit */
    2.62 @@ -293,7 +294,7 @@
    2.63              }
    2.64              /* check if the key was a colon */
    2.65              /* draw our updates to the screen */
    2.66 -            SDL_RenderPresent();
    2.67 +            SDL_RenderPresent(renderer);
    2.68              break;
    2.69  #ifdef __IPHONEOS__
    2.70          case SDL_MOUSEBUTTONUP: