4#include <SDL3/SDL_timer.h>
5#include "SDL3pp_stdinc.h"
273 return SDL_GetPerformanceFrequency();
367 SDL_DelayPrecise(duration.count());
462 template<std::invocable<TimerID, Nanoseconds> F>
469 template<std::invocable<TimerID, Nanoseconds> F>
472 return func(timerID, std::chrono::nanoseconds(interval)).count();
514 return SDL_AddTimer(
Uint32(interval.count()), callback, userdata);
556 return CheckError(SDL_AddTimerNS(interval.count(), callback, userdata));
598 return SDL_AddTimerNS(interval.count(), callback.
wrapper, callback.
data);
SDL times are signed, 64-bit integers representing nanoseconds since the Unix epoch (Jan 1,...
Definition SDL3pp_stdinc.h:369
static constexpr Time FromNS(Sint64 time)
Create from a nanoseconds Sint64.
Definition SDL3pp_stdinc.h:417
Either integral or floating point.
Definition SDL3pp_stdinc.h:6283
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:199
std::chrono::nanoseconds Nanoseconds
Duration in Nanoseconds (Uint64).
Definition SDL3pp_stdinc.h:338
::Sint64 Sint64
A signed 64-bit integer type.
Definition SDL3pp_stdinc.h:311
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:296
std::chrono::milliseconds Milliseconds
Duration in Miliseconds (Uint32).
Definition SDL3pp_stdinc.h:341
::Uint64 Uint64
An unsigned 64-bit integer type.
Definition SDL3pp_stdinc.h:326
constexpr Sint64 ToPosix() const
Convert nanoseconds to seconds.
Definition SDL3pp_timer.h:139
constexpr Uint64 UsToNs(Number auto US)
Convert microseconds to nanoseconds.
Definition SDL3pp_timer.h:182
Uint32(SDLCALL *)(void *userdata, TimerID timerID, Uint32 interval) MSTimerCallback
Function prototype for the millisecond timer callback function.
Definition SDL3pp_timer.h:401
constexpr auto NsToMs(Number auto NS)
Convert nanoseconds to milliseconds.
Definition SDL3pp_timer.h:168
Uint64 GetPerformanceFrequency()
Get the count per second of the high resolution counter.
Definition SDL3pp_timer.h:271
Uint64 GetPerformanceCounter()
Get the current value of the high resolution counter.
Definition SDL3pp_timer.h:258
constexpr Uint32 MS_PER_SECOND
Number of milliseconds in a second.
Definition SDL3pp_timer.h:36
constexpr Uint32 NS_PER_US
Number of nanoseconds in a microsecond.
Definition SDL3pp_timer.h:72
void RemoveTimer(TimerID id)
Remove a timer created with AddTimer().
Definition SDL3pp_timer.h:613
constexpr Uint64 NS_PER_SECOND
Number of nanoseconds in a second.
Definition SDL3pp_timer.h:54
SDL_TimerID TimerID
Definition of the timer ID type.
Definition SDL3pp_timer.h:375
void DelayNS(Uint64 ns)
Wait a specified number of nanoseconds before returning.
Definition SDL3pp_timer.h:326
constexpr auto NsToUs(Number auto NS)
Convert nanoseconds to microseconds.
Definition SDL3pp_timer.h:197
Uint64 GetTicksMS()
Get the number of milliseconds that have elapsed since the SDL library initialization.
Definition SDL3pp_timer.h:228
void DelayPrecise(Uint64 ns)
Wait a specified number of nanoseconds before returning.
Definition SDL3pp_timer.h:345
constexpr Time TimeFromPosix(Sint64 time)
Convert seconds to nanoseconds.
Definition SDL3pp_timer.h:100
TimerID AddTimer(Milliseconds interval, MSTimerCallback callback, void *userdata)
Call a callback function at a future time.
Definition SDL3pp_timer.h:510
constexpr auto NsToSeconds(Number auto NS)
Convert nanoseconds to seconds.
Definition SDL3pp_timer.h:123
constexpr Uint32 NS_PER_MS
Number of nanoseconds in a millisecond.
Definition SDL3pp_timer.h:63
constexpr Uint32 US_PER_SECOND
Number of microseconds in a second.
Definition SDL3pp_timer.h:45
Uint64 GetTicksNS()
Get the number of nanoseconds since SDL library initialization.
Definition SDL3pp_timer.h:240
void Delay(Uint32 ms)
Wait a specified number of milliseconds before returning.
Definition SDL3pp_timer.h:292
Uint64(SDLCALL *)(void *userdata, TimerID timerID, Uint64 interval) NSTimerCallback
Function prototype for the nanosecond timer callback function.
Definition SDL3pp_timer.h:429
static constexpr Time FromPosix(Sint64 time)
Convert seconds to nanoseconds.
Definition SDL3pp_timer.h:105
constexpr Sint64 TimeToPosix(Time time)
Convert nanoseconds to seconds.
Definition SDL3pp_timer.h:137
constexpr Uint64 SecondsToNs(Number auto S)
Convert seconds to nanoseconds.
Definition SDL3pp_timer.h:86
constexpr Uint64 MsToNs(Number auto MS)
Convert milliseconds to nanoseconds.
Definition SDL3pp_timer.h:153
Nanoseconds GetTicks()
Get the time elapsed since SDL library initialization.
Definition SDL3pp_timer.h:212
Main include header for the SDL3pp library.
void * data
The wrapped data.
Definition SDL3pp_callbackWrapper.h:114
LightweightCallbackT(const F &func)
Definition SDL3pp_callbackWrapper.h:118
R(* wrapper)(void *, PARAMS...)
The wrapper function.
Definition SDL3pp_callbackWrapper.h:111
Function prototype for the nanosecond timer callback function.
Definition SDL3pp_timer.h:460
TimerCB(const F &func)
ctor
Definition SDL3pp_timer.h:463