Fixed bug 5404 - stdlib: Added SDL_round, SDL_roundf, SDL_lround and SDL_lroundf

Cameron Cawley

stdlib: Added SDL_round, SDL_roundf, SDL_lround and SDL_lroundf

The default implementation is based on the one used in the Windows RT video driver.
This commit is contained in:
Sam Lantinga
2020-12-23 13:47:49 -08:00
parent d0b8295c0d
commit 93ccdee8c1
19 changed files with 105 additions and 19 deletions

View File

@@ -116,16 +116,6 @@ WINRT_TransformCursorPosition(SDL_Window * window,
return outputPosition;
}
static inline int
_lround(float arg)
{
if (arg >= 0.0f) {
return (int)floor(arg + 0.5f);
} else {
return (int)ceil(arg - 0.5f);
}
}
Uint8
WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
{
@@ -389,8 +379,8 @@ WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::Mouse
window,
0,
1,
_lround(mouseDeltaInSDLWindowCoords.X),
_lround(mouseDeltaInSDLWindowCoords.Y));
SDL_lroundf(mouseDeltaInSDLWindowCoords.X),
SDL_lroundf(mouseDeltaInSDLWindowCoords.Y));
}
#endif // SDL_VIDEO_DRIVER_WINRT