SDL3 - Documentation about the move to float coordinates

Hello,

I was wondering if some documentation was available about the move from using int coordinates to float? Like why SDL_RenderRect now takes an SDL_FRect when in sdl2 you could use SDL_Rect in SDL_RenderCopy?
I’ve tried to find some explanations but could not find any.

Grain of salt, I’m not a Dev so there’s probably more about the shift that I don’t know.

In the source code for SDL2 the function SDL_RenderCopy(renderer, texture, NULL, pos) would actually convert the pos SDL_Rect into an SDL_FRect behind the scenes before it sends the draw command to the GUI.

So it’s more efficient to have the user work in SDL_FRect in the first place rather than converting to and from floats every frame. (Also much of the math such as sin/cos/sqrt that are common for scaling and positioning take float or double as inputs, so it’s again faster to run a float through them than an int).

I also think that the motion and scaling are more accurate and feel smoother without the points being rounded as ints.

1 Like

If you can only draw images at integer values then they’ll jiggle as they move slowly across the screen. My WW2 game draws a tank’s hull and then the turret on top. In the old days of SDL when those could only be drawn at int values the turret would seem to jiggle about the top of the hull as it couldn’t be drawn at a floating point position. It looked nasty!

1 Like