本文整理汇总了C++中CTimeValue::SetMilliSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ CTimeValue::SetMilliSeconds方法的具体用法?C++ CTimeValue::SetMilliSeconds怎么用?C++ CTimeValue::SetMilliSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTimeValue
的用法示例。
在下文中一共展示了CTimeValue::SetMilliSeconds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateOnFrameStart
void gkTimer::UpdateOnFrameStart()
{
if(!m_bEnabled)
return;
if (sys_max_fps != 0)
{
CTimeValue timeFrameMax;
timeFrameMax.SetMilliSeconds((int64)(1000.f/(float)sys_max_fps));
static CTimeValue sTimeLast = gEnv->pTimer->GetAsyncTime();
const CTimeValue timeLast = timeFrameMax + sTimeLast;
while(timeLast.GetValue() > gEnv->pTimer->GetAsyncTime().GetValue())
{
volatile int i=0;
while(i++ < 1000);
}
sTimeLast = gEnv->pTimer->GetAsyncTime();
}
assert(m_pfnUpdate); // call Init() before
if ((m_nFrameCounter & 127)==0)
{
// every bunch of frames, check frequency to adapt to
// CPU power management clock rate changes
#ifdef OS_WIN32
LARGE_INTEGER TTicksPerSec;
if (QueryPerformanceFrequency(&TTicksPerSec))
{
// if returns false, no performance counter is available
m_lTicksPerSec=TTicksPerSec.QuadPart;
}
#endif
}
m_nFrameCounter++;
#ifdef PROFILING
m_fFrameTime = 0.020f; // 20ms = 50fps
g_lCurrentTime += (int)(m_fFrameTime*(float)(CTimeValue::TIMEVALUE_PRECISION));
m_lCurrentTime = g_lCurrentTime;
m_lLastTime = m_lCurrentTime;
RefreshGameTime(m_lCurrentTime);
RefreshUITime(m_lCurrentTime);
return;
#endif
int64 now = (*m_pfnUpdate)();
if (m_lForcedGameTime >= 0)
{
// m_lCurrentTime contains the time, which should be current
// but time has passed since Serialize until UpdateOnFrameStart
// so we have to make sure to compensate!
m_lOffsetTime = m_lForcedGameTime - now + m_lBaseTime;
m_lLastTime = now - m_lBaseTime;
m_lForcedGameTime = -1;
}
// Real time.
m_lCurrentTime = now - m_lBaseTime;
//m_fRealFrameTime = m_fFrameTime = (float)(m_lCurrentTime-m_lLastTime) / (float)(m_lTicksPerSec);
m_fRealFrameTime = m_fFrameTime = (float)((double)(m_lCurrentTime-m_lLastTime) / (double)(m_lTicksPerSec));
if( 0 != m_fixed_time_step) // Absolute zero used as a switch. looks wrong, but runs right ;-)
{
#ifdef OS_WIN32
if (m_fixed_time_step < 0)
{
// Enforce real framerate by sleeping.
float sleep = -m_fixed_time_step - m_fFrameTime;
if (sleep > 0)
{
// while first
// float now = GetAsyncCurTime();
bool breaksleep = 0;
// if (sleep < 0.01f)
// {
// for (int i=0; i < 1000000; ++i)
// {
// if( GetAsyncCurTime() - now > sleep )
// {
// breaksleep = 1;
// break;
// }
// }
// }
if (!breaksleep)
{
Sleep((unsigned int)(sleep*1000.f));
m_lCurrentTime = (*m_pfnUpdate)() - m_lBaseTime;
//m_fRealFrameTime = (float)(m_lCurrentTime-m_lLastTime) / (float)(m_lTicksPerSec);
m_fRealFrameTime = (float)((double)(m_lCurrentTime-m_lLastTime) / (double)(m_lTicksPerSec));
}
//.........这里部分代码省略.........