A timer created from OpenTK's gamewindow.
More...
|
void | Run (double updatesPerSec, double framesPerSec) |
| Runs the timer until Stop() is called. Do note that the function that calls this will be suspended until the timer is stopped. Code located after where you call this will then be executed after. More...
|
|
void | Stop () |
|
|
double | TargetRenderFrequency [get, set] |
| Gets or sets a double representing the target render frequency, in hertz. More...
|
|
double | TargetRenderPeriod [get, set] |
| Gets or sets a double representing the target render period, in seconds. More...
|
|
double | RenderFrequency [get] |
| Gets a double representing the actual frequency of RenderFrame events, in hertz (i.e. fps or frames per second). More...
|
|
double | RenderPeriod [get] |
| Gets a double representing the period of RenderFrame events, in seconds. More...
|
|
double | RenderTime [get, protected set] |
| Gets a double representing the time spent in the RenderFrame function, in seconds. More...
|
|
double | TargetUpdateFrequency [get, set] |
| Gets or sets a double representing the target update frequency, in hertz. More...
|
|
double | TargetUpdatePeriod [get, set] |
| Gets or sets a double representing the target update period, in seconds. More...
|
|
double | UpdateFrequency [get] |
| Gets a double representing the frequency of UpdateFrame events, in hertz. More...
|
|
double | UpdatePeriod [get] |
| Gets a double representing the period of UpdateFrame events, in seconds. More...
|
|
double | UpdateTime [get] |
| Gets a double representing the time spent in the UpdateFrame function, in seconds. More...
|
|
bool | IsRunning [get] |
|
A timer created from OpenTK's gamewindow.
◆ Run()
void BrawlLib.Internal.CoolTimer.Run |
( |
double |
updatesPerSec, |
|
|
double |
framesPerSec |
|
) |
| |
|
inline |
Runs the timer until Stop() is called. Do note that the function that calls this will be suspended until the timer is stopped. Code located after where you call this will then be executed after.
- Parameters
-
updatesPerSec | FPS of update events. |
framesPerSec | FPS of render events. |
216 {
217 _running = true;
218
219
220
221
224
225 _updateWatch.Reset();
226 _renderWatch.Reset();
227
229 {
230 _updateWatch.Start();
231 }
232
234 {
235 _renderWatch.Start();
236 }
237
238 while (true)
239 {
240 ProcessEvents();
241 if (!_running)
242 {
243 return;
244 }
245
246 UpdateAndRenderFrame();
247 }
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262 }
double TargetRenderFrequency
Gets or sets a double representing the target render frequency, in hertz.
Definition: CoolTimer.cs:38
double TargetUpdateFrequency
Gets or sets a double representing the target update frequency, in hertz.
Definition: CoolTimer.cs:130
◆ Stop()
void BrawlLib.Internal.CoolTimer.Stop |
( |
| ) |
|
|
inline |
393 {
394 _running = false;
395 }
◆ IsRunning
bool BrawlLib.Internal.CoolTimer.IsRunning |
|
get |
◆ RenderFrequency
double BrawlLib.Internal.CoolTimer.RenderFrequency |
|
get |
Gets a double representing the actual frequency of RenderFrame events, in hertz (i.e. fps or frames per second).
92 {
93 get
94 {
95 if (_renderPeriod == 0.0)
96 {
97 return 1.0;
98 }
99
100 return 1.0 / _renderPeriod;
101 }
102 }
◆ RenderPeriod
double BrawlLib.Internal.CoolTimer.RenderPeriod |
|
get |
Gets a double representing the period of RenderFrame events, in seconds.
◆ RenderTime
double BrawlLib.Internal.CoolTimer.RenderTime |
|
getprotected set |
Gets a double representing the time spent in the RenderFrame function, in seconds.
113 {
114 get => _renderTime;
115 protected set => _renderTime = value;
116 }
◆ TargetRenderFrequency
double BrawlLib.Internal.CoolTimer.TargetRenderFrequency |
|
getset |
Gets or sets a double representing the target render frequency, in hertz.
A value of 0.0 indicates that RenderFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities).
Values lower than 1.0Hz are clamped to 1.0Hz. Values higher than 200.0Hz are clamped to 200.0Hz.
38 {
39 get
40 {
42 {
43 return 0.0;
44 }
45
47 }
48 set
49 {
50 double v = value.Clamp(0.0, 200.0);
51
52 if (v < 1.0)
53 {
55 }
56 else
57 {
59 }
60 }
61 }
double TargetRenderPeriod
Gets or sets a double representing the target render period, in seconds.
Definition: CoolTimer.cs:71
◆ TargetRenderPeriod
double BrawlLib.Internal.CoolTimer.TargetRenderPeriod |
|
getset |
Gets or sets a double representing the target render period, in seconds.
A value of 0.0 indicates that RenderFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities).
Values lower than 0.005 seconds (200Hz) are clamped to 0.0. Values higher than 1.0 seconds (1Hz) are clamped to 1.0.
71 {
72 get => _targetRenderPeriod;
73 set
74 {
75 double v = value.Clamp(0.0, 1.0);
76
77 if (v < 0.001)
78 {
79 _targetRenderPeriod = 0.0;
80 }
81 else
82 {
83 _targetRenderPeriod = v;
84 }
85 }
86 }
◆ TargetUpdateFrequency
double BrawlLib.Internal.CoolTimer.TargetUpdateFrequency |
|
getset |
Gets or sets a double representing the target update frequency, in hertz.
A value of 0.0 indicates that UpdateFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities).
Values lower than 1.0Hz are clamped to 1.0Hz. Values higher than 200.0Hz are clamped to 200.0Hz.
130 {
131 get
132 {
134 {
135 return 0.0;
136 }
137
139 }
140 set
141 {
142 double v = value.Clamp(0.0, 200.0);
143
144 if (v < 1.0)
145 {
147 }
148 else
149 {
151 }
152 }
153 }
double TargetUpdatePeriod
Gets or sets a double representing the target update period, in seconds.
Definition: CoolTimer.cs:163
◆ TargetUpdatePeriod
double BrawlLib.Internal.CoolTimer.TargetUpdatePeriod |
|
getset |
Gets or sets a double representing the target update period, in seconds.
A value of 0.0 indicates that UpdateFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities).
Values lower than 0.005 seconds (200Hz) are clamped to 0.0. Values higher than 1.0 seconds (1Hz) are clamped to 1.0.
163 {
164 get => _targetUpdatePeriod;
165 set
166 {
167 double v = value.Clamp(0.0, 1.0);
168
169 if (v <= 0.005)
170 {
171 _targetUpdatePeriod = 0.0;
172 }
173 else
174 {
175 _targetUpdatePeriod = v;
176 }
177 }
178 }
◆ UpdateFrequency
double BrawlLib.Internal.CoolTimer.UpdateFrequency |
|
get |
Gets a double representing the frequency of UpdateFrame events, in hertz.
184 {
185 get
186 {
187 if (_updatePeriod == 0.0)
188 {
189 return 1.0;
190 }
191
192 return 1.0 / _updatePeriod;
193 }
194 }
◆ UpdatePeriod
double BrawlLib.Internal.CoolTimer.UpdatePeriod |
|
get |
Gets a double representing the period of UpdateFrame events, in seconds.
◆ UpdateTime
double BrawlLib.Internal.CoolTimer.UpdateTime |
|
get |
Gets a double representing the time spent in the UpdateFrame function, in seconds.
◆ RenderFrame
◆ UpdateFrame
The documentation for this class was generated from the following file:
- BrawlLib/Internal/CoolTimer.cs