本文整理汇总了C++中Timer::ElapsedMicroSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::ElapsedMicroSeconds方法的具体用法?C++ Timer::ElapsedMicroSeconds怎么用?C++ Timer::ElapsedMicroSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::ElapsedMicroSeconds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
void GameLoop::Run()
{
_isRunning = true;
Timer timer;
micro_seconds current = timer.ElapsedMicroSeconds();
micro_seconds accumulator = current;
while (_isRunning)
{
current = timer.ElapsedMicroSeconds();
for (
int updateNumber = 0;
updateNumber < MAX_CONSECUTIVE_UPDATES && accumulator < current;
++updateNumber)
{
accumulator += _updateDelay;
InnerUpdate(_updateDelay);
}
// If the system is running too slow for the update to run at a consistent pace
// then we need to resync the accumulator past the current time so that we can
// calculate an interpolated value for the next draw call.
if (accumulator < current)
{
micro_seconds diff = current - accumulator;
micro_seconds updatesMissed = diff / _updateDelay + 1;
accumulator += updatesMissed * _updateDelay;
}
auto interpolation = 1.0 - (double(accumulator - current) / double(_updateDelay));
InnerDraw(interpolation);
}
// TODO win32 system exit code
//return static_cast<int>(exitCode);
}