mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-20 15:51:07 +01:00
Added SDL_modf() and SDL_modff()
This function is useful for accumulating relative mouse motion if you want to only handle whole pixel movement.
e.g.
static float dx_frac, dy_frac;
float dx, dy;
/* Accumulate new motion with previous sub-pixel motion */
dx = event.motion.xrel + dx_frac;
dy = event.motion.yrel + dy_frac;
/* Split the integral and fractional motion, dx and dy will contain whole pixel deltas */
dx_frac = SDL_modff(dx, &dx);
dy_frac = SDL_modff(dy, &dy);
if (dx != 0.0f || dy != 0.0f) {
...
}
This commit is contained in:
@@ -19,3 +19,4 @@ General:
|
||||
* Added SDL_GetTicksNS() to return the number of nanoseconds since the SDL library initialized
|
||||
* Added SDL_DelayNS() to specify a delay in nanoseconds, to the highest precision the system will support
|
||||
* The timestamp member of the SDL_Event structure is now in nanoseconds, filled in with the time the event was generated, or the time it was queued if that's not available
|
||||
* Added SDL_modf() and SDL_modff() to separate the whole and fractional portions of a floating point number
|
||||
|
||||
Reference in New Issue
Block a user