Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Game::Run()
- {
- LARGE_INTEGER li;
- Double frequency;
- Double time;
- bool done, result;
- // Get the high-resolution timer frequency
- result = QueryPerformanceFrequency(&li);
- if(!result) { return; }
- // Set the timer frequency to milliseconds
- frequency = (double)li.QuadPart / 1000.0;
- // Loop until the engine wants to quit
- done = false;
- while(!done)
- {
- // Reset the timer
- QueryPerformanceCounter(&li);
- time = li.QuadPart;
- // Do frame processing
- result = Frame();
- if(!result) { done = true; }
- // Get the elasped time
- QueryPerformanceCounter(&li);
- time = li.QuadPart - time;
- time /= frequency;
- // Sleep
- Long sleeptime = mFrameTime - time;
- Sleep(max(sleeptime, 0));
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment