• Sam Lantinga's avatar
    [SDL] Bad math in SDL_RenderCopy · 7f262312
    Sam Lantinga authored
    Mason Wheeler to sdl
    
    When I tried to render an image using something other than NULL for srcrect, it got horribly distorted.  I traced it down to the fact that the math in the rectangle adjustments performed just before the call to renderer->RenderCopy is written inside out.  It should look like this:
    
           if (dstrect->w != real_dstrect.w) {
               int deltax = (dstrect->x - real_dstrect.x);
               int deltaw = (dstrect->w - real_dstrect.w);
               real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
               real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;
           }
           if (dstrect->h != real_dstrect.h) {
               int deltay = (dstrect->y - real_dstrect.y);
               int deltah = (dstrect->h - real_dstrect.h);
               real_srcrect.y += (deltay * real_srcrect.h) / dstrect->h;
               real_srcrect.h += (deltah * real_srcrect.h) / dstrect->h;
    
    --HG--
    extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403957
    7f262312
Name
Last commit
Last update
..
atomic Loading commit data...
audio Loading commit data...
cpuinfo Loading commit data...
events Loading commit data...
file Loading commit data...
haptic Loading commit data...
joystick Loading commit data...
libm Loading commit data...
loadso Loading commit data...
main Loading commit data...
power Loading commit data...
stdlib Loading commit data...
thread Loading commit data...
timer Loading commit data...
video Loading commit data...
SDL.c Loading commit data...
SDL_compat.c Loading commit data...
SDL_error.c Loading commit data...
SDL_error_c.h Loading commit data...
SDL_fatal.c Loading commit data...
SDL_fatal.h Loading commit data...