Added SDL_RenderSetScale() and SDL_RenderGetScale()
authorSam Lantinga <slouken@libsdl.org>
Mon, 01 Oct 2012 20:59:33 -0700
changeset 6528e978048ced60
parent 6527 c04879cd3b57
child 6529 9094fcfd378d
Added SDL_RenderSetScale() and SDL_RenderGetScale()
include/SDL_render.h
src/render/SDL_render.c
src/render/SDL_sysrender.h
src/render/direct3d/SDL_render_d3d.c
src/render/opengl/SDL_glfuncs.h
src/render/opengl/SDL_render_gl.c
src/render/opengles/SDL_glesfuncs.h
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
src/render/software/SDL_render_sw.c
     1.1 --- a/include/SDL_render.h	Mon Oct 01 00:56:58 2012 -0700
     1.2 +++ b/include/SDL_render.h	Mon Oct 01 20:59:33 2012 -0700
     1.3 @@ -437,6 +437,32 @@
     1.4                                                     SDL_Rect * rect);
     1.5  
     1.6  /**
     1.7 + *  \brief Set the drawing scale for rendering on the current target.
     1.8 + *
     1.9 + *  \param scaleX The horizontal scaling factor
    1.10 + *  \param scaleY The vertical scaling factor
    1.11 + *
    1.12 + *  The drawing coordinates are scaled by the x/y scaling factors
    1.13 + *  before they are used by the renderer.  This allows resolution
    1.14 + *  independent drawing with a single coordinate system.
    1.15 + *
    1.16 + *  \note If this results in scaling or subpixel drawing by the 
    1.17 + *        rendering backend, it will be handled using the appropriate
    1.18 + *        quality hints.  For best results use integer scaling factors.
    1.19 + */
    1.20 +extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
    1.21 +                                               float scaleX, float scaleY);
    1.22 +
    1.23 +/**
    1.24 + *  \brief Get the drawing scale for the current target.
    1.25 + *
    1.26 + *  \param scaleX A pointer filled in with the horizontal scaling factor
    1.27 + *  \param scaleY A pointer filled in with the vertical scaling factor
    1.28 + */
    1.29 +extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
    1.30 +                                               float *scaleX, float *scaleY);
    1.31 +
    1.32 +/**
    1.33   *  \brief Set the color used for drawing operations (Rect, Line and Clear).
    1.34   *  
    1.35   *  \param r The red value used to draw on the rendering target.
     2.1 --- a/src/render/SDL_render.c	Mon Oct 01 00:56:58 2012 -0700
     2.2 +++ b/src/render/SDL_render.c	Mon Oct 01 20:59:33 2012 -0700
     2.3 @@ -103,26 +103,22 @@
     2.4              if (event->window.event == SDL_WINDOWEVENT_RESIZED) {
     2.5                  /* Try to keep the previous viewport centered */
     2.6                  int w, h;
     2.7 -                SDL_Rect viewport;
     2.8  
     2.9                  SDL_GetWindowSize(window, &w, &h);
    2.10                  if (renderer->target) {
    2.11                      renderer->viewport_backup.x = (w - renderer->viewport_backup.w) / 2;
    2.12                      renderer->viewport_backup.y = (h - renderer->viewport_backup.h) / 2;
    2.13                  } else {
    2.14 -                    viewport.x = (w - renderer->viewport.w) / 2;
    2.15 -                    viewport.y = (h - renderer->viewport.h) / 2;
    2.16 -                    viewport.w = renderer->viewport.w;
    2.17 -                    viewport.h = renderer->viewport.h;
    2.18 -                    SDL_RenderSetViewport(renderer, &viewport);
    2.19 +                    renderer->viewport.x = (w - renderer->viewport.w) / 2;
    2.20 +                    renderer->viewport.y = (h - renderer->viewport.h) / 2;
    2.21 +                    renderer->UpdateViewport(renderer);
    2.22                  }
    2.23                  renderer->resized = SDL_TRUE;
    2.24              } else if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
    2.25 -                int w, h;
    2.26 -                SDL_Rect viewport;
    2.27 -
    2.28                  if (!renderer->resized) {
    2.29                      /* Window was programmatically resized, reset viewport */
    2.30 +                    int w, h;
    2.31 +
    2.32                      SDL_GetWindowSize(window, &w, &h);
    2.33                      if (renderer->target) {
    2.34                          renderer->viewport_backup.x = 0;
    2.35 @@ -130,14 +126,14 @@
    2.36                          renderer->viewport_backup.w = w;
    2.37                          renderer->viewport_backup.h = h;
    2.38                      } else {
    2.39 -                        viewport.x = 0;
    2.40 -                        viewport.y = 0;
    2.41 -                        viewport.w = w;
    2.42 -                        viewport.h = h;
    2.43 -                        SDL_RenderSetViewport(renderer, &viewport);
    2.44 +                        renderer->viewport.x = 0;
    2.45 +                        renderer->viewport.y = 0;
    2.46 +                        renderer->viewport.w = w;
    2.47 +                        renderer->viewport.h = h;
    2.48 +                        renderer->UpdateViewport(renderer);
    2.49                      }
    2.50 -                    renderer->resized = SDL_FALSE;
    2.51                  }
    2.52 +                renderer->resized = SDL_FALSE;
    2.53              } else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) {
    2.54                  renderer->hidden = SDL_TRUE;
    2.55              } else if (event->window.event == SDL_WINDOWEVENT_SHOWN) {
    2.56 @@ -247,6 +243,8 @@
    2.57      if (renderer) {
    2.58          renderer->magic = &renderer_magic;
    2.59          renderer->window = window;
    2.60 +        renderer->scale.x = 1.0f;
    2.61 +        renderer->scale.y = 1.0f;
    2.62  
    2.63          if (SDL_GetWindowFlags(window) & (SDL_WINDOW_HIDDEN|SDL_WINDOW_MINIMIZED)) {
    2.64              renderer->hidden = SDL_TRUE;
    2.65 @@ -867,8 +865,6 @@
    2.66  int
    2.67  SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
    2.68  {
    2.69 -    SDL_Rect viewport;
    2.70 -
    2.71      if (!SDL_RenderTargetSupported(renderer)) {
    2.72          SDL_Unsupported();
    2.73          return -1;
    2.74 @@ -898,6 +894,7 @@
    2.75      if (texture && !renderer->target) {
    2.76          /* Make a backup of the viewport */
    2.77          renderer->viewport_backup = renderer->viewport;
    2.78 +        renderer->scale_backup = renderer->scale;
    2.79      }
    2.80      renderer->target = texture;
    2.81  
    2.82 @@ -906,14 +903,17 @@
    2.83      }
    2.84  
    2.85      if (texture) {
    2.86 -        viewport.x = 0;
    2.87 -        viewport.y = 0;
    2.88 -        viewport.w = texture->w;
    2.89 -        viewport.h = texture->h;
    2.90 +        renderer->viewport.x = 0;
    2.91 +        renderer->viewport.y = 0;
    2.92 +        renderer->viewport.w = texture->w;
    2.93 +        renderer->viewport.h = texture->h;
    2.94 +        renderer->scale.x = 1.0f;
    2.95 +        renderer->scale.y = 1.0f;
    2.96      } else {
    2.97 -        viewport = renderer->viewport_backup;
    2.98 +        renderer->viewport = renderer->viewport_backup;
    2.99 +        renderer->scale = renderer->scale_backup;
   2.100      }
   2.101 -    if (SDL_RenderSetViewport(renderer, &viewport) < 0) {
   2.102 +    if (renderer->UpdateViewport(renderer) < 0) {
   2.103          return -1;
   2.104      }
   2.105  
   2.106 @@ -927,7 +927,10 @@
   2.107      CHECK_RENDERER_MAGIC(renderer, -1);
   2.108  
   2.109      if (rect) {
   2.110 -        renderer->viewport = *rect;
   2.111 +        renderer->viewport.x = (int)SDL_floor(rect->x * renderer->scale.x);
   2.112 +        renderer->viewport.y = (int)SDL_floor(rect->y * renderer->scale.y);
   2.113 +        renderer->viewport.w = (int)SDL_ceil(rect->w * renderer->scale.x);
   2.114 +        renderer->viewport.h = (int)SDL_ceil(rect->h * renderer->scale.y);
   2.115      } else {
   2.116          renderer->viewport.x = 0;
   2.117          renderer->viewport.y = 0;
   2.118 @@ -948,7 +951,35 @@
   2.119  {
   2.120      CHECK_RENDERER_MAGIC(renderer, );
   2.121  
   2.122 -    *rect = renderer->viewport;
   2.123 +    if (rect) {
   2.124 +        rect->x = (int)(renderer->viewport.x / renderer->scale.x);
   2.125 +        rect->y = (int)(renderer->viewport.y / renderer->scale.y);
   2.126 +        rect->w = (int)(renderer->viewport.w / renderer->scale.x);
   2.127 +        rect->h = (int)(renderer->viewport.h / renderer->scale.y);
   2.128 +    }
   2.129 +}
   2.130 +
   2.131 +int
   2.132 +SDL_RenderSetScale(SDL_Renderer * renderer, float scaleX, float scaleY)
   2.133 +{
   2.134 +    CHECK_RENDERER_MAGIC(renderer, -1);
   2.135 +
   2.136 +    renderer->scale.x = scaleX;
   2.137 +    renderer->scale.y = scaleY;
   2.138 +    return 0;
   2.139 +}
   2.140 +
   2.141 +void
   2.142 +SDL_RenderGetScale(SDL_Renderer * renderer, float *scaleX, float *scaleY)
   2.143 +{
   2.144 +    CHECK_RENDERER_MAGIC(renderer, );
   2.145 +
   2.146 +    if (scaleX) {
   2.147 +        *scaleX = renderer->scale.x;
   2.148 +    }
   2.149 +    if (scaleY) {
   2.150 +        *scaleY = renderer->scale.y;
   2.151 +    }
   2.152  }
   2.153  
   2.154  int
   2.155 @@ -1025,10 +1056,41 @@
   2.156      return SDL_RenderDrawPoints(renderer, &point, 1);
   2.157  }
   2.158  
   2.159 +static int
   2.160 +RenderDrawPointsWithRects(SDL_Renderer * renderer,
   2.161 +                     const SDL_Point * points, int count)
   2.162 +{
   2.163 +    SDL_FRect *frects;
   2.164 +    int i;
   2.165 +    int status;
   2.166 +
   2.167 +    frects = SDL_stack_alloc(SDL_FRect, count);
   2.168 +    if (!frects) {
   2.169 +        SDL_OutOfMemory();
   2.170 +        return -1;
   2.171 +    }
   2.172 +    for (i = 0; i < count; ++i) {
   2.173 +        frects[i].x = points[i].x * renderer->scale.x;
   2.174 +        frects[i].y = points[i].y * renderer->scale.y;
   2.175 +        frects[i].w = renderer->scale.x;
   2.176 +        frects[i].h = renderer->scale.y;
   2.177 +    }
   2.178 +
   2.179 +    status = renderer->RenderFillRects(renderer, frects, count);
   2.180 +
   2.181 +    SDL_stack_free(frects);
   2.182 +
   2.183 +    return status;
   2.184 +}
   2.185 +
   2.186  int
   2.187  SDL_RenderDrawPoints(SDL_Renderer * renderer,
   2.188                       const SDL_Point * points, int count)
   2.189  {
   2.190 +    SDL_FPoint *fpoints;
   2.191 +    int i;
   2.192 +    int status;
   2.193 +
   2.194      CHECK_RENDERER_MAGIC(renderer, -1);
   2.195  
   2.196      if (!points) {
   2.197 @@ -1042,7 +1104,26 @@
   2.198      if (renderer->hidden) {
   2.199          return 0;
   2.200      }
   2.201 -    return renderer->RenderDrawPoints(renderer, points, count);
   2.202 +
   2.203 +    if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
   2.204 +        return RenderDrawPointsWithRects(renderer, points, count);
   2.205 +    }
   2.206 +
   2.207 +    fpoints = SDL_stack_alloc(SDL_FPoint, count);
   2.208 +    if (!fpoints) {
   2.209 +        SDL_OutOfMemory();
   2.210 +        return -1;
   2.211 +    }
   2.212 +    for (i = 0; i < count; ++i) {
   2.213 +        fpoints[i].x = points[i].x * renderer->scale.x;
   2.214 +        fpoints[i].y = points[i].y * renderer->scale.y;
   2.215 +    }
   2.216 +
   2.217 +    status = renderer->RenderDrawPoints(renderer, fpoints, count);
   2.218 +
   2.219 +    SDL_stack_free(fpoints);
   2.220 +
   2.221 +    return status;
   2.222  }
   2.223  
   2.224  int
   2.225 @@ -1057,10 +1138,71 @@
   2.226      return SDL_RenderDrawLines(renderer, points, 2);
   2.227  }
   2.228  
   2.229 +static int
   2.230 +RenderDrawLinesWithRects(SDL_Renderer * renderer,
   2.231 +                     const SDL_Point * points, int count)
   2.232 +{
   2.233 +    SDL_FRect *frect;
   2.234 +    SDL_FRect *frects;
   2.235 +    SDL_FPoint fpoints[2];
   2.236 +    int i, nrects;
   2.237 +    int status;
   2.238 +
   2.239 +    frects = SDL_stack_alloc(SDL_FRect, count-1);
   2.240 +    if (!frects) {
   2.241 +        SDL_OutOfMemory();
   2.242 +        return -1;
   2.243 +    }
   2.244 +
   2.245 +    status = 0;
   2.246 +    nrects = 0;
   2.247 +    for (i = 0; i < count-1; ++i) {
   2.248 +        if (points[i].x == points[i+1].x) {
   2.249 +            int minY = SDL_min(points[i].y, points[i+1].y);
   2.250 +            int maxY = SDL_max(points[i].y, points[i+1].y);
   2.251 +
   2.252 +            frect = &frects[nrects++];
   2.253 +            frect->x = points[i].x * renderer->scale.x;
   2.254 +            frect->y = minY * renderer->scale.y;
   2.255 +            frect->w = renderer->scale.x;
   2.256 +            frect->h = (maxY - minY + 1) * renderer->scale.y;
   2.257 +        } else if (points[i].y == points[i+1].y) {
   2.258 +            int minX = SDL_min(points[i].x, points[i+1].x);
   2.259 +            int maxX = SDL_max(points[i].x, points[i+1].x);
   2.260 +
   2.261 +            frect = &frects[nrects++];
   2.262 +            frect->x = minX * renderer->scale.x;
   2.263 +            frect->y = points[i].y * renderer->scale.y;
   2.264 +            frect->w = (maxX - minX + 1) * renderer->scale.x;
   2.265 +            frect->h = renderer->scale.y;
   2.266 +        } else {
   2.267 +            /* FIXME: We can't use a rect for this line... */
   2.268 +            frects[0].x = points[i].x * renderer->scale.x;
   2.269 +            frects[0].y = points[i].y * renderer->scale.y;
   2.270 +            frects[1].x = points[i+1].x * renderer->scale.x;
   2.271 +            frects[1].y = points[i+1].y * renderer->scale.y;
   2.272 +            status += renderer->RenderDrawLines(renderer, fpoints, 2);
   2.273 +        }
   2.274 +    }
   2.275 +
   2.276 +    status += renderer->RenderFillRects(renderer, frects, nrects);
   2.277 +
   2.278 +    SDL_stack_free(frects);
   2.279 +
   2.280 +    if (status < 0) {
   2.281 +        status = -1;
   2.282 +    }
   2.283 +    return status;
   2.284 +}
   2.285 +
   2.286  int
   2.287  SDL_RenderDrawLines(SDL_Renderer * renderer,
   2.288                      const SDL_Point * points, int count)
   2.289  {
   2.290 +    SDL_FPoint *fpoints;
   2.291 +    int i;
   2.292 +    int status;
   2.293 +
   2.294      CHECK_RENDERER_MAGIC(renderer, -1);
   2.295  
   2.296      if (!points) {
   2.297 @@ -1074,7 +1216,26 @@
   2.298      if (renderer->hidden) {
   2.299          return 0;
   2.300      }
   2.301 -    return renderer->RenderDrawLines(renderer, points, count);
   2.302 +
   2.303 +    if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
   2.304 +        return RenderDrawLinesWithRects(renderer, points, count);
   2.305 +    }
   2.306 +
   2.307 +    fpoints = SDL_stack_alloc(SDL_FPoint, count);
   2.308 +    if (!fpoints) {
   2.309 +        SDL_OutOfMemory();
   2.310 +        return -1;
   2.311 +    }
   2.312 +    for (i = 0; i < count; ++i) {
   2.313 +        fpoints[i].x = points[i].x * renderer->scale.x;
   2.314 +        fpoints[i].y = points[i].y * renderer->scale.y;
   2.315 +    }
   2.316 +
   2.317 +    status = renderer->RenderDrawLines(renderer, fpoints, count);
   2.318 +
   2.319 +    SDL_stack_free(fpoints);
   2.320 +
   2.321 +    return status;
   2.322  }
   2.323  
   2.324  int
   2.325 @@ -1087,10 +1248,9 @@
   2.326  
   2.327      /* If 'rect' == NULL, then outline the whole surface */
   2.328      if (!rect) {
   2.329 +        SDL_RenderGetViewport(renderer, &full_rect);
   2.330          full_rect.x = 0;
   2.331          full_rect.y = 0;
   2.332 -        full_rect.w = renderer->viewport.w;
   2.333 -        full_rect.h = renderer->viewport.h;
   2.334          rect = &full_rect;
   2.335      }
   2.336  
   2.337 @@ -1144,10 +1304,9 @@
   2.338  
   2.339      /* If 'rect' == NULL, then outline the whole surface */
   2.340      if (!rect) {
   2.341 +        SDL_RenderGetViewport(renderer, &full_rect);
   2.342          full_rect.x = 0;
   2.343          full_rect.y = 0;
   2.344 -        full_rect.w = renderer->viewport.w;
   2.345 -        full_rect.h = renderer->viewport.h;
   2.346          rect = &full_rect;
   2.347      }
   2.348      return SDL_RenderFillRects(renderer, rect, 1);
   2.349 @@ -1157,6 +1316,10 @@
   2.350  SDL_RenderFillRects(SDL_Renderer * renderer,
   2.351                      const SDL_Rect * rects, int count)
   2.352  {
   2.353 +    SDL_FRect *frects;
   2.354 +    int i;
   2.355 +    int status;
   2.356 +
   2.357      CHECK_RENDERER_MAGIC(renderer, -1);
   2.358  
   2.359      if (!rects) {
   2.360 @@ -1170,7 +1333,24 @@
   2.361      if (renderer->hidden) {
   2.362          return 0;
   2.363      }
   2.364 -    return renderer->RenderFillRects(renderer, rects, count);
   2.365 +
   2.366 +    frects = SDL_stack_alloc(SDL_FRect, count);
   2.367 +    if (!frects) {
   2.368 +        SDL_OutOfMemory();
   2.369 +        return -1;
   2.370 +    }
   2.371 +    for (i = 0; i < count; ++i) {
   2.372 +        frects[i].x = rects[i].x * renderer->scale.x;
   2.373 +        frects[i].y = rects[i].y * renderer->scale.y;
   2.374 +        frects[i].w = rects[i].w * renderer->scale.x;
   2.375 +        frects[i].h = rects[i].h * renderer->scale.y;
   2.376 +    }
   2.377 +
   2.378 +    status = renderer->RenderFillRects(renderer, frects, count);
   2.379 +
   2.380 +    SDL_stack_free(frects);
   2.381 +
   2.382 +    return status;
   2.383  }
   2.384  
   2.385  int
   2.386 @@ -1179,6 +1359,7 @@
   2.387  {
   2.388      SDL_Rect real_srcrect;
   2.389      SDL_Rect real_dstrect;
   2.390 +    SDL_FRect frect;
   2.391  
   2.392      CHECK_RENDERER_MAGIC(renderer, -1);
   2.393      CHECK_TEXTURE_MAGIC(texture, -1);
   2.394 @@ -1198,10 +1379,9 @@
   2.395          }
   2.396      }
   2.397  
   2.398 +    SDL_RenderGetViewport(renderer, &real_dstrect);
   2.399      real_dstrect.x = 0;
   2.400      real_dstrect.y = 0;
   2.401 -    real_dstrect.w = renderer->viewport.w;
   2.402 -    real_dstrect.h = renderer->viewport.h;
   2.403      if (dstrect) {
   2.404          if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) {
   2.405              return 0;
   2.406 @@ -1229,8 +1409,13 @@
   2.407      if (renderer->hidden) {
   2.408          return 0;
   2.409      }
   2.410 -    return renderer->RenderCopy(renderer, texture, &real_srcrect,
   2.411 -                                &real_dstrect);
   2.412 +
   2.413 +    frect.x = real_dstrect.x * renderer->scale.x;
   2.414 +    frect.y = real_dstrect.y * renderer->scale.y;
   2.415 +    frect.w = real_dstrect.w * renderer->scale.x;
   2.416 +    frect.h = real_dstrect.h * renderer->scale.y;
   2.417 +
   2.418 +    return renderer->RenderCopy(renderer, texture, &real_srcrect, &frect);
   2.419  }
   2.420  
   2.421  
   2.422 @@ -1241,6 +1426,8 @@
   2.423  {
   2.424      SDL_Rect real_srcrect, real_dstrect;
   2.425      SDL_Point real_center;
   2.426 +    SDL_FRect frect;
   2.427 +    SDL_FPoint fcenter;
   2.428  
   2.429      CHECK_RENDERER_MAGIC(renderer, -1);
   2.430      CHECK_TEXTURE_MAGIC(texture, -1);
   2.431 @@ -1265,12 +1452,12 @@
   2.432      }
   2.433  
   2.434      /* We don't intersect the dstrect with the viewport as RenderCopy does because of potential rotation clipping issues... TODO: should we? */
   2.435 -    if (dstrect) real_dstrect = *dstrect;
   2.436 -    else {
   2.437 +    if (dstrect) {
   2.438 +        real_dstrect = *dstrect;
   2.439 +    } else {
   2.440 +        SDL_RenderGetViewport(renderer, &real_dstrect);
   2.441          real_dstrect.x = 0;
   2.442          real_dstrect.y = 0;
   2.443 -        real_dstrect.w = renderer->viewport.w;
   2.444 -        real_dstrect.h = renderer->viewport.h;
   2.445      }
   2.446  
   2.447      if (texture->native) {
   2.448 @@ -1283,7 +1470,15 @@
   2.449          real_center.y = real_dstrect.h/2;
   2.450      }
   2.451  
   2.452 -    return renderer->RenderCopyEx(renderer, texture, &real_srcrect, &real_dstrect, angle, &real_center, flip);
   2.453 +    frect.x = real_dstrect.x * renderer->scale.x;
   2.454 +    frect.y = real_dstrect.y * renderer->scale.y;
   2.455 +    frect.w = real_dstrect.w * renderer->scale.x;
   2.456 +    frect.h = real_dstrect.h * renderer->scale.y;
   2.457 +
   2.458 +    fcenter.x = real_center.x * renderer->scale.x;
   2.459 +    fcenter.y = real_center.y * renderer->scale.y;
   2.460 +
   2.461 +    return renderer->RenderCopyEx(renderer, texture, &real_srcrect, &frect, angle, &fcenter, flip);
   2.462  }
   2.463  
   2.464  int
     3.1 --- a/src/render/SDL_sysrender.h	Mon Oct 01 00:56:58 2012 -0700
     3.2 +++ b/src/render/SDL_sysrender.h	Mon Oct 01 20:59:33 2012 -0700
     3.3 @@ -31,6 +31,20 @@
     3.4  
     3.5  typedef struct SDL_RenderDriver SDL_RenderDriver;
     3.6  
     3.7 +typedef struct
     3.8 +{
     3.9 +    float x;
    3.10 +    float y;
    3.11 +} SDL_FPoint;
    3.12 +
    3.13 +typedef struct
    3.14 +{
    3.15 +    float x;
    3.16 +    float y;
    3.17 +    float w;
    3.18 +    float h;
    3.19 +} SDL_FRect;
    3.20 +
    3.21  /* Define the SDL texture structure */
    3.22  struct SDL_Texture
    3.23  {
    3.24 @@ -80,17 +94,17 @@
    3.25      int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture);
    3.26      int (*UpdateViewport) (SDL_Renderer * renderer);
    3.27      int (*RenderClear) (SDL_Renderer * renderer);
    3.28 -    int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
    3.29 +    int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_FPoint * points,
    3.30                               int count);
    3.31 -    int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
    3.32 +    int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_FPoint * points,
    3.33                              int count);
    3.34 -    int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect * rects,
    3.35 +    int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_FRect * rects,
    3.36                              int count);
    3.37      int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
    3.38 -                       const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    3.39 +                       const SDL_Rect * srcrect, const SDL_FRect * dstrect);
    3.40      int (*RenderCopyEx) (SDL_Renderer * renderer, SDL_Texture * texture,
    3.41 -                       const SDL_Rect * srcquad, const SDL_Rect * dstrect,
    3.42 -                       const double angle, const SDL_Point *center, const SDL_RendererFlip flip);
    3.43 +                       const SDL_Rect * srcquad, const SDL_FRect * dstrect,
    3.44 +                       const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
    3.45      int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
    3.46                               Uint32 format, void * pixels, int pitch);
    3.47      void (*RenderPresent) (SDL_Renderer * renderer);
    3.48 @@ -113,6 +127,10 @@
    3.49      SDL_Rect viewport;
    3.50      SDL_Rect viewport_backup;
    3.51  
    3.52 +    /* The render output coordinate scale */
    3.53 +    SDL_FPoint scale;
    3.54 +    SDL_FPoint scale_backup;
    3.55 +
    3.56      /* The list of textures */
    3.57      SDL_Texture *textures;
    3.58      SDL_Texture *target;
     4.1 --- a/src/render/direct3d/SDL_render_d3d.c	Mon Oct 01 00:56:58 2012 -0700
     4.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Mon Oct 01 20:59:33 2012 -0700
     4.3 @@ -188,16 +188,16 @@
     4.4  static int D3D_UpdateViewport(SDL_Renderer * renderer);
     4.5  static int D3D_RenderClear(SDL_Renderer * renderer);
     4.6  static int D3D_RenderDrawPoints(SDL_Renderer * renderer,
     4.7 -                                const SDL_Point * points, int count);
     4.8 +                                const SDL_FPoint * points, int count);
     4.9  static int D3D_RenderDrawLines(SDL_Renderer * renderer,
    4.10 -                               const SDL_Point * points, int count);
    4.11 +                               const SDL_FPoint * points, int count);
    4.12  static int D3D_RenderFillRects(SDL_Renderer * renderer,
    4.13 -                               const SDL_Rect * rects, int count);
    4.14 +                               const SDL_FRect * rects, int count);
    4.15  static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    4.16 -                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    4.17 +                          const SDL_Rect * srcrect, const SDL_FRect * dstrect);
    4.18  static int D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
    4.19 -                          const SDL_Rect * srcrect, const SDL_Rect * dstrect,
    4.20 -                          const double angle, const SDL_Point * center, const SDL_RendererFlip flip);
    4.21 +                          const SDL_Rect * srcrect, const SDL_FRect * dstrect,
    4.22 +                          const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip);
    4.23  static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    4.24                                  Uint32 format, void * pixels, int pitch);
    4.25  static void D3D_RenderPresent(SDL_Renderer * renderer);
    4.26 @@ -963,7 +963,7 @@
    4.27  }
    4.28  
    4.29  static int
    4.30 -D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
    4.31 +D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
    4.32                       int count)
    4.33  {
    4.34      D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
    4.35 @@ -990,8 +990,8 @@
    4.36  
    4.37      vertices = SDL_stack_alloc(Vertex, count);
    4.38      for (i = 0; i < count; ++i) {
    4.39 -        vertices[i].x = (float) points[i].x;
    4.40 -        vertices[i].y = (float) points[i].y;
    4.41 +        vertices[i].x = points[i].x;
    4.42 +        vertices[i].y = points[i].y;
    4.43          vertices[i].z = 0.0f;
    4.44          vertices[i].color = color;
    4.45          vertices[i].u = 0.0f;
    4.46 @@ -1009,7 +1009,7 @@
    4.47  }
    4.48  
    4.49  static int
    4.50 -D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
    4.51 +D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
    4.52                      int count)
    4.53  {
    4.54      D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
    4.55 @@ -1036,8 +1036,8 @@
    4.56  
    4.57      vertices = SDL_stack_alloc(Vertex, count);
    4.58      for (i = 0; i < count; ++i) {
    4.59 -        vertices[i].x = (float) points[i].x;
    4.60 -        vertices[i].y = (float) points[i].y;
    4.61 +        vertices[i].x = points[i].x;
    4.62 +        vertices[i].y = points[i].y;
    4.63          vertices[i].z = 0.0f;
    4.64          vertices[i].color = color;
    4.65          vertices[i].u = 0.0f;
    4.66 @@ -1051,8 +1051,8 @@
    4.67         so we need to close the endpoint of the line */
    4.68      if (count == 2 ||
    4.69          points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
    4.70 -        vertices[0].x = (float) points[count-1].x;
    4.71 -        vertices[0].y = (float) points[count-1].y;
    4.72 +        vertices[0].x = points[count-1].x;
    4.73 +        vertices[0].y = points[count-1].y;
    4.74          result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices));
    4.75      }
    4.76  
    4.77 @@ -1065,7 +1065,7 @@
    4.78  }
    4.79  
    4.80  static int
    4.81 -D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects,
    4.82 +D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects,
    4.83                      int count)
    4.84  {
    4.85      D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
    4.86 @@ -1092,12 +1092,12 @@
    4.87      color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
    4.88  
    4.89      for (i = 0; i < count; ++i) {
    4.90 -        const SDL_Rect *rect = &rects[i];
    4.91 +        const SDL_FRect *rect = &rects[i];
    4.92  
    4.93 -        minx = (float) rect->x;
    4.94 -        miny = (float) rect->y;
    4.95 -        maxx = (float) rect->x + rect->w;
    4.96 -        maxy = (float) rect->y + rect->h;
    4.97 +        minx = rect->x;
    4.98 +        miny = rect->y;
    4.99 +        maxx = rect->x + rect->w;
   4.100 +        maxy = rect->y + rect->h;
   4.101  
   4.102          vertices[0].x = minx;
   4.103          vertices[0].y = miny;
   4.104 @@ -1140,7 +1140,7 @@
   4.105  
   4.106  static int
   4.107  D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   4.108 -               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
   4.109 +               const SDL_Rect * srcrect, const SDL_FRect * dstrect)
   4.110  {
   4.111      D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   4.112      D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
   4.113 @@ -1155,10 +1155,10 @@
   4.114          return -1;
   4.115      }
   4.116  
   4.117 -    minx = (float) dstrect->x - 0.5f;
   4.118 -    miny = (float) dstrect->y - 0.5f;
   4.119 -    maxx = (float) dstrect->x + dstrect->w - 0.5f;
   4.120 -    maxy = (float) dstrect->y + dstrect->h - 0.5f;
   4.121 +    minx = dstrect->x - 0.5f;
   4.122 +    miny = dstrect->y - 0.5f;
   4.123 +    maxx = dstrect->x + dstrect->w - 0.5f;
   4.124 +    maxy = dstrect->y + dstrect->h - 0.5f;
   4.125  
   4.126      minu = (float) srcrect->x / texture->w;
   4.127      maxu = (float) (srcrect->x + srcrect->w) / texture->w;
   4.128 @@ -1239,8 +1239,8 @@
   4.129  
   4.130  static int
   4.131  D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
   4.132 -               const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   4.133 -               const double angle, const SDL_Point * center, const SDL_RendererFlip flip)
   4.134 +               const SDL_Rect * srcrect, const SDL_FRect * dstrect,
   4.135 +               const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip)
   4.136  {
   4.137      D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   4.138      D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
   4.139 @@ -1256,25 +1256,25 @@
   4.140          return -1;
   4.141      }
   4.142  
   4.143 -    centerx = (float)center->x;
   4.144 -    centery = (float)center->y;
   4.145 +    centerx = center->x;
   4.146 +    centery = center->y;
   4.147  
   4.148      if (flip & SDL_FLIP_HORIZONTAL) {
   4.149 -        minx = (float) dstrect->w - centerx - 0.5f;
   4.150 -        maxx = (float) -centerx - 0.5f;
   4.151 +        minx = dstrect->w - centerx - 0.5f;
   4.152 +        maxx = -centerx - 0.5f;
   4.153      }
   4.154      else {
   4.155 -        minx = (float) -centerx - 0.5f;
   4.156 -        maxx = (float) dstrect->w - centerx - 0.5f;
   4.157 +        minx = -centerx - 0.5f;
   4.158 +        maxx = dstrect->w - centerx - 0.5f;
   4.159      }
   4.160  
   4.161      if (flip & SDL_FLIP_VERTICAL) {
   4.162 -        miny = (float) dstrect->h - centery - 0.5f;
   4.163 -        maxy = (float) -centery - 0.5f;
   4.164 +        miny = dstrect->h - centery - 0.5f;
   4.165 +        maxy = -centery - 0.5f;
   4.166      }
   4.167      else {
   4.168 -        miny = (float) -centery - 0.5f;
   4.169 -        maxy = (float) dstrect->h - centery - 0.5f;
   4.170 +        miny = -centery - 0.5f;
   4.171 +        maxy = dstrect->h - centery - 0.5f;
   4.172      }
   4.173  
   4.174      minu = (float) srcrect->x / texture->w;
     5.1 --- a/src/render/opengl/SDL_glfuncs.h	Mon Oct 01 00:56:58 2012 -0700
     5.2 +++ b/src/render/opengl/SDL_glfuncs.h	Mon Oct 01 20:59:33 2012 -0700
     5.3 @@ -322,10 +322,10 @@
     5.4  SDL_PROC_UNUSED(void, glRectd,
     5.5                  (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2))
     5.6  SDL_PROC_UNUSED(void, glRectdv, (const GLdouble * v1, const GLdouble * v2))
     5.7 -SDL_PROC_UNUSED(void, glRectf,
     5.8 +SDL_PROC(void, glRectf,
     5.9                  (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
    5.10  SDL_PROC_UNUSED(void, glRectfv, (const GLfloat * v1, const GLfloat * v2))
    5.11 -SDL_PROC(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2))
    5.12 +SDL_PROC_UNUSED(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2))
    5.13  SDL_PROC_UNUSED(void, glRectiv, (const GLint * v1, const GLint * v2))
    5.14  SDL_PROC_UNUSED(void, glRects,
    5.15                  (GLshort x1, GLshort y1, GLshort x2, GLshort y2))
     6.1 --- a/src/render/opengl/SDL_render_gl.c	Mon Oct 01 00:56:58 2012 -0700
     6.2 +++ b/src/render/opengl/SDL_render_gl.c	Mon Oct 01 20:59:33 2012 -0700
     6.3 @@ -58,16 +58,16 @@
     6.4  static int GL_UpdateViewport(SDL_Renderer * renderer);
     6.5  static int GL_RenderClear(SDL_Renderer * renderer);
     6.6  static int GL_RenderDrawPoints(SDL_Renderer * renderer,
     6.7 -                               const SDL_Point * points, int count);
     6.8 +                               const SDL_FPoint * points, int count);
     6.9  static int GL_RenderDrawLines(SDL_Renderer * renderer,
    6.10 -                              const SDL_Point * points, int count);
    6.11 +                              const SDL_FPoint * points, int count);
    6.12  static int GL_RenderFillRects(SDL_Renderer * renderer,
    6.13 -                              const SDL_Rect * rects, int count);
    6.14 +                              const SDL_FRect * rects, int count);
    6.15  static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    6.16 -                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    6.17 +                         const SDL_Rect * srcrect, const SDL_FRect * dstrect);
    6.18  static int GL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
    6.19 -                         const SDL_Rect * srcrect, const SDL_Rect * dstrect,
    6.20 -                         const double angle, const SDL_Point *center, const SDL_RendererFlip flip);
    6.21 +                         const SDL_Rect * srcrect, const SDL_FRect * dstrect,
    6.22 +                         const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
    6.23  static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    6.24                                 Uint32 pixel_format, void * pixels, int pitch);
    6.25  static void GL_RenderPresent(SDL_Renderer * renderer);
    6.26 @@ -876,7 +876,7 @@
    6.27  }
    6.28  
    6.29  static int
    6.30 -GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
    6.31 +GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
    6.32                      int count)
    6.33  {
    6.34      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    6.35 @@ -894,7 +894,7 @@
    6.36  }
    6.37  
    6.38  static int
    6.39 -GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
    6.40 +GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
    6.41                     int count)
    6.42  {
    6.43      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    6.44 @@ -959,7 +959,7 @@
    6.45  }
    6.46  
    6.47  static int
    6.48 -GL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count)
    6.49 +GL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count)
    6.50  {
    6.51      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    6.52      int i;
    6.53 @@ -967,9 +967,9 @@
    6.54      GL_SetDrawingState(renderer);
    6.55  
    6.56      for (i = 0; i < count; ++i) {
    6.57 -        const SDL_Rect *rect = &rects[i];
    6.58 +        const SDL_FRect *rect = &rects[i];
    6.59  
    6.60 -        data->glRecti(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
    6.61 +        data->glRectf(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
    6.62      }
    6.63      GL_CheckError("", renderer);
    6.64  
    6.65 @@ -978,11 +978,11 @@
    6.66  
    6.67  static int
    6.68  GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    6.69 -              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
    6.70 +              const SDL_Rect * srcrect, const SDL_FRect * dstrect)
    6.71  {
    6.72      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    6.73      GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
    6.74 -    int minx, miny, maxx, maxy;
    6.75 +    GLfloat minx, miny, maxx, maxy;
    6.76      GLfloat minu, maxu, minv, maxv;
    6.77  
    6.78      GL_ActivateRenderer(renderer);
    6.79 @@ -1029,13 +1029,13 @@
    6.80  
    6.81      data->glBegin(GL_TRIANGLE_STRIP);
    6.82      data->glTexCoord2f(minu, minv);
    6.83 -    data->glVertex2f((GLfloat) minx, (GLfloat) miny);
    6.84 +    data->glVertex2f(minx, miny);
    6.85      data->glTexCoord2f(maxu, minv);
    6.86 -    data->glVertex2f((GLfloat) maxx, (GLfloat) miny);
    6.87 +    data->glVertex2f(maxx, miny);
    6.88      data->glTexCoord2f(minu, maxv);
    6.89 -    data->glVertex2f((GLfloat) minx, (GLfloat) maxy);
    6.90 +    data->glVertex2f(minx, maxy);
    6.91      data->glTexCoord2f(maxu, maxv);
    6.92 -    data->glVertex2f((GLfloat) maxx, (GLfloat) maxy);
    6.93 +    data->glVertex2f(maxx, maxy);
    6.94      data->glEnd();
    6.95  
    6.96      data->glDisable(texturedata->type);
    6.97 @@ -1047,8 +1047,8 @@
    6.98  
    6.99  static int
   6.100  GL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
   6.101 -              const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   6.102 -              const double angle, const SDL_Point *center, const SDL_RendererFlip flip)
   6.103 +              const SDL_Rect * srcrect, const SDL_FRect * dstrect,
   6.104 +              const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
   6.105  {
   6.106      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
   6.107      GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
   6.108 @@ -1083,25 +1083,25 @@
   6.109          GL_SetShader(data, SHADER_RGB);
   6.110      }
   6.111  
   6.112 -    centerx = (GLfloat)center->x;
   6.113 -    centery = (GLfloat)center->y;
   6.114 +    centerx = center->x;
   6.115 +    centery = center->y;
   6.116  
   6.117      if (flip & SDL_FLIP_HORIZONTAL) {
   6.118 -        minx = (GLfloat) dstrect->w - centerx;
   6.119 +        minx =  dstrect->w - centerx;
   6.120          maxx = -centerx;
   6.121      }
   6.122      else {
   6.123          minx = -centerx;
   6.124 -        maxx = (GLfloat) dstrect->w - centerx;
   6.125 +        maxx =  dstrect->w - centerx;
   6.126      }
   6.127  
   6.128      if (flip & SDL_FLIP_VERTICAL) {
   6.129 -        miny = (GLfloat) dstrect->h - centery;
   6.130 +        miny =  dstrect->h - centery;
   6.131          maxy = -centery;
   6.132      }
   6.133      else {
   6.134          miny = -centery;
   6.135 -        maxy = (GLfloat) dstrect->h - centery;
   6.136 +        maxy =  dstrect->h - centery;
   6.137      }
   6.138  
   6.139      minu = (GLfloat) srcrect->x / texture->w;
     7.1 --- a/src/render/opengles/SDL_glesfuncs.h	Mon Oct 01 00:56:58 2012 -0700
     7.2 +++ b/src/render/opengles/SDL_glesfuncs.h	Mon Oct 01 20:59:33 2012 -0700
     7.3 @@ -7,7 +7,7 @@
     7.4  SDL_PROC(void, glDisable, (GLenum))
     7.5  SDL_PROC(void, glDisableClientState, (GLenum array))
     7.6  SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei))
     7.7 -SDL_PROC(void, glDrawTexiOES, (GLint, GLint, GLint, GLint, GLint))
     7.8 +SDL_PROC(void, glDrawTexfOES, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat))
     7.9  SDL_PROC(void, glEnable, (GLenum))
    7.10  SDL_PROC(void, glEnableClientState, (GLenum))
    7.11  SDL_PROC(void, glFinish, (void))
     8.1 --- a/src/render/opengles/SDL_render_gles.c	Mon Oct 01 00:56:58 2012 -0700
     8.2 +++ b/src/render/opengles/SDL_render_gles.c	Mon Oct 01 20:59:33 2012 -0700
     8.3 @@ -61,19 +61,19 @@
     8.4  static int GLES_UpdateViewport(SDL_Renderer * renderer);
     8.5  static int GLES_RenderClear(SDL_Renderer * renderer);
     8.6  static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
     8.7 -                                 const SDL_Point * points, int count);
     8.8 +                                 const SDL_FPoint * points, int count);
     8.9  static int GLES_RenderDrawLines(SDL_Renderer * renderer,
    8.10 -                                const SDL_Point * points, int count);
    8.11 +                                const SDL_FPoint * points, int count);
    8.12  static int GLES_RenderFillRects(SDL_Renderer * renderer,
    8.13 -                                const SDL_Rect * rects, int count);
    8.14 +                                const SDL_FRect * rects, int count);
    8.15  static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    8.16                             const SDL_Rect * srcrect,
    8.17 -                           const SDL_Rect * dstrect);
    8.18 +                           const SDL_FRect * dstrect);
    8.19 +static int GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
    8.20 +                         const SDL_Rect * srcrect, const SDL_FRect * dstrect,
    8.21 +                         const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
    8.22  static int GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    8.23                      Uint32 pixel_format, void * pixels, int pitch);
    8.24 -static int GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
    8.25 -                         const SDL_Rect * srcrect, const SDL_Rect * dstrect,
    8.26 -                         const double angle, const SDL_Point *center, const SDL_RendererFlip flip);
    8.27  static void GLES_RenderPresent(SDL_Renderer * renderer);
    8.28  static void GLES_DestroyTexture(SDL_Renderer * renderer,
    8.29                                  SDL_Texture * texture);
    8.30 @@ -309,8 +309,8 @@
    8.31      renderer->RenderDrawLines = GLES_RenderDrawLines;
    8.32      renderer->RenderFillRects = GLES_RenderFillRects;
    8.33      renderer->RenderCopy = GLES_RenderCopy;
    8.34 +    renderer->RenderCopyEx = GLES_RenderCopyEx;
    8.35      renderer->RenderReadPixels = GLES_RenderReadPixels;
    8.36 -    renderer->RenderCopyEx = GLES_RenderCopyEx;
    8.37      renderer->RenderPresent = GLES_RenderPresent;
    8.38      renderer->DestroyTexture = GLES_DestroyTexture;
    8.39      renderer->DestroyRenderer = GLES_DestroyRenderer;
    8.40 @@ -732,43 +732,28 @@
    8.41  }
    8.42  
    8.43  static int
    8.44 -GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
    8.45 +GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
    8.46                        int count)
    8.47  {
    8.48      GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
    8.49 -    int i;
    8.50 -    GLshort *vertices;
    8.51  
    8.52      GLES_SetDrawingState(renderer);
    8.53  
    8.54 -    vertices = SDL_stack_alloc(GLshort, count*2);
    8.55 -    for (i = 0; i < count; ++i) {
    8.56 -        vertices[2*i+0] = (GLshort)points[i].x;
    8.57 -        vertices[2*i+1] = (GLshort)points[i].y;
    8.58 -    }
    8.59 -    data->glVertexPointer(2, GL_SHORT, 0, vertices);
    8.60 +    data->glVertexPointer(2, GL_FLOAT, 0, points);
    8.61      data->glDrawArrays(GL_POINTS, 0, count);
    8.62 -    SDL_stack_free(vertices);
    8.63  
    8.64      return 0;
    8.65  }
    8.66  
    8.67  static int
    8.68 -GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
    8.69 +GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
    8.70                       int count)
    8.71  {
    8.72      GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
    8.73 -    int i;
    8.74 -    GLshort *vertices;
    8.75  
    8.76      GLES_SetDrawingState(renderer);
    8.77  
    8.78 -    vertices = SDL_stack_alloc(GLshort, count*2);
    8.79 -    for (i = 0; i < count; ++i) {
    8.80 -        vertices[2*i+0] = (GLshort)points[i].x;
    8.81 -        vertices[2*i+1] = (GLshort)points[i].y;
    8.82 -    }
    8.83 -    data->glVertexPointer(2, GL_SHORT, 0, vertices);
    8.84 +    data->glVertexPointer(2, GL_FLOAT, 0, points);
    8.85      if (count > 2 && 
    8.86          points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
    8.87          /* GL_LINE_LOOP takes care of the final segment */
    8.88 @@ -779,13 +764,12 @@
    8.89          /* We need to close the endpoint of the line */
    8.90          data->glDrawArrays(GL_POINTS, count-1, 1);
    8.91      }
    8.92 -    SDL_stack_free(vertices);
    8.93  
    8.94      return 0;
    8.95  }
    8.96  
    8.97  static int
    8.98 -GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects,
    8.99 +GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects,
   8.100                       int count)
   8.101  {
   8.102      GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
   8.103 @@ -794,12 +778,12 @@
   8.104      GLES_SetDrawingState(renderer);
   8.105  
   8.106      for (i = 0; i < count; ++i) {
   8.107 -        const SDL_Rect *rect = &rects[i];
   8.108 -        GLshort minx = rect->x;
   8.109 -        GLshort maxx = rect->x + rect->w;
   8.110 -        GLshort miny = rect->y;
   8.111 -        GLshort maxy = rect->y + rect->h;
   8.112 -        GLshort vertices[8];
   8.113 +        const SDL_FRect *rect = &rects[i];
   8.114 +        GLfloat minx = rect->x;
   8.115 +        GLfloat maxx = rect->x + rect->w;
   8.116 +        GLfloat miny = rect->y;
   8.117 +        GLfloat maxy = rect->y + rect->h;
   8.118 +        GLfloat vertices[8];
   8.119          vertices[0] = minx;
   8.120          vertices[1] = miny;
   8.121          vertices[2] = maxx;
   8.122 @@ -809,7 +793,7 @@
   8.123          vertices[6] = maxx;
   8.124          vertices[7] = maxy;
   8.125  
   8.126 -        data->glVertexPointer(2, GL_SHORT, 0, vertices);
   8.127 +        data->glVertexPointer(2, GL_FLOAT, 0, vertices);
   8.128          data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   8.129      }
   8.130  
   8.131 @@ -818,12 +802,12 @@
   8.132  
   8.133  static int
   8.134  GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   8.135 -                const SDL_Rect * srcrect, const SDL_Rect * dstrect)
   8.136 +                const SDL_Rect * srcrect, const SDL_FRect * dstrect)
   8.137  {
   8.138  
   8.139      GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
   8.140      GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
   8.141 -    int minx, miny, maxx, maxy;
   8.142 +    GLfloat minx, miny, maxx, maxy;
   8.143      GLfloat minu, maxu, minv, maxv;
   8.144  
   8.145      GLES_ActivateRenderer(renderer);
   8.146 @@ -856,7 +840,7 @@
   8.147              cropRect[3] = srcrect->h;
   8.148              data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
   8.149                                     cropRect);
   8.150 -            data->glDrawTexiOES(renderer->viewport.x + dstrect->x, renderer->viewport.y + dstrect->y, 0,
   8.151 +            data->glDrawTexfOES(renderer->viewport.x + dstrect->x, renderer->viewport.y + dstrect->y, 0,
   8.152                                  dstrect->w, dstrect->h);
   8.153          } else {
   8.154              cropRect[0] = srcrect->x;
   8.155 @@ -865,7 +849,7 @@
   8.156              cropRect[3] = -srcrect->h;
   8.157              data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
   8.158                                     cropRect);
   8.159 -            data->glDrawTexiOES(renderer->viewport.x + dstrect->x,
   8.160 +            data->glDrawTexfOES(renderer->viewport.x + dstrect->x,
   8.161                          h - (renderer->viewport.y + dstrect->y) - dstrect->h, 0,
   8.162                          dstrect->w, dstrect->h);
   8.163          }
   8.164 @@ -885,7 +869,7 @@
   8.165          maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
   8.166          maxv *= texturedata->texh;
   8.167  
   8.168 -        GLshort vertices[8];
   8.169 +        GLfloat vertices[8];
   8.170          GLfloat texCoords[8];
   8.171  
   8.172          vertices[0] = minx;
   8.173 @@ -906,7 +890,7 @@
   8.174          texCoords[6] = maxu;
   8.175          texCoords[7] = maxv;
   8.176  
   8.177 -        data->glVertexPointer(2, GL_SHORT, 0, vertices);
   8.178 +        data->glVertexPointer(2, GL_FLOAT, 0, vertices);
   8.179          data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
   8.180          data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   8.181      }
   8.182 @@ -916,6 +900,96 @@
   8.183  }
   8.184  
   8.185  static int
   8.186 +GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
   8.187 +                const SDL_Rect * srcrect, const SDL_FRect * dstrect,
   8.188 +                const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
   8.189 +{
   8.190 +
   8.191 +    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
   8.192 +    GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
   8.193 +    GLfloat minx, miny, maxx, maxy;
   8.194 +    GLfloat minu, maxu, minv, maxv;
   8.195 +    GLfloat centerx, centery;
   8.196 +    
   8.197 +    GLES_ActivateRenderer(renderer);
   8.198 +
   8.199 +    data->glEnable(GL_TEXTURE_2D);
   8.200 +
   8.201 +    data->glBindTexture(texturedata->type, texturedata->texture);
   8.202 +
   8.203 +    if (texture->modMode) {
   8.204 +        GLES_SetColor(data, texture->r, texture->g, texture->b, texture->a);
   8.205 +    } else {
   8.206 +        GLES_SetColor(data, 255, 255, 255, 255);
   8.207 +    }
   8.208 +
   8.209 +    GLES_SetBlendMode(data, texture->blendMode);
   8.210 +
   8.211 +    GLES_SetTexCoords(data, SDL_TRUE);
   8.212 +
   8.213 +    centerx = center->x;
   8.214 +    centery = center->y;
   8.215 +
   8.216 +    // Rotate and translate
   8.217 +    data->glPushMatrix();
   8.218 +    data->glTranslatef(dstrect->x + centerx, dstrect->y + centery, 0.0f);
   8.219 +    data->glRotatef((GLfloat)angle, 0.0f, 0.0f, 1.0f);
   8.220 +
   8.221 +    if (flip & SDL_FLIP_HORIZONTAL) {
   8.222 +        minx =  dstrect->w - centerx;
   8.223 +        maxx = -centerx;
   8.224 +    } else {
   8.225 +        minx = -centerx;
   8.226 +        maxx = dstrect->w - centerx;
   8.227 +    }
   8.228 +
   8.229 +    if (flip & SDL_FLIP_VERTICAL) {
   8.230 +        miny = dstrect->h - centery;
   8.231 +        maxy = -centery;
   8.232 +    } else {
   8.233 +        miny = -centery;
   8.234 +        maxy = dstrect->h - centery;
   8.235 +    }
   8.236 +
   8.237 +    minu = (GLfloat) srcrect->x / texture->w;
   8.238 +    minu *= texturedata->texw;
   8.239 +    maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
   8.240 +    maxu *= texturedata->texw;
   8.241 +    minv = (GLfloat) srcrect->y / texture->h;
   8.242 +    minv *= texturedata->texh;
   8.243 +    maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
   8.244 +    maxv *= texturedata->texh;
   8.245 +
   8.246 +    GLfloat vertices[8];
   8.247 +    GLfloat texCoords[8];
   8.248 +
   8.249 +    vertices[0] = minx;
   8.250 +    vertices[1] = miny;
   8.251 +    vertices[2] = maxx;
   8.252 +    vertices[3] = miny;
   8.253 +    vertices[4] = minx;
   8.254 +    vertices[5] = maxy;
   8.255 +    vertices[6] = maxx;
   8.256 +    vertices[7] = maxy;
   8.257 +
   8.258 +    texCoords[0] = minu;
   8.259 +    texCoords[1] = minv;
   8.260 +    texCoords[2] = maxu;
   8.261 +    texCoords[3] = minv;
   8.262 +    texCoords[4] = minu;
   8.263 +    texCoords[5] = maxv;
   8.264 +    texCoords[6] = maxu;
   8.265 +    texCoords[7] = maxv;
   8.266 +    data->glVertexPointer(2, GL_FLOAT, 0, vertices);
   8.267 +    data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
   8.268 +    data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   8.269 +    data->glPopMatrix();
   8.270 +    data->glDisable(GL_TEXTURE_2D);
   8.271 +
   8.272 +    return 0;
   8.273 +}
   8.274 +
   8.275 +static int
   8.276  GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
   8.277                      Uint32 pixel_format, void * pixels, int pitch)
   8.278  {
   8.279 @@ -967,98 +1041,6 @@
   8.280      return status;
   8.281  }
   8.282  
   8.283 -static int
   8.284 -GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
   8.285 -                const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   8.286 -                const double angle, const SDL_Point *center, const SDL_RendererFlip flip)
   8.287 -{
   8.288 -
   8.289 -    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
   8.290 -    GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
   8.291 -    int minx, miny, maxx, maxy;
   8.292 -    GLfloat minu, maxu, minv, maxv;
   8.293 -    GLfloat centerx, centery;
   8.294 -    
   8.295 -    GLES_ActivateRenderer(renderer);
   8.296 -
   8.297 -    data->glEnable(GL_TEXTURE_2D);
   8.298 -
   8.299 -    data->glBindTexture(texturedata->type, texturedata->texture);
   8.300 -
   8.301 -    if (texture->modMode) {
   8.302 -        GLES_SetColor(data, texture->r, texture->g, texture->b, texture->a);
   8.303 -    } else {
   8.304 -        GLES_SetColor(data, 255, 255, 255, 255);
   8.305 -    }
   8.306 -
   8.307 -    GLES_SetBlendMode(data, texture->blendMode);
   8.308 -
   8.309 -    GLES_SetTexCoords(data, SDL_TRUE);
   8.310 -
   8.311 -    centerx = (GLfloat)center->x;
   8.312 -    centery = (GLfloat)center->y;
   8.313 -
   8.314 -    // Rotate and translate
   8.315 -    data->glPushMatrix();
   8.316 -    data->glTranslatef((GLfloat)dstrect->x + centerx, (GLfloat)dstrect->y + centery, (GLfloat)0.0);
   8.317 -    data->glRotatef((GLfloat)angle, (GLfloat)0.0, (GLfloat)0.0, (GLfloat)1.0);
   8.318 -
   8.319 -    if (flip & SDL_FLIP_HORIZONTAL) {
   8.320 -        minx = (GLfloat) dstrect->w - centerx;
   8.321 -        maxx = -centerx;
   8.322 -    }
   8.323 -    else {
   8.324 -        minx = -centerx;
   8.325 -        maxx = dstrect->w - centerx;
   8.326 -    }
   8.327 -
   8.328 -    if (flip & SDL_FLIP_VERTICAL) {
   8.329 -        miny = dstrect->h - centery;
   8.330 -        maxy = -centery;
   8.331 -    }
   8.332 -    else {
   8.333 -        miny = -centery;
   8.334 -        maxy = dstrect->h - centery;
   8.335 -    }
   8.336 -
   8.337 -    minu = (GLfloat) srcrect->x / texture->w;
   8.338 -    minu *= texturedata->texw;
   8.339 -    maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
   8.340 -    maxu *= texturedata->texw;
   8.341 -    minv = (GLfloat) srcrect->y / texture->h;
   8.342 -    minv *= texturedata->texh;
   8.343 -    maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
   8.344 -    maxv *= texturedata->texh;
   8.345 -
   8.346 -    GLshort vertices[8];
   8.347 -    GLfloat texCoords[8];
   8.348 -
   8.349 -    vertices[0] = minx;
   8.350 -    vertices[1] = miny;
   8.351 -    vertices[2] = maxx;
   8.352 -    vertices[3] = miny;
   8.353 -    vertices[4] = minx;
   8.354 -    vertices[5] = maxy;
   8.355 -    vertices[6] = maxx;
   8.356 -    vertices[7] = maxy;
   8.357 -
   8.358 -    texCoords[0] = minu;
   8.359 -    texCoords[1] = minv;
   8.360 -    texCoords[2] = maxu;
   8.361 -    texCoords[3] = minv;
   8.362 -    texCoords[4] = minu;
   8.363 -    texCoords[5] = maxv;
   8.364 -    texCoords[6] = maxu;
   8.365 -    texCoords[7] = maxv;
   8.366 -    data->glVertexPointer(2, GL_SHORT, 0, vertices);
   8.367 -    data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
   8.368 -    data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   8.369 -    data->glPopMatrix();
   8.370 -    data->glDisable(GL_TEXTURE_2D);
   8.371 -
   8.372 -    return 0;
   8.373 -}
   8.374 -
   8.375  static void
   8.376  GLES_RenderPresent(SDL_Renderer * renderer)
   8.377  {
     9.1 --- a/src/render/opengles2/SDL_render_gles2.c	Mon Oct 01 00:56:58 2012 -0700
     9.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Mon Oct 01 20:59:33 2012 -0700
     9.3 @@ -945,16 +945,16 @@
     9.4  static const float inv255f = 1.0f / 255.0f;
     9.5  
     9.6  static int GLES2_RenderClear(SDL_Renderer *renderer);
     9.7 -static int GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count);
     9.8 -static int GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count);
     9.9 -static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count);
    9.10 +static int GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
    9.11 +static int GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
    9.12 +static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
    9.13  static int GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect,
    9.14 -                            const SDL_Rect *dstrect);
    9.15 +                            const SDL_FRect *dstrect);
    9.16  static int GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    9.17                      Uint32 pixel_format, void * pixels, int pitch);
    9.18  static int GLES2_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
    9.19 -                         const SDL_Rect * srcrect, const SDL_Rect * dstrect,
    9.20 -                         const double angle, const SDL_Point *center, const SDL_RendererFlip flip);
    9.21 +                         const SDL_Rect * srcrect, const SDL_FRect * dstrect,
    9.22 +                         const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
    9.23  static void GLES2_RenderPresent(SDL_Renderer *renderer);
    9.24  
    9.25  
    9.26 @@ -1054,7 +1054,7 @@
    9.27  }
    9.28  
    9.29  static int
    9.30 -GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count)
    9.31 +GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
    9.32  {
    9.33      GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
    9.34      GLfloat *vertices;
    9.35 @@ -1068,8 +1068,8 @@
    9.36      vertices = SDL_stack_alloc(GLfloat, count * 2);
    9.37      for (idx = 0; idx < count; ++idx)
    9.38      {
    9.39 -        GLfloat x = (GLfloat)points[idx].x + 0.5f;
    9.40 -        GLfloat y = (GLfloat)points[idx].y + 0.5f;
    9.41 +        GLfloat x = points[idx].x + 0.5f;
    9.42 +        GLfloat y = points[idx].y + 0.5f;
    9.43  
    9.44          vertices[idx * 2] = x;
    9.45          vertices[(idx * 2) + 1] = y;
    9.46 @@ -1087,7 +1087,7 @@
    9.47  }
    9.48  
    9.49  static int
    9.50 -GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count)
    9.51 +GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
    9.52  {
    9.53      GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
    9.54      GLfloat *vertices;
    9.55 @@ -1101,8 +1101,8 @@
    9.56      vertices = SDL_stack_alloc(GLfloat, count * 2);
    9.57      for (idx = 0; idx < count; ++idx)
    9.58      {
    9.59 -        GLfloat x = (GLfloat)points[idx].x + 0.5f;
    9.60 -        GLfloat y = (GLfloat)points[idx].y + 0.5f;
    9.61 +        GLfloat x = points[idx].x + 0.5f;
    9.62 +        GLfloat y = points[idx].y + 0.5f;
    9.63  
    9.64          vertices[idx * 2] = x;
    9.65          vertices[(idx * 2) + 1] = y;
    9.66 @@ -1126,7 +1126,7 @@
    9.67  }
    9.68  
    9.69  static int
    9.70 -GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count)
    9.71 +GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
    9.72  {
    9.73      GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
    9.74      GLfloat vertices[8];
    9.75 @@ -1139,12 +1139,12 @@
    9.76      /* Emit a line loop for each rectangle */
    9.77      rdata->glGetError();
    9.78      for (idx = 0; idx < count; ++idx) {
    9.79 -        const SDL_Rect *rect = &rects[idx];
    9.80 +        const SDL_FRect *rect = &rects[idx];
    9.81  
    9.82 -        GLfloat xMin = (GLfloat)rect->x;
    9.83 -        GLfloat xMax = (GLfloat)(rect->x + rect->w);
    9.84 -        GLfloat yMin = (GLfloat)rect->y;
    9.85 -        GLfloat yMax = (GLfloat)(rect->y + rect->h);
    9.86 +        GLfloat xMin = rect->x;
    9.87 +        GLfloat xMax = (rect->x + rect->w);
    9.88 +        GLfloat yMin = rect->y;
    9.89 +        GLfloat yMax = (rect->y + rect->h);
    9.90  
    9.91          vertices[0] = xMin;
    9.92          vertices[1] = yMin;
    9.93 @@ -1167,7 +1167,7 @@
    9.94  
    9.95  static int
    9.96  GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect,
    9.97 -                 const SDL_Rect *dstrect)
    9.98 +                 const SDL_FRect *dstrect)
    9.99  {
   9.100      GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
   9.101      GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
   9.102 @@ -1294,14 +1294,14 @@
   9.103      GLES2_SetTexCoords(rdata, SDL_TRUE);
   9.104  
   9.105      /* Emit the textured quad */
   9.106 -    vertices[0] = (GLfloat)dstrect->x;
   9.107 -    vertices[1] = (GLfloat)dstrect->y;
   9.108 -    vertices[2] = (GLfloat)(dstrect->x + dstrect->w);
   9.109 -    vertices[3] = (GLfloat)dstrect->y;
   9.110 -    vertices[4] = (GLfloat)dstrect->x;
   9.111 -    vertices[5] = (GLfloat)(dstrect->y + dstrect->h);
   9.112 -    vertices[6] = (GLfloat)(dstrect->x + dstrect->w);
   9.113 -    vertices[7] = (GLfloat)(dstrect->y + dstrect->h);
   9.114 +    vertices[0] = dstrect->x;
   9.115 +    vertices[1] = dstrect->y;
   9.116 +    vertices[2] = (dstrect->x + dstrect->w);
   9.117 +    vertices[3] = dstrect->y;
   9.118 +    vertices[4] = dstrect->x;
   9.119 +    vertices[5] = (dstrect->y + dstrect->h);
   9.120 +    vertices[6] = (dstrect->x + dstrect->w);
   9.121 +    vertices[7] = (dstrect->y + dstrect->h);
   9.122      rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
   9.123      texCoords[0] = srcrect->x / (GLfloat)texture->w;
   9.124      texCoords[1] = srcrect->y / (GLfloat)texture->h;
   9.125 @@ -1323,7 +1323,7 @@
   9.126  
   9.127  static int
   9.128  GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect,
   9.129 -                 const SDL_Rect *dstrect, const double angle, const SDL_Point *center, const SDL_RendererFlip flip)
   9.130 +                 const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
   9.131  {
   9.132      GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
   9.133      GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
   9.134 @@ -1343,8 +1343,8 @@
   9.135      rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE);
   9.136      fAngle[0] = fAngle[1] = fAngle[2] = fAngle[3] = (GLfloat)angle;
   9.137      /* Calculate the center of rotation */
   9.138 -    translate[0] = translate[2] = translate[4] = translate[6] = (GLfloat)(center->x + dstrect->x);
   9.139 -    translate[1] = translate[3] = translate[5] = translate[7] = (GLfloat)(center->y + dstrect->y);
   9.140 +    translate[0] = translate[2] = translate[4] = translate[6] = (center->x + dstrect->x);
   9.141 +    translate[1] = translate[3] = translate[5] = translate[7] = (center->y + dstrect->y);
   9.142  
   9.143      /* Activate an appropriate shader and set the projection matrix */
   9.144      blendMode = texture->blendMode;
   9.145 @@ -1460,14 +1460,14 @@
   9.146      GLES2_SetTexCoords(rdata, SDL_TRUE);
   9.147  
   9.148      /* Emit the textured quad */
   9.149 -    vertices[0] = (GLfloat)dstrect->x;
   9.150 -    vertices[1] = (GLfloat)dstrect->y;
   9.151 -    vertices[2] = (GLfloat)(dstrect->x + dstrect->w);
   9.152 -    vertices[3] = (GLfloat)dstrect->y;
   9.153 -    vertices[4] = (GLfloat)dstrect->x;
   9.154 -    vertices[5] = (GLfloat)(dstrect->y + dstrect->h);
   9.155 -    vertices[6] = (GLfloat)(dstrect->x + dstrect->w);
   9.156 -    vertices[7] = (GLfloat)(dstrect->y + dstrect->h);
   9.157 +    vertices[0] = dstrect->x;
   9.158 +    vertices[1] = dstrect->y;
   9.159 +    vertices[2] = (dstrect->x + dstrect->w);
   9.160 +    vertices[3] = dstrect->y;
   9.161 +    vertices[4] = dstrect->x;
   9.162 +    vertices[5] = (dstrect->y + dstrect->h);
   9.163 +    vertices[6] = (dstrect->x + dstrect->w);
   9.164 +    vertices[7] = (dstrect->y + dstrect->h);
   9.165      if (flip & SDL_FLIP_HORIZONTAL) {
   9.166          tmp = vertices[0];
   9.167          vertices[0] = vertices[4] = vertices[2];
    10.1 --- a/src/render/software/SDL_render_sw.c	Mon Oct 01 00:56:58 2012 -0700
    10.2 +++ b/src/render/software/SDL_render_sw.c	Mon Oct 01 20:59:33 2012 -0700
    10.3 @@ -56,16 +56,16 @@
    10.4  static int SW_UpdateViewport(SDL_Renderer * renderer);
    10.5  static int SW_RenderClear(SDL_Renderer * renderer);
    10.6  static int SW_RenderDrawPoints(SDL_Renderer * renderer,
    10.7 -                               const SDL_Point * points, int count);
    10.8 +                               const SDL_FPoint * points, int count);
    10.9  static int SW_RenderDrawLines(SDL_Renderer * renderer,
   10.10 -                              const SDL_Point * points, int count);
   10.11 +                              const SDL_FPoint * points, int count);
   10.12  static int SW_RenderFillRects(SDL_Renderer * renderer,
   10.13 -                              const SDL_Rect * rects, int count);
   10.14 +                              const SDL_FRect * rects, int count);
   10.15  static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   10.16 -                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
   10.17 +                         const SDL_Rect * srcrect, const SDL_FRect * dstrect);
   10.18  static int SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
   10.19 -                          const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   10.20 -                          const double angle, const SDL_Point * center, const SDL_RendererFlip flip);
   10.21 +                          const SDL_Rect * srcrect, const SDL_FRect * dstrect,
   10.22 +                          const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip);
   10.23  static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
   10.24                                 Uint32 format, void * pixels, int pitch);
   10.25  static void SW_RenderPresent(SDL_Renderer * renderer);
   10.26 @@ -344,28 +344,35 @@
   10.27  }
   10.28  
   10.29  static int
   10.30 -SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
   10.31 +SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
   10.32                      int count)
   10.33  {
   10.34      SDL_Surface *surface = SW_ActivateRenderer(renderer);
   10.35 -    SDL_Point *temp = NULL;
   10.36 -    int status;
   10.37 +    SDL_Point *final_points;
   10.38 +    int i, status;
   10.39  
   10.40      if (!surface) {
   10.41          return -1;
   10.42      }
   10.43  
   10.44 +    final_points = SDL_stack_alloc(SDL_Point, count);
   10.45 +    if (!final_points) {
   10.46 +        SDL_OutOfMemory();
   10.47 +        return -1;
   10.48 +    }
   10.49      if (renderer->viewport.x || renderer->viewport.y) {
   10.50 -        int i;
   10.51 -        int x = renderer->viewport.x;
   10.52 -        int y = renderer->viewport.y;
   10.53 +        float x = renderer->viewport.x * renderer->scale.x;
   10.54 +        float y = renderer->viewport.y * renderer->scale.y;
   10.55  
   10.56 -        temp = SDL_stack_alloc(SDL_Point, count);
   10.57          for (i = 0; i < count; ++i) {
   10.58 -            temp[i].x = x + points[i].x;
   10.59 -            temp[i].y = y + points[i].x;
   10.60 +            final_points[i].x = (int)(x + points[i].x);
   10.61 +            final_points[i].y = (int)(y + points[i].y);
   10.62          }
   10.63 -        points = temp;
   10.64 +    } else {
   10.65 +        for (i = 0; i < count; ++i) {
   10.66 +            final_points[i].x = (int)points[i].x;
   10.67 +            final_points[i].y = (int)points[i].y;
   10.68 +        }
   10.69      }
   10.70  
   10.71      /* Draw the points! */
   10.72 @@ -374,43 +381,48 @@
   10.73                                     renderer->r, renderer->g, renderer->b,
   10.74                                     renderer->a);
   10.75  
   10.76 -        status = SDL_DrawPoints(surface, points, count, color);
   10.77 +        status = SDL_DrawPoints(surface, final_points, count, color);
   10.78      } else {
   10.79 -        status = SDL_BlendPoints(surface, points, count,
   10.80 +        status = SDL_BlendPoints(surface, final_points, count,
   10.81                                  renderer->blendMode,
   10.82                                  renderer->r, renderer->g, renderer->b,
   10.83                                  renderer->a);
   10.84      }
   10.85 +    SDL_stack_free(final_points);
   10.86  
   10.87 -    if (temp) {
   10.88 -        SDL_stack_free(temp);
   10.89 -    }
   10.90      return status;
   10.91  }
   10.92  
   10.93  static int
   10.94 -SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
   10.95 +SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
   10.96                     int count)
   10.97  {
   10.98      SDL_Surface *surface = SW_ActivateRenderer(renderer);
   10.99 -    SDL_Point *temp = NULL;
  10.100 -    int status;
  10.101 +    SDL_Point *final_points;
  10.102 +    int i, status;
  10.103  
  10.104      if (!surface) {
  10.105          return -1;
  10.106      }
  10.107  
  10.108 +    final_points = SDL_stack_alloc(SDL_Point, count);
  10.109 +    if (!final_points) {
  10.110 +        SDL_OutOfMemory();
  10.111 +        return -1;
  10.112 +    }
  10.113      if (renderer->viewport.x || renderer->viewport.y) {
  10.114 -        int i;
  10.115 -        int x = renderer->viewport.x;
  10.116 -        int y = renderer->viewport.y;
  10.117 +        float x = renderer->viewport.x * renderer->scale.x;
  10.118 +        float y = renderer->viewport.y * renderer->scale.y;
  10.119  
  10.120 -        temp = SDL_stack_alloc(SDL_Point, count);
  10.121          for (i = 0; i < count; ++i) {
  10.122 -            temp[i].x = x + points[i].x;
  10.123 -            temp[i].y = y + points[i].y;
  10.124 +            final_points[i].x = (int)(x + points[i].x);
  10.125 +            final_points[i].y = (int)(y + points[i].y);
  10.126          }
  10.127 -        points = temp;
  10.128 +    } else {
  10.129 +        for (i = 0; i < count; ++i) {
  10.130 +            final_points[i].x = (int)points[i].x;
  10.131 +            final_points[i].y = (int)points[i].y;
  10.132 +        }
  10.133      }
  10.134  
  10.135      /* Draw the lines! */
  10.136 @@ -419,80 +431,91 @@
  10.137                                     renderer->r, renderer->g, renderer->b,
  10.138                                     renderer->a);
  10.139  
  10.140 -        status = SDL_DrawLines(surface, points, count, color);
  10.141 +        status = SDL_DrawLines(surface, final_points, count, color);
  10.142      } else {
  10.143 -        status = SDL_BlendLines(surface, points, count,
  10.144 +        status = SDL_BlendLines(surface, final_points, count,
  10.145                                  renderer->blendMode,
  10.146                                  renderer->r, renderer->g, renderer->b,
  10.147                                  renderer->a);
  10.148      }
  10.149 +    SDL_stack_free(final_points);
  10.150  
  10.151 -    if (temp) {
  10.152 -        SDL_stack_free(temp);
  10.153 -    }
  10.154      return status;
  10.155  }
  10.156  
  10.157  static int
  10.158 -SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count)
  10.159 +SW_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count)
  10.160  {
  10.161      SDL_Surface *surface = SW_ActivateRenderer(renderer);
  10.162 -    SDL_Rect *temp = NULL;
  10.163 -    int status;
  10.164 +    SDL_Rect *final_rects;
  10.165 +    int i, status;
  10.166 +
  10.167 +    if (!surface) {
  10.168 +        return -1;
  10.169 +    }
  10.170 +
  10.171 +    final_rects = SDL_stack_alloc(SDL_Rect, count);
  10.172 +    if (!final_rects) {
  10.173 +        SDL_OutOfMemory();
  10.174 +        return -1;
  10.175 +    }
  10.176 +    if (renderer->viewport.x || renderer->viewport.y) {
  10.177 +        float x = renderer->viewport.x * renderer->scale.x;
  10.178 +        float y = renderer->viewport.y * renderer->scale.y;
  10.179 +
  10.180 +        for (i = 0; i < count; ++i) {
  10.181 +            final_rects[i].x = (int)(x + rects[i].x);
  10.182 +            final_rects[i].y = (int)(y + rects[i].y);
  10.183 +            final_rects[i].w = SDL_max((int)rects[i].w, 1);
  10.184 +            final_rects[i].h = SDL_max((int)rects[i].h, 1);
  10.185 +        }
  10.186 +    } else {
  10.187 +        for (i = 0; i < count; ++i) {
  10.188 +            final_rects[i].x = (int)rects[i].x;
  10.189 +            final_rects[i].y = (int)rects[i].y;
  10.190 +            final_rects[i].w = SDL_max((int)rects[i].w, 1);
  10.191 +            final_rects[i].h = SDL_max((int)rects[i].h, 1);
  10.192 +        }
  10.193 +    }
  10.194 +
  10.195 +    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
  10.196 +        Uint32 color = SDL_MapRGBA(surface->format,
  10.197 +                                   renderer->r, renderer->g, renderer->b,
  10.198 +                                   renderer->a);
  10.199 +        status = SDL_FillRects(surface, final_rects, count, color);
  10.200 +    } else {
  10.201 +        status = SDL_BlendFillRects(surface, final_rects, count,
  10.202 +                                    renderer->blendMode,
  10.203 +                                    renderer->r, renderer->g, renderer->b,
  10.204 +                                    renderer->a);
  10.205 +    }
  10.206 +    SDL_stack_free(final_rects);
  10.207 +
  10.208 +    return status;
  10.209 +}
  10.210 +
  10.211 +static int
  10.212 +SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
  10.213 +              const SDL_Rect * srcrect, const SDL_FRect * dstrect)
  10.214 +{
  10.215 +    SDL_Surface *surface = SW_ActivateRenderer(renderer);
  10.216 +    SDL_Surface *src = (SDL_Surface *) texture->driverdata;
  10.217 +    SDL_Rect final_rect;
  10.218  
  10.219      if (!surface) {
  10.220          return -1;
  10.221      }
  10.222  
  10.223      if (renderer->viewport.x || renderer->viewport.y) {
  10.224 -        int i;
  10.225 -        int x = renderer->viewport.x;
  10.226 -        int y = renderer->viewport.y;
  10.227 +        final_rect.x = (int)((renderer->viewport.x * renderer->scale.x) + dstrect->x);
  10.228 +        final_rect.y = (int)((renderer->viewport.y * renderer->scale.y) + dstrect->y);
  10.229 +    } else {
  10.230 +        final_rect.x = (int)dstrect->x;
  10.231 +        final_rect.y = (int)dstrect->y;
  10.232 +    }
  10.233 +    final_rect.w = (int)dstrect->w;
  10.234 +    final_rect.h = (int)dstrect->h;
  10.235  
  10.236 -        temp = SDL_stack_alloc(SDL_Rect, count);
  10.237 -        for (i = 0; i < count; ++i) {
  10.238 -            temp[i].x = x + rects[i].x;
  10.239 -            temp[i].y = y + rects[i].y;
  10.240 -            temp[i].w = rects[i].w;
  10.241 -            temp[i].h = rects[i].h;
  10.242 -        }
  10.243 -        rects = temp;
  10.244 -    }
  10.245 -
  10.246 -    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
  10.247 -        Uint32 color = SDL_MapRGBA(surface->format,
  10.248 -                                   renderer->r, renderer->g, renderer->b,
  10.249 -                                   renderer->a);
  10.250 -        status = SDL_FillRects(surface, rects, count, color);
  10.251 -    } else {
  10.252 -        status = SDL_BlendFillRects(surface, rects, count,
  10.253 -                                    renderer->blendMode,
  10.254 -                                    renderer->r, renderer->g, renderer->b,
  10.255 -                                    renderer->a);
  10.256 -    }
  10.257 -
  10.258 -    if (temp) {
  10.259 -        SDL_stack_free(temp);
  10.260 -    }
  10.261 -    return status;
  10.262 -}
  10.263 -
  10.264 -static int
  10.265 -SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
  10.266 -              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
  10.267 -{
  10.268 -    SDL_Surface *surface = SW_ActivateRenderer(renderer);
  10.269 -    SDL_Surface *src = (SDL_Surface *) texture->driverdata;
  10.270 -    SDL_Rect final_rect = *dstrect;
  10.271 -
  10.272 -    if (!surface) {
  10.273 -        return -1;
  10.274 -    }
  10.275 -
  10.276 -    if (renderer->viewport.x || renderer->viewport.y) {
  10.277 -        final_rect.x += renderer->viewport.x;
  10.278 -        final_rect.y += renderer->viewport.y;
  10.279 -    }
  10.280      if ( srcrect->w == final_rect.w && srcrect->h == final_rect.h ) {
  10.281          return SDL_BlitSurface(src, srcrect, surface, &final_rect);
  10.282      } else {
  10.283 @@ -514,12 +537,12 @@
  10.284  
  10.285  static int
  10.286  SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
  10.287 -                const SDL_Rect * srcrect, const SDL_Rect * dstrect,
  10.288 -                const double angle, const SDL_Point * center, const SDL_RendererFlip flip)
  10.289 +                const SDL_Rect * srcrect, const SDL_FRect * dstrect,
  10.290 +                const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip)
  10.291  {
  10.292      SDL_Surface *surface = SW_ActivateRenderer(renderer);
  10.293      SDL_Surface *src = (SDL_Surface *) texture->driverdata;
  10.294 -    SDL_Rect final_rect = *dstrect, tmp_rect;
  10.295 +    SDL_Rect final_rect, tmp_rect;
  10.296      SDL_Surface *surface_rotated, *surface_scaled;
  10.297      Uint32 colorkey;
  10.298      int retval, dstwidth, dstheight, abscenterx, abscentery;
  10.299 @@ -530,27 +553,33 @@
  10.300      }
  10.301  
  10.302      if (renderer->viewport.x || renderer->viewport.y) {
  10.303 -        final_rect.x += renderer->viewport.x;
  10.304 -        final_rect.y += renderer->viewport.y;
  10.305 +        final_rect.x = (int)((renderer->viewport.x * renderer->scale.x) + dstrect->x);
  10.306 +        final_rect.y = (int)((renderer->viewport.y * renderer->scale.y) + dstrect->y);
  10.307 +    } else {
  10.308 +        final_rect.x = (int)dstrect->x;
  10.309 +        final_rect.y = (int)dstrect->y;
  10.310      }
  10.311 +    final_rect.w = (int)dstrect->w;
  10.312 +    final_rect.h = (int)dstrect->h;
  10.313  
  10.314      surface_scaled = SDL_CreateRGBSurface(SDL_SWSURFACE, final_rect.w, final_rect.h, src->format->BitsPerPixel,
  10.315                                            src->format->Rmask, src->format->Gmask,
  10.316                                            src->format->Bmask, src->format->Amask );
  10.317 -    SDL_GetColorKey(src, &colorkey);
  10.318 -    SDL_SetColorKey(surface_scaled, SDL_TRUE, colorkey);
  10.319 -    tmp_rect = final_rect;
  10.320 -    tmp_rect.x = 0;
  10.321 -    tmp_rect.y = 0;
  10.322      if (surface_scaled) {
  10.323 +        SDL_GetColorKey(src, &colorkey);
  10.324 +        SDL_SetColorKey(surface_scaled, SDL_TRUE, colorkey);
  10.325 +        tmp_rect = final_rect;
  10.326 +        tmp_rect.x = 0;
  10.327 +        tmp_rect.y = 0;
  10.328 +
  10.329          retval = SDL_BlitScaled(src, srcrect, surface_scaled, &tmp_rect);
  10.330          if (!retval) {
  10.331              _rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle);
  10.332              surface_rotated = _rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
  10.333              if(surface_rotated) {
  10.334                  /* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */
  10.335 -                abscenterx = final_rect.x + center->x;
  10.336 -                abscentery = final_rect.y + center->y;
  10.337 +                abscenterx = final_rect.x + (int)center->x;
  10.338 +                abscentery = final_rect.y + (int)center->y;
  10.339                  /* Compensate the angle inversion to match the behaviour of the other backends */
  10.340                  sangle = -sangle;
  10.341