Guest User

Untitled

a guest
Jun 14th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. UINT TARGET_RESOLUTION = 1; // 1 millisecond target resolution
  2. TIMECAPS tc;
  3. UINT wTimerRes = 0;
  4. if (TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(TIMECAPS)))
  5. {
  6. wTimerRes = std::min(std::max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
  7. timeBeginPeriod(wTimerRes);// request minimum time resolution to 1
  8. }
  9.  
  10. while(true)//main loop
  11. {
  12. mainGameLoop();
  13. int workedTime= calculateWorkedTime();// miliseconds
  14. if(workedTime < 1000/60)// target 60fps
  15. {
  16. int remainingTime = 1000/60 - workedTime;
  17. Sleep(remainingTime);
  18. }
  19. }
Add Comment
Please, Sign In to add comment