Mercurial > sdl-ios-xcode
view VisualCE/SDL.vcw @ 3333:b334b4f7dfa0
[SDL] Bad math in SDL_RenderCopy
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;
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 03 Oct 2009 16:23:16 +0000 |
parents | d63e9f5944ae |
children |
line wrap: on
line source
Microsoft eMbedded Visual Tools Workspace File, Format Version 3.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "loopwave"=.\loopwave\loopwave.vcp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name SDL End Project Dependency Begin Project Dependency Project_Dep_Name SDLmain End Project Dependency }}} ############################################################################### Project: "SDL"=.\SDL\SDL.VCP - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "SDLmain"=.\SDLmain\SDLmain.vcp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name SDL End Project Dependency }}} ############################################################################### Project: "testtimer"=.\testtimer\testtimer.vcp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name SDL End Project Dependency Begin Project Dependency Project_Dep_Name SDLmain End Project Dependency }}} ############################################################################### Project: "testalpha"=.\testalpha\testalpha.vcp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name SDL End Project Dependency Begin Project Dependency Project_Dep_Name SDLmain End Project Dependency }}} ############################################################################### Project: "testwin"=.\testwin\testwin.vcp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name SDL End Project Dependency Begin Project Dependency Project_Dep_Name SDLmain End Project Dependency }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ###############################################################################