⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.cpp

📁 wince 3d tutorial, it has various examples
💻 CPP
字号:
#include "timer.h"

Timer::Timer()
{   
  //we must initialize all our variables
  m_diffTime = 0;
  m_accumTime = 0;
  m_fps = 0;
  m_lastTime = 0;		
	m_frameTime = 0; 
}
//-----------------------------------------------------
void Timer::UpdateTimer()
{
  long currentTime;
  static long framesPerSecond = 0;		
  static bool sw = false;
  static unsigned long firstTime = 0;
  if(!sw)
  {
    firstTime = GetTickCount();
    sw = true;
    
  }

  currentTime = GetTickCount() - firstTime; //compute time elapsed since the first UpdateTimer call
  
  m_diffTime   = currentTime - m_frameTime; //compute time elapsed since the last frame
  m_accumTime += m_diffTime;               //compute accumulated time
  m_frameTime  = currentTime;

  //compute frames per second
  framesPerSecond++;
  if(currentTime - m_lastTime > 1000 )
  {
	  m_lastTime = currentTime;
    m_fps = framesPerSecond;
    framesPerSecond = 0;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -