PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

rotation

Hi,

I'm trying to figure out how the rotation works.

I want to rotate a 16x16 sprite using to following code:

Code:
SetRect(&rcDst, x, y, x + 16, y + 16);

fx.dwRotationAngle = 4500;
fx.rotationCenter.x = 8; // 16/2
fx.rotationCenter.y = 8; // 16/2

backbuffer.Blt(&rcDst, pSurface, &rcSrc, GDBLT_ROTATIONANGLE | GDBLT_ROTATIONCENTER, &fx);


It rotates, but I thought that since I use a rotation center it wouldn't clip any more, but it does.


Maurice


BTW. The docs say the rotation center is the position in the destination surface, but it seems to me it is the position in the destination rectangle.
Take a look in the GapiDraw forum on our website http://www.ppcstudios.com. I wrote a short tutorial on rotations for 1.04 a while back... it might help you some.
maurice: Thanks.. I'll update the documentation... Clipping will always be done to the destination rectangle (due to the nature of the algorithm. The destination rectangle is always traversed in a cache-optimized way where pixels are read from source as needed)...

//Johan
The fastest is to use as small destination rectangle as possible. The rotation uses some fixed point approximations so 90 and 180 degree rotations will still be slightly rotated.