[SDL] Sprite Origin positions
sanette-linux at laposte.net
Fri Sep 19 08:50:28 PDT 2014
Le 19/09/2014 17:38, Sanette a écrit :
> Le 19/09/2014 17:33, Sanette a écrit :
>> I made some quick tests and it seems that SDL_RenderCopyEx does all
>> the calculations for you:
>> if you rotate a texture around some point p, then the rotated image
>> is displayed the way you want, that is, the point p has not moved.
>> But, if you also scale the image by providing a dstRect, then
>> SDL_RenderCopyEx does not scale p for you; it first scales the
>> texture, and then rotates around the point given by the original
>> coordinates of p.
>> Therefore, the only thing you have to do, is simply to scale p before
>> rotating. Of course, since you want that the image to be stretched
>> around p you need to make the following transforms:
arg, another typo:
>> srcRect = (x,y,w,h), center=(cx,cy) ===> dstRect =
>> (x+cx*(1-scalex), y+cy*(1-scaley), w*scalex, h*scaley)
> I forgot to add that the "center" to use in RenderCopyEx is now
> (scalex*cx, scaley*cy)
>> and THEN, apply SDL_RenderCopyEx
>> It should do exactly what you want
now it works (I have tested it) !
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL