22 lines
327 B
C++
22 lines
327 B
C++
#include "fps_limiter.h"
|
|
|
|
#include <SDL.h>
|
|
|
|
FpsLimiter::FpsLimiter(size_t fps)
|
|
: _fps(fps)
|
|
, _ticks(0)
|
|
{
|
|
}
|
|
|
|
void FpsLimiter::mark()
|
|
{
|
|
_ticks = SDL_GetTicks();
|
|
}
|
|
|
|
void FpsLimiter::throttle() const
|
|
{
|
|
if (1000 / _fps > SDL_GetTicks() - _ticks) {
|
|
SDL_Delay(1000 / _fps - (SDL_GetTicks() - _ticks));
|
|
}
|
|
}
|