mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-28 02:04:20 +00: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:
@@ -859,6 +859,8 @@ SDL3_0.0.0 {
|
||||
SDL_wcsncasecmp;
|
||||
SDL_wcsncmp;
|
||||
SDL_wcsstr;
|
||||
SDL_modf;
|
||||
SDL_modff;
|
||||
# extra symbols go here (don't modify this line)
|
||||
local: *;
|
||||
};
|
||||
|
||||
@@ -887,3 +887,5 @@
|
||||
#define SDL_wcsstr SDL_wcsstr_REAL
|
||||
|
||||
/* New API symbols are added at the end */
|
||||
#define SDL_modf SDL_modf_REAL
|
||||
#define SDL_modff SDL_modff_REAL
|
||||
|
||||
@@ -932,3 +932,5 @@ SDL_DYNAPI_PROC(int,SDL_wcsncmp,(const wchar_t *a, const wchar_t *b, size_t c),(
|
||||
SDL_DYNAPI_PROC(wchar_t*,SDL_wcsstr,(const wchar_t *a, const wchar_t *b),(a,b),return)
|
||||
|
||||
/* New API symbols are added at the end */
|
||||
SDL_DYNAPI_PROC(double,SDL_modf,(double a, double *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(float,SDL_modff,(float a, float *b),(a,b),return)
|
||||
|
||||
Reference in New Issue
Block a user