17 Timer(SDL_TimerID timer) : timer_{timer} {}
30 return SDL_RemoveTimer(timer_);
38 const auto id = SDL_AddTimer(interval,
function, user_context);
51 return create(static_cast<uint32_t>(interval.count()),
function, user_context);
55 static void delay(std::chrono::milliseconds millisec)
57 assert(millisec.count() >= 0);
58 delay(static_cast<uint32_t>(millisec.count()));
62 static void delay(uint32_t millisec) { SDL_Delay(millisec); }
65 static uint32_t
ticks_u32() {
return static_cast<uint32_t
>(
ticks().count()); }
68 static std::chrono::milliseconds
ticks() {
return std::chrono::milliseconds(SDL_GetTicks()); }
71 static uint64_t
perf_counter() {
return SDL_GetPerformanceCounter(); }
79 operator SDL_TimerID()
const {
return timer_id(); }
static std::chrono::milliseconds ticks()
Retruns the number of milliseconds.
static Timer create(std::chrono::milliseconds interval, Callback function, void *user_context)
Factory function using std::chrono.
Timer(SDL_TimerID timer)
construct
Define to deactivate exception support.
static uint64_t perf_counter()
Return the performance counter value.
SDL_TimerID timer_id() const
Get the id of this timer.
SDL_TimerCallback Callback
Just so that the type of a callback function can be.
static uint64_t perf_frequency()
Return the performace frequency value.
static void delay(std::chrono::milliseconds millisec)
Wait for millisec milliseconds.
static void delay(uint32_t millisec)
Wait for millisec milliseconds.
static uint32_t ticks_u32()
Returns the number of milliseconds elapsed as a unint32_t (standard SDL API)
static Timer create(uint32_t interval, Callback function, void *user_context)
Factory function.
Define to deactivate exception support.
Timer()=delete
A timer object that is not tied to a timer id in SDL doesn't make senes.