SDL rotation glitch - flawed rotation center

Subscribers:
14,100
Published on ● Video Link: https://www.youtube.com/watch?v=UWfNYD-iyaY



Duration: 1:15
2,640 views
56


https://www.patreon.com/ulillillia --- SDL is what I used for PM's rendering. The SDL_RenderCopyEx function has an option for rotating things where you set the angle of rotation and a rotation center. The angle works fine, but it's the rotation center that's flawed. No matter what I do, I cannot get rid of the 1 pixel offset down and right that occurs when the angle is 180°. This makes it offset from the center by 1.4142 pixels (after sqrt(2)) and it's quite noticeable... and ugly. Adjust the rotation center by 1 pixel left and up and it's got that same offset. If I could use a half of a pixel, I could fix the problem but SDL doesn't support that. This video shows it, at 4x magnification.

What's going on is that the rotation center is being based on the center of the pixel in question rather than the corner as I need. From being based on the center of the pixel, this means there's a half a pixel to the left and 1 1/2 pixels to the right. This is what causes the 1-pixel misalignment. A 2-way flag can fix this, a flag for edge or center.







Tags:
ulillillia
Platform Masters