1 //-----------------------------------------------------------------------------
2 // Timer
3 //-----------------------------------------------------------------------------
4 
5 #ifndef __TIMER_H__
6 #define __TIMER_H__
7 
8 #ifdef WIN32
9   #include <wtypes.h>
10 #else
11   #include "types.h"
12 #endif
13 
14 #ifndef WIN32
15   typedef struct
16   {
17     DWORD LowPart;
18     LONG HighPart;
19   } LARGE_INTEGER;
20 #endif
21 
22 /**
23  * Timer class.
24  * The timer is used in every operations which has connections with time.
25  * It is used for animations, fps, etc.
26  */
27 class Timer
28 {
29   public:
30     /**
31      * Timer initialization. The timer must be initialized manually by
32      * calling this function.
33      */
34     static void Init(void);
35 
36     /**
37      * Refresh the timer. When this function is called, the timer gets
38      * the current time and store new values into public class variables.
39      * @return the number of calls of the function since the timer has
40      *         been created (if the engine calls this function each frames,
41      *         the returned value is the number of frames since the
42      *         beginning of the main loop)
43      */
44     static int Refresh(void);
45 
46     static double     fTime;      /**< time since window started */
47     static double     flastTime;    /**< last recorded time */
48     static double     frametime;    /**< time elapsed in the last frame */
49     static int        frames;     /**< number of frames */
50 
51     static LARGE_INTEGER  tFrequency;
52     static double     tResolution;
53 };
54 
55 #endif
56