4#include <SDL3/SDL_timer.h> 
    5#include "SDL3pp_stdinc.h" 
   34  return SDL_NS_TO_SECONDS(m_time.count());
 
   49  return std::chrono::nanoseconds{SDL_GetTicksNS()};
 
   84  return SDL_GetPerformanceFrequency();
 
  102inline void Delay(std::chrono::nanoseconds duration)
 
  104  SDL_DelayNS(duration.count());
 
  124  SDL_DelayPrecise(duration.count());
 
  186  std::function<std::chrono::nanoseconds(
TimerID, std::chrono::nanoseconds)>;
 
  226  return CheckError(SDL_AddTimerNS(interval.count(), callback, userdata));
 
  270  auto cb = Wrapper::Wrap(std::move(callback));
 
  272  if (
TimerID id = SDL_AddTimerNS(
 
  275          auto& f = *static_cast<TimerCB*>(userdata);
 
  276          auto next = f(timerID, std::chrono::nanoseconds(interval)).count();
 
  278          if (next == 0) delete Store::release(timerID);
 
  282    Store::Wrap(
id, std::move(cb));
 
An exception that returns GetError()
Definition: SDL3pp_error.h:165
 
SDL times are signed, 64-bit integers representing nanoseconds since the Unix epoch (Jan 1,...
Definition: SDL3pp_stdinc.h:383
 
static constexpr Time FromNS(Sint64 time)
Create from a nanoseconds Sint64.
Definition: SDL3pp_stdinc.h:429
 
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:198
 
::Uint64 Uint64
An unsigned 64-bit integer type.
Definition: SDL3pp_stdinc.h:340
 
::Sint64 Sint64
A signed 64-bit integer type.
Definition: SDL3pp_stdinc.h:325
 
constexpr Sint64 ToPosix() const
Convert nanoseconds to seconds.
Definition: SDL3pp_timer.h:32
 
void Delay(std::chrono::nanoseconds duration)
Wait a specified duration before returning.
Definition: SDL3pp_timer.h:102
 
TimerID AddTimer(std::chrono::nanoseconds interval, TimerCallback callback, void *userdata)
Call a callback function at a future time.
Definition: SDL3pp_timer.h:222
 
void DelayPrecise(std::chrono::nanoseconds duration)
Wait a specified duration before returning.
Definition: SDL3pp_timer.h:122
 
std::function< std::chrono::nanoseconds(TimerID, std::chrono::nanoseconds)> TimerCB
Function prototype for the nanosecond timer callback function.
Definition: SDL3pp_timer.h:186
 
std::chrono::nanoseconds GetTicks()
Get the time elapsed since SDL library initialization.
Definition: SDL3pp_timer.h:47
 
Uint64 GetPerformanceFrequency()
Get the count per second of the high resolution counter.
Definition: SDL3pp_timer.h:82
 
SDL_TimerID TimerID
Definition of the timer ID type.
Definition: SDL3pp_timer.h:132
 
Uint64 GetPerformanceCounter()
Get the current value of the high resolution counter.
Definition: SDL3pp_timer.h:69
 
void RemoveTimer(TimerID id)
Remove a timer created with SDL_AddTimer().
Definition: SDL3pp_timer.h:301
 
SDL_NSTimerCallback TimerCallback
Function prototype for the nanosecond timer callback function.
Definition: SDL3pp_timer.h:158
 
static constexpr Time FromPosix(Sint64 time)
Convert seconds to nanoseconds.
Definition: SDL3pp_timer.h:27
 
Main include header for the SDL3pp library.
 
Definition: SDL3pp_callbackWrapper.h:66
 
Wrapper key to value result callbacks.
Definition: SDL3pp_callbackWrapper.h:145
 
static ValueType release(KeyType key)
Return unwrapped value associated by key and remove association.
Definition: SDL3pp_callbackWrapper.h:183