Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UINT TARGET_RESOLUTION = 1; // 1 millisecond target resolution
- TIMECAPS tc;
- UINT wTimerRes = 0;
- if (TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(TIMECAPS)))
- {
- wTimerRes = std::min(std::max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
- timeBeginPeriod(wTimerRes);// request minimum time resolution to 1
- }
- while(true)//main loop
- {
- mainGameLoop();
- int workedTime= calculateWorkedTime();// miliseconds
- if(workedTime < 1000/60)// target 60fps
- {
- int remainingTime = 1000/60 - workedTime;
- Sleep(remainingTime);
- }
- }
Add Comment
Please, Sign In to add comment