rotationscalingsdl-2

SDL_RenderSetScale incorrectly applies to rotated bitmaps in SDL2 (2.0.3)


SDL_RenderSetScale will scale co-ordinates accordingly until rotation is used with SDL_RenderCopyEx. SDL seems to apply the scaling pre-rotation, so the rotated texture's aspect ratio is wrong. For example, a texture rotated 90 degrees will have the x and y scaling reversed. I've tried to calculate a formula to counteract this scaling, but the result isn't great.

I've also noticed that straight lines drawn with SDL_RenderDrawLine are drawn a different thickness according to scaling, but diagonal lines are still drawn per screen pixel.

Has anyone else had this problem? Is there another way around it to get the desired result? Is there any plan to fix SDL2 so the scaling effect is consistent throughout?


Solution

  • This has finally been fixed in SDL3. The scaling behaviour of SDL has been completely re-written and this issue is no longer a problem.