Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static unsigned int next_tick = 0;
- static unsigned int tick_interval = 0;
- void sync_frame(void)
- {
- if (next_tick > SDL_GetTicks())
- {
- SDL_Delay(next_tick - SDL_GetTicks());
- }
- next_tick = SDL_GetTicks() + tick_interval;
- }
- void set_sync_rate(float rate)
- {
- tick_interval = (int)(1.0f * 1000.0f / rate);
- }
Add Comment
Please, Sign In to add comment