Guest User

Untitled

a guest
Dec 11th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. static unsigned int next_tick = 0;
  2. static unsigned int tick_interval = 0;
  3.  
  4. void sync_frame(void)
  5. {
  6.     if (next_tick > SDL_GetTicks())
  7.     {
  8.         SDL_Delay(next_tick - SDL_GetTicks());
  9.     }
  10.    
  11.     next_tick = SDL_GetTicks() + tick_interval;
  12. }
  13.  
  14. void set_sync_rate(float rate)
  15. {
  16.     tick_interval = (int)(1.0f * 1000.0f / rate);
  17. }
Add Comment
Please, Sign In to add comment