-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGUITimer.h
More file actions
56 lines (36 loc) · 740 Bytes
/
GUITimer.h
File metadata and controls
56 lines (36 loc) · 740 Bytes
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
#ifndef TIMER_H
#define TIMER_H
#ifdef _MSC_VER // other possibilities are WIN32 _WIN32 or _WIN64
#include "SDL_timer.h"
#else
#include "SDL/SDL_timer.h"
#endif
namespace GUI {
class GUITimer {
public:
GUITimer() : ticks_at_start(0), ticks_at_pause(0), running(false), paused(false) { }
void start();
void stop();
void pause();
void unpause();
void reset();
Uint32 get_time();
typedef Uint32 time_t;
private:
Uint32 ticks_at_start;
Uint32 ticks_at_pause;
bool running;
bool paused;
};
class FrameRateCapper {
public:
FrameRateCapper(int frames_per_second_cap);
~FrameRateCapper();
void cap_frame_rate();
private:
GUITimer fps;
int fps_cap;
bool capping;
};
} // namespace GUI
#endif /* TIMER_H */