43 Uint32 ticks = SDL_GetTicks();
99 manager->
rateticks = (1000.0F /
static_cast<float>(rate));
119 if (manager ==
nullptr)
125 return (
static_cast<int>(manager->
rate));
141 if (manager ==
nullptr)
147 return (
static_cast<int>(manager->
framecount));
164 Uint32 current_ticks;
167 Uint32 time_passed = 0;
172 if (manager ==
nullptr)
194 time_passed = current_ticks - manager->
lastticks;
196 target_ticks = manager->
baseticks +
static_cast<Uint32
>(
static_cast<float>(
199 if (current_ticks <= target_ticks)
201 the_delay = target_ticks - current_ticks;
202 SDL_Delay(the_delay);
static Uint32 _getTicks()
Internal wrapper to SDL_GetTicks that ensures a non-zero return value.
void SDL_initFramerate(FPSmanager *manager)
Initialize the framerate manager.
int SDL_getFramerate(FPSmanager *manager)
Return the current target framerate in Hz.
int SDL_getFramecount(FPSmanager *manager)
Return the current framecount.
int SDL_setFramerate(FPSmanager *manager, Uint32 rate)
Set the framerate in Hz.
Uint32 SDL_framerateDelay(FPSmanager *manager)
Delay execution to maintain a constant framerate and calculate fps.
#define FPS_LOWER_LIMIT
Lowest possible rate supported by framerate controller in Hz (1/s).
#define FPS_DEFAULT
Default rate of framerate controller in Hz (1/s).
#define FPS_UPPER_LIMIT
Highest possible rate supported by framerate controller in Hz (1/s).
Structure holding the state and timing information of the framerate controller.