|
DWORD currTime(timeGetTime());//当前时间
static float lastTime((float)timeGetTime());//上次时间
float timeDelta((float(currTime) - lastTime) /1000.0f);//消耗的时间
static float m_FpsCount = 0;//总帧数
static float m_TimePasted = 0;//总消耗时间
static float m_Fps = 0;//帧数
m_FpsCount++;
m_TimePasted+=timeDelta;
if(m_TimePasted>=1.0f) //每秒计算当前帧数
{
m_Fps = m_FpsCount/m_TimePasted;
m_FpsCount = 0.0f;
m_TimePasted = 0.0f;
}
char m_strFps[32];
sprintf_s(m_strFps, "%.4f", m_Fps);
//为什么m_strFps保持最大60帧
lastTime = (float)currTime;//的到上一次的时间 |
|