TDME2 1.9.121
Timing.cpp
Go to the documentation of this file.
2
3#include <array>
4
5#include <tdme/tdme.h>
7
8using std::array;
9
12
13Timing::Timing()
14{
15 frame = 0;
16 startTime = Time::getCurrentMillis();
19 avarageFPS = 60.0f;
24 for (auto i = 0; i < avarageFPSSequence.size(); i++) avarageFPSSequence[i] = 60.0f;
25}
26
27constexpr int64_t Timing::UNDEFINED;
28
30{
32 currentFrameAtTime = Time::getCurrentMillis();
33 fps = 0;
35 fps = 1000.0f / ((currentFrameAtTime - lastFrameAtTime));
36 }
37 fps++;
38
39 // avarage fps
42 avarageFPS = 0.0f;
43 for (auto i = 0; i < avarageFPSSequence.size(); i++) avarageFPS+= avarageFPSSequence[(avarageFPSIndex - i) % avarageFPSSequence.size()];
45
46}
Timing class.
Definition: Timing.h:17
void updateTiming()
Updates timing.
Definition: Timing.cpp:29
array< float, 60 *3 > avarageFPSSequence
Definition: Timing.h:30
static constexpr int64_t UNDEFINED
Definition: Timing.h:21
int64_t currentFrameAtTime
Definition: Timing.h:27
int64_t startTime
Definition: Timing.h:25
int64_t lastFrameAtTime
Definition: Timing.h:26
Time utility class.
Definition: Time.h:21