afTime.h
资源名称:AirForce.rar [点击查看]
上传用户:kaiguan
上传日期:2007-10-28
资源大小:1074k
文件大小:1k
源码类别:
其他游戏
开发平台:
Visual C++
- #ifndef AF_TIME
- #define AF_TIME
- #include <windows.h>
- /// this class represents a specific instance in time (a distinct point on the timeline)
- class afTimeInstance
- {
- public:
- afTimeInstance() {}
- afTimeInstance(LARGE_INTEGER nTime) { time = nTime; }
- LONGLONG getQuadPart() const { return time.QuadPart; }
- private:
- LARGE_INTEGER time;
- };
- /// afTime provides precise timing methods
- /**
- * afTime uses the processors VERY HIGH PRECISSION
- * timer functions, which are precise enough to bench
- * even single assembler commands...
- */
- class afTime
- {
- public:
- /// Update must only be called once per frame (before any other afTime method is used)
- static void update();
- /// Returns in seconds, how long the last frame took
- /**
- * The time difference between the last two
- * calls to update() is returned.
- */
- static float getLastFrameTime();
- /// returns the current frames per second based on the last frame time
- static float getFPS();
- static float getAverageFPS();
- /// returns the current time in very high precision as afTimeInstance object
- static afTimeInstance getCurrentTime();
- /// returns the time if seconds since which have passed since nInst
- static float getTimeSince(const afTimeInstance& nInst);
- static float lastFrameTime, totalFrameTime,fps;
- static bool firstUpdate;
- static int NumOfFrames;
- static LARGE_INTEGER time0, time1, freq;
- };
- #endif