TDME2  1.9.200
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Timing.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <array>
5 
6 #include <tdme/tdme.h>
7 #include <tdme/engine/fwd-tdme.h>
8 
9 using std::array;
10 
11 /**
12  * Timing class
13  * @author Andreas Drewke
14  */
16 {
17  friend class Engine;
18 
19 public:
20  static constexpr int64_t UNDEFINED { -1LL };
21 
22 private:
23  int64_t frame;
24  int64_t startTime;
25  int64_t lastFrameAtTime;
27  float fps;
28  float avarageFPS;
29  array<float, 60 * 3> avarageFPSSequence;
30  int avarageFPSIndex { 0 };
31 
32  /**
33  * Updates timing
34  */
35  void updateTiming();
36 
37  // forbid class copy
39 
40 public:
41  /**
42  * Public constructor
43  */
44  Timing();
45 
46  /**
47  * @return frames that have been rendered
48  */
49  inline int64_t getFrame() {
50  return frame;
51  }
52 
53  /**
54  * @return start time
55  */
56  inline int64_t getStartTime() {
57  return startTime;
58  }
59 
60  /**
61  * @return total time the engine is running
62  */
63  inline int64_t getTotalTime() {
65  }
66 
67  /**
68  * @return time last frame has been rendered in ms
69  */
70  inline int64_t getLastFrameAtTime() {
71  return lastFrameAtTime;
72  }
73 
74  /**
75  * @return time current frame has been rendered in ms
76  */
77  inline int64_t getCurrentFrameAtTime() {
78  return currentFrameAtTime;
79  }
80 
81  /**
82  * Gets the time passed between last and current frame
83  * @return delta time
84  */
85  inline int64_t getDeltaTime() {
87  return 0LL;
88  }
90  }
91 
92  /**
93  * Gets the time passed between last and current frame in seconds
94  * @return delta time in seconds
95  */
96  inline float getDeltaTimeSeconds() {
97  return static_cast<float>(getDeltaTime()) / 1000.0f;
98  }
99 
100  /**
101  * @return avarage fps
102  */
103  inline float getFPS() {
104  return fps;
105  }
106 
107  /**
108  * @return avarage fps
109  */
110  inline float getAvarageFPS() {
111  return avarageFPS;
112  }
113 
114 };
Engine main class.
Definition: Engine.h:131
Timing class.
Definition: Timing.h:16
int64_t getLastFrameAtTime()
Definition: Timing.h:70
void updateTiming()
Updates timing.
Definition: Timing.cpp:29
int64_t getFrame()
Definition: Timing.h:49
int64_t getDeltaTime()
Gets the time passed between last and current frame.
Definition: Timing.h:85
array< float, 60 *3 > avarageFPSSequence
Definition: Timing.h:29
static constexpr int64_t UNDEFINED
Definition: Timing.h:20
int64_t getCurrentFrameAtTime()
Definition: Timing.h:77
int64_t getTotalTime()
Definition: Timing.h:63
float getAvarageFPS()
Definition: Timing.h:110
float getDeltaTimeSeconds()
Gets the time passed between last and current frame in seconds.
Definition: Timing.h:96
int64_t currentFrameAtTime
Definition: Timing.h:26
int64_t startTime
Definition: Timing.h:24
int64_t getStartTime()
Definition: Timing.h:56
int64_t lastFrameAtTime
Definition: Timing.h:25
Timing()
Public constructor.
Definition: Timing.cpp:13
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6