-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.h
More file actions
63 lines (52 loc) · 1.42 KB
/
Copy pathtimer.h
File metadata and controls
63 lines (52 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//-----------------------------------------------------------------------------
// File: timer.h
//
// Timer class
//-----------------------------------------------------------------------------
#ifndef TIMER_H
#define TIMER_H
// Number of times per second the timer updates
#define GAME_TICKRATE (60.0f)
// Timer identifiers
enum timerid_t {
TID_APP, // Application timer, time since the app started
TID_PROFILE0, // Profiler timer
TID_PROFILE1, // Profiler timer
TID_PROFILE2, // Profiler timer
TID_PROFILE3, // Profiler timer
TID_PROFILE4, // Profiler timer
TID_PROFILE5, // Profiler timer
TID_PROFILE6, // Profiler timer
TID_PROFILE7, // Profiler timer
TID_PROFILE8, // Profiler timer
TID_PROFILE9, // Profiler timer
MAX_TID, // Must always be the last entry
};
/*
struct timer_t {
__int64 start_time; // Time the timer was last started
__int64 ela
static __int64 cpu_frequency;
};
*/
class timer_t {
// Timer, keeps track of when it is in the game world
public:
bool init();
void start(timerid_t timer);
void mark(timerid_t timer);
float time(timerid_t timer) { return timers[timer].mark_time; }
float elapsed(timerid_t timer) { return timers[timer].elapsed_time; }
static timer_t& get_instance();
private:
timer_t() {}
struct {
float elapsed_time;
float mark_time;
__int64 start_ticks;
__int64 mark_ticks;
} timers[MAX_TID];
__int64 cpu_frequency;
};
#define timer (timer_t::get_instance())
#endif