游戏中限制帧数

GameLoop()中

static uint32 s_dwPreTime = 0;
uint32 dwCurrentTime = CStaticFunc::GetTime();
uint32 dwElapsed = dwCurrentTime - s_dwPreTime;
if (m_bLimitFPS && dwElapsed < 16)//限帧到60FPS,1000/60=16
{
  Thread::sleep(16 - dwElapsed);
  return;
}
if (s_dwPreTime == 0)
{
  dwElapsed = 0;
}
s_dwPreTime = dwCurrentTime;

 

 

你可能感兴趣的:(游戏)