blob: 3c0dd54aff8b54d6ea3bc2a80d023ab4e0b19a55 (
plain)
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
|
namespace PluggIt {
class FPS
{
private int frames;
private char str[20];
private Clock clock;
public FPS() {
Reset();
}
public void Reset() {
frames = 0;
str[0] = 0;
clock.Reset();
}
public void Count( float interval ) {
float time = clock.GetTime();
frames++;
if (time >= interval) {
float fps = frames / time;
snprintf( str, sizeof(str), "%.1f", fps );
frames = 0;
clock.Reset();
}
}
public const char *GetFPS() {
return str;
}
};
}
|