[SDL] Sprite Origin positions
sanette-linux at laposte.net
Fri Sep 19 08:38:33 PDT 2014
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:
> srcRect = (x,y,w,h), center=(cx,cy) ===> dstRect = (x+cx*(1-scalex),
> y+cy*(1-scaley), w*cx, h*cy)
I forgot to add that the "center" to use in RenderCopyEx is now
> and THEN, apply SDL_RenderCopyEx
> It should do exactly what you want
> Le 19/09/2014 11:48, MrTAToad a écrit :
>> I presume SDL2 does scaling first (or rather it acts on a defined
>> size) and then rotation.
>> SDL mailing list
>> SDL at lists.libsdl.org
> SDL mailing list
> SDL at lists.libsdl.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL