Remove int/float duplication in SDL_Render #6656
Remove int/float duplication in SDL_Render #6656
maybe we could should add: SDL_Render{Set,Get}ViewportF SDL_Render{Set,Get}ClipRectF SDL_SetWindowHitTestF
maybe we could remove the "warning C4244: 'function': conversion from 'int' to 'float'," from being treated as an error ?
Should the F suffixes be removed from the Render functions/structs? They feel a bit redundant to me now.
maybe we could should add: SDL_Render{Set,Get}ViewportF SDL_Render{Set,Get}ClipRectF SDL_SetWindowHitTestF
Normally the viewport and clip rect etc. cannot use fractional pixels (unlike rendered geometry). But I suppose if scaling is applied to their coordinate system then they'd be able to use fractional units?
it was more to have a convenient API . eg: you to {get,set} the {viewport,cliprect} using the same variable used with a FRect function. but maybe not usefull
(indeed internally, if one use SDL_RenderSetScale the clip/viewport becomes fractionnal)
I don't know if we should do this. @icculus, what's your thought on making the entire API float instead of int?
If we do end up doing this, we should remove the *F functions and just change the types of the normal functions to reduce the amount of redundant typing involved.
My thinking is the int versions can go away (and the 'F' suffix can go away).
The reason these were ints in the first place, I assume, was to make everything snap to pixel alignment, but there was clearly a desire for subpixel precision, and there's no reason an app can't use the float versions to snap to pixel alignment anyhow by truncating (or just working in ints and casting to float for the function calls).
SDL_Rect itself is useful outside the renderer, though, so we'd probably need to keep the separate SDL_FRect struct.
@icculus, do we really want to cause this for everyone using the render API?
D:\a\SDL\SDL\test\testautomation_render.c(408,13): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(409,13): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(418,19): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(419,19): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(478,13): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(479,13): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(495,19): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(496,19): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(559,13): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(560,13): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(576,19): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(577,19): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(628,13): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(629,13): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(645,19): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(646,19): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(697,13): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(698,13): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(790,19): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
D:\a\SDL\SDL\test\testautomation_render.c(791,19): warning C4244: '=': conversion from 'int' to 'float', possible loss of data [D:\a\SDL\SDL\build\SDL\test\testautomation.vcxproj]
do we really want to cause this for everyone using the render API?
Mmmm...that's not ideal. To be fair, it's a one-time migration cost, but that is messy.
... and adding (float) casts to every parameter for existing code seems like painful unnecessary work.
I'm leaning toward not changing the API here. Are there other internal benefits we would get by doing this?
@icculus, what do you think?
I went ahead and created a new pull request based on the current API changes.