Fixed compilation on iPhone
authorSam Lantinga <slouken@libsdl.org>
Thu, 21 Jan 2010 16:12:24 +0000
changeset 3690e431b888ac6c
parent 3689 af25b5586af7
child 3691 9fed2aa469ed
Fixed compilation on iPhone
TODO
Xcode-iPhoneOS/Demos/src/accelerometer.c
src/SDL_assert.c
     1.1 --- a/TODO	Thu Jan 21 16:11:55 2010 +0000
     1.2 +++ b/TODO	Thu Jan 21 16:12:24 2010 +0000
     1.3 @@ -53,6 +53,8 @@
     1.4   * Figure out how to handle OpenGL context lost on Mac OS X (does it happen?)
     1.5   * Write automated test case for multi-draw APIs
     1.6   * Make sure you can build SDL without the renderer to slim it down a bunch
     1.7 + * Implement assertion code on iPhone
     1.8 + * Add __WINDOWS__ in addition to __WIN32__
     1.9  
    1.10   * Check 1.2 revisions:
    1.11  	3554 - Need to resolve semantics for locking keys on different platforms
     2.1 --- a/Xcode-iPhoneOS/Demos/src/accelerometer.c	Thu Jan 21 16:11:55 2010 +0000
     2.2 +++ b/Xcode-iPhoneOS/Demos/src/accelerometer.c	Thu Jan 21 16:12:24 2010 +0000
     2.3 @@ -25,7 +25,7 @@
     2.4      float x, y;                 /* position of ship */
     2.5      float vx, vy;               /* velocity of ship (in pixels per millesecond) */
     2.6      SDL_Rect rect;              /* (drawn) position and size of ship */
     2.7 -} ship;
     2.8 +} shipData;
     2.9  
    2.10  static SDL_Texture *ship = 0;        /* texture for spaceship */
    2.11  static SDL_Texture *space = 0;       /* texture for space (background */
    2.12 @@ -41,9 +41,9 @@
    2.13  
    2.14      /* ship screen constraints */
    2.15      Uint32 minx = 0.0f;
    2.16 -    Uint32 maxx = SCREEN_WIDTH - ship.rect.w;
    2.17 +    Uint32 maxx = SCREEN_WIDTH - shipData.rect.w;
    2.18      Uint32 miny = 0.0f;
    2.19 -    Uint32 maxy = SCREEN_HEIGHT - ship.rect.h;
    2.20 +    Uint32 maxy = SCREEN_HEIGHT - shipData.rect.h;
    2.21  
    2.22  #define SINT16_MAX ((float)(0x7FFF))
    2.23  
    2.24 @@ -51,59 +51,59 @@
    2.25         the factor SDL_IPHONE_MAX_G_FORCE / SINT16_MAX converts between 
    2.26         SDL's units reported from the joytick, and units of g-force, as reported by the accelerometer
    2.27       */
    2.28 -    ship.vx +=
    2.29 +    shipData.vx +=
    2.30          ax * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT *
    2.31          MILLESECONDS_PER_FRAME;
    2.32 -    ship.vy +=
    2.33 +    shipData.vy +=
    2.34          ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT *
    2.35          MILLESECONDS_PER_FRAME;
    2.36  
    2.37 -    float speed = sqrt(ship.vx * ship.vx + ship.vy * ship.vy);
    2.38 +    float speed = sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy);
    2.39  
    2.40      if (speed > 0) {
    2.41          /* compensate for friction */
    2.42 -        float dirx = ship.vx / speed;   /* normalized x velocity */
    2.43 -        float diry = ship.vy / speed;   /* normalized y velocity */
    2.44 +        float dirx = shipData.vx / speed;   /* normalized x velocity */
    2.45 +        float diry = shipData.vy / speed;   /* normalized y velocity */
    2.46  
    2.47          /* update velocity due to friction */
    2.48          if (speed - FRICTION * MILLESECONDS_PER_FRAME > 0) {
    2.49              /* apply friction */
    2.50 -            ship.vx -= dirx * FRICTION * MILLESECONDS_PER_FRAME;
    2.51 -            ship.vy -= diry * FRICTION * MILLESECONDS_PER_FRAME;
    2.52 +            shipData.vx -= dirx * FRICTION * MILLESECONDS_PER_FRAME;
    2.53 +            shipData.vy -= diry * FRICTION * MILLESECONDS_PER_FRAME;
    2.54          } else {
    2.55              /* applying friction would MORE than stop the ship, so just stop the ship */
    2.56 -            ship.vx = 0.0f;
    2.57 -            ship.vy = 0.0f;
    2.58 +            shipData.vx = 0.0f;
    2.59 +            shipData.vy = 0.0f;
    2.60          }
    2.61      }
    2.62  
    2.63      /* update ship location */
    2.64 -    ship.x += ship.vx * MILLESECONDS_PER_FRAME;
    2.65 -    ship.y += ship.vy * MILLESECONDS_PER_FRAME;
    2.66 +    shipData.x += shipData.vx * MILLESECONDS_PER_FRAME;
    2.67 +    shipData.y += shipData.vy * MILLESECONDS_PER_FRAME;
    2.68  
    2.69 -    if (ship.x > maxx) {
    2.70 -        ship.x = maxx;
    2.71 -        ship.vx = -ship.vx * DAMPING;
    2.72 -    } else if (ship.x < minx) {
    2.73 -        ship.x = minx;
    2.74 -        ship.vx = -ship.vx * DAMPING;
    2.75 +    if (shipData.x > maxx) {
    2.76 +        shipData.x = maxx;
    2.77 +        shipData.vx = -shipData.vx * DAMPING;
    2.78 +    } else if (shipData.x < minx) {
    2.79 +        shipData.x = minx;
    2.80 +        shipData.vx = -shipData.vx * DAMPING;
    2.81      }
    2.82 -    if (ship.y > maxy) {
    2.83 -        ship.y = maxy;
    2.84 -        ship.vy = -ship.vy * DAMPING;
    2.85 -    } else if (ship.y < miny) {
    2.86 -        ship.y = miny;
    2.87 -        ship.vy = -ship.vy * DAMPING;
    2.88 +    if (shipData.y > maxy) {
    2.89 +        shipData.y = maxy;
    2.90 +        shipData.vy = -shipData.vy * DAMPING;
    2.91 +    } else if (shipData.y < miny) {
    2.92 +        shipData.y = miny;
    2.93 +        shipData.vy = -shipData.vy * DAMPING;
    2.94      }
    2.95  
    2.96      /* draw the background */
    2.97      SDL_RenderCopy(space, NULL, NULL);
    2.98  
    2.99      /* draw the ship */
   2.100 -    ship.rect.x = ship.x;
   2.101 -    ship.rect.y = ship.y;
   2.102 +    shipData.rect.x = shipData.x;
   2.103 +    shipData.rect.y = shipData.y;
   2.104  
   2.105 -    SDL_RenderCopy(ship, NULL, &ship.rect);
   2.106 +    SDL_RenderCopy(ship, NULL, &shipData.rect);
   2.107  
   2.108      /* update screen */
   2.109      SDL_RenderPresent();
   2.110 @@ -148,8 +148,8 @@
   2.111      SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND);
   2.112  
   2.113      /* set the width and height of the ship from the surface dimensions */
   2.114 -    ship.rect.w = bmp_surface->w;
   2.115 -    ship.rect.h = bmp_surface->h;
   2.116 +    shipData.rect.w = bmp_surface->w;
   2.117 +    shipData.rect.h = bmp_surface->h;
   2.118  
   2.119      SDL_FreeSurface(bmp_surface_rgba);
   2.120      SDL_FreeSurface(bmp_surface);
   2.121 @@ -211,10 +211,10 @@
   2.122      initializeTextures();
   2.123  
   2.124      /* setup ship */
   2.125 -    ship.x = (SCREEN_WIDTH - ship.rect.w) / 2;
   2.126 -    ship.y = (SCREEN_HEIGHT - ship.rect.h) / 2;
   2.127 -    ship.vx = 0.0f;
   2.128 -    ship.vy = 0.0f;
   2.129 +    shipData.x = (SCREEN_WIDTH - shipData.rect.w) / 2;
   2.130 +    shipData.y = (SCREEN_HEIGHT - shipData.rect.h) / 2;
   2.131 +    shipData.vx = 0.0f;
   2.132 +    shipData.vy = 0.0f;
   2.133  
   2.134      done = 0;
   2.135      /* enter main loop */
     3.1 --- a/src/SDL_assert.c	Thu Jan 21 16:11:55 2010 +0000
     3.2 +++ b/src/SDL_assert.c	Thu Jan 21 16:12:24 2010 +0000
     3.3 @@ -312,7 +312,7 @@
     3.4  #ifdef _WINDOWS
     3.5      state = SDL_PromptAssertion_windows(data);
     3.6  
     3.7 -#elif __APPLE__
     3.8 +#elif __MACOSX__
     3.9      /* This has to be done in an Objective-C (*.m) file, so we call out. */
    3.10      extern SDL_assert_state SDL_PromptAssertion_cocoa(const SDL_assert_data *);
    3.11      state = SDL_PromptAssertion_cocoa(data);