sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Bindgen.Timer.FunPtr

Synopsis

Documentation

sDL_GetTicks :: FunPtr (IO Uint64) Source #

Get the number of milliseconds that have elapsed since the SDL library initialization.

Returns
an unsigned 64‑bit integer that represents the number of milliseconds that have elapsed since the SDL library was initialized (typically via a call to SDL_Init).
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetTicksNS
C declaration
SDL_GetTicks, defined at SDL3/SDL_timer.h 201:36

Since: 3.2.0

sDL_GetTicksNS :: FunPtr (IO Uint64) Source #

Get the number of nanoseconds since SDL library initialization.

Returns
an unsigned 64-bit value representing the number of nanoseconds since the SDL library initialized.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_GetTicksNS, defined at SDL3/SDL_timer.h 213:36

Since: 3.2.0

sDL_GetPerformanceCounter :: FunPtr (IO Uint64) Source #

Get the current value of the high resolution counter.

This function is typically used for profiling.

The counter values are only meaningful relative to each other. Differences between values can be converted to times by using SDL_GetPerformanceFrequency().

Returns
the current counter value.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetPerformanceFrequency
C declaration
SDL_GetPerformanceCounter, defined at SDL3/SDL_timer.h 232:36

Since: 3.2.0

sDL_GetPerformanceFrequency :: FunPtr (IO Uint64) Source #

Get the count per second of the high resolution counter.

Returns
a platform-specific count per second.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetPerformanceCounter
C declaration
SDL_GetPerformanceFrequency, defined at SDL3/SDL_timer.h 245:36

Since: 3.2.0

sDL_Delay :: FunPtr (Uint32 -> IO ()) Source #

Wait a specified number of milliseconds before returning.

This function waits a specified number of milliseconds before returning. It waits at least the specified time, but possibly longer due to OS scheduling.

ms
the number of milliseconds to delay.
Thread safety
It is safe to call this function from any thread.
See also
sDL_DelayNS, sDL_DelayPrecise
C declaration
SDL_Delay, defined at SDL3/SDL_timer.h 263:34

Since: 3.2.0

sDL_DelayNS :: FunPtr (Uint64 -> IO ()) Source #

Wait a specified number of nanoseconds before returning.

This function waits a specified number of nanoseconds before returning. It waits at least the specified time, but possibly longer due to OS scheduling.

ns
the number of nanoseconds to delay.
Thread safety
It is safe to call this function from any thread.
See also
sDL_Delay, sDL_DelayPrecise
C declaration
SDL_DelayNS, defined at SDL3/SDL_timer.h 281:34

Since: 3.2.0

sDL_DelayPrecise :: FunPtr (Uint64 -> IO ()) Source #

Wait a specified number of nanoseconds before returning.

This function waits a specified number of nanoseconds before returning. It will attempt to wait as close to the requested time as possible, busy waiting if necessary, but could return later due to OS scheduling.

ns
the number of nanoseconds to delay.
Thread safety
It is safe to call this function from any thread.
See also
sDL_Delay, sDL_DelayNS
C declaration
SDL_DelayPrecise, defined at SDL3/SDL_timer.h 299:34

Since: 3.2.0

sDL_AddTimer :: FunPtr (Uint32 -> SDL_TimerCallback -> Ptr Void -> IO SDL_TimerID) Source #

Call a callback function at a future time.

The callback function is passed the current timer interval and the user supplied parameter from the SDL_AddTimer() call and should return the next timer interval. If the value returned from the callback is 0, the timer is canceled and will be removed.

The callback is run on a separate thread, and for short timeouts can potentially be called before this function returns.

Timers take into account the amount of time it took to execute the callback. For example, if the callback took 250 ms to execute and returned 1000 (ms), the timer would only wait another 750 ms before its next iteration.

Timing may be inexact due to OS scheduling. Be sure to note the current time with SDL_GetTicksNS() or SDL_GetPerformanceCounter() in case your callback needs to adjust for variances.

interval
the timer delay, in milliseconds, passed to callback.
callback
the SDL_TimerCallback function to call when the specified interval elapses.
userdata
a pointer that is passed to callback.
Returns
a timer ID or 0 on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_AddTimerNS, sDL_RemoveTimer
C declaration
SDL_AddTimer, defined at SDL3/SDL_timer.h 368:41

Since: 3.2.0

sDL_AddTimerNS :: FunPtr (Uint64 -> SDL_NSTimerCallback -> Ptr Void -> IO SDL_TimerID) Source #

Call a callback function at a future time.

The callback function is passed the current timer interval and the user supplied parameter from the SDL_AddTimerNS() call and should return the next timer interval. If the value returned from the callback is 0, the timer is canceled and will be removed.

The callback is run on a separate thread, and for short timeouts can potentially be called before this function returns.

Timers take into account the amount of time it took to execute the callback. For example, if the callback took 250 ns to execute and returned 1000 (ns), the timer would only wait another 750 ns before its next iteration.

Timing may be inexact due to OS scheduling. Be sure to note the current time with SDL_GetTicksNS() or SDL_GetPerformanceCounter() in case your callback needs to adjust for variances.

interval
the timer delay, in nanoseconds, passed to callback.
callback
the SDL_TimerCallback function to call when the specified interval elapses.
userdata
a pointer that is passed to callback.
Returns
a timer ID or 0 on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_AddTimer, sDL_RemoveTimer
C declaration
SDL_AddTimerNS, defined at SDL3/SDL_timer.h 430:41

Since: 3.2.0

sDL_RemoveTimer :: FunPtr (SDL_TimerID -> IO CBool) Source #

Remove a timer created with SDL_AddTimer().

id
the ID of the timer to remove.
Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_AddTimer
C declaration
SDL_RemoveTimer, defined at SDL3/SDL_timer.h 445:34

Since: 3.2.0