?? timer.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 + -