[SDL] Sprite Origin positions

Sanette sanette-linux at laposte.net
Fri Sep 19 08:33:55 PDT 2014

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)

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
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140919/fe5c5569/attachment-0002.htm>

More information about the SDL mailing list