📄 time.h
字号:
#ifdef CGE_HEADER_H
#ifndef CGE_TIME_H
#define CGE_TIME_H
namespace CGE
{
namespace TIME
{
typedef class CLOCK
{
public:
CLOCK();
~CLOCK();
public:
DWORD End();
VOID Begin();
VOID Delay(DWORD dwDelay);
DWORD mm_timer_start;
__int64 performance_timer_start; // Performance Timer Start Value
static BOOL performance_timer;
static __int64 performance_timer_frequency;
}*LPCLOCK;
CGE_INLINE
VOID CLOCK::Delay( DWORD dwDelay )
{
// dwDelay为毫秒级数.
if ( performance_timer_frequency != -1)
{
while ( (End()) < dwDelay );
Begin();
}
}
typedef class FPS
{
public:
FPS();
VOID Limit(LONG fps);
FLOAT Refresh();
FLOAT GetFPS() { return m_fFPS; }
protected:
FLOAT m_fFPS; // 帧数/秒
DWORD m_dwFrameCount; // 总帧数
CLOCK m_dyTimer; // 计算FPS
CLOCK m_dyLimit; // 控制FPS
}*LPFPS;
// 控制FPS为指定值
CGE_INLINE
VOID FPS::Limit( LONG fps )
{
m_dyLimit.Delay( 1000000 / fps );
}
// 刷新当前FPS值
CGE_INLINE
FLOAT FPS::Refresh()
{
m_dwFrameCount++;
DWORD t = m_dyTimer.End();
if ( t >= 1000000 )
{
m_fFPS = (FLOAT)(m_dwFrameCount * 1000000) / (FLOAT)t;
m_dwFrameCount = 0;
m_dyTimer.Begin();
}
return m_fFPS;
}
}
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -