aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/manager/LoopTimerManager.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-09 17:35:20 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-09 17:35:20 +0100
commit7893342e1ba5fd01be7448244db967fda3c5cfe9 (patch)
tree6af7a1f89557f856d59dd64089d0a5fec8a84fae /src/crepe/manager/LoopTimerManager.cpp
parent66f2777086e4d554067da7400f543fe7cc9e4b0b (diff)
checked for 0 division
Diffstat (limited to 'src/crepe/manager/LoopTimerManager.cpp')
-rw-r--r--src/crepe/manager/LoopTimerManager.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/crepe/manager/LoopTimerManager.cpp b/src/crepe/manager/LoopTimerManager.cpp
index 37b9c44..70a57d2 100644
--- a/src/crepe/manager/LoopTimerManager.cpp
+++ b/src/crepe/manager/LoopTimerManager.cpp
@@ -31,6 +31,9 @@ void LoopTimerManager::update() {
if (this->delta_time > this->maximum_delta_time) {
this->delta_time = this->maximum_delta_time;
}
+ if(this->delta_time.count() <= 0){
+ this->delta_time = std::chrono::duration<double>(0.0);
+ }
this->actual_fps = 1.0 / this->delta_time.count();
this->elapsed_time += this->delta_time;
@@ -49,6 +52,10 @@ void LoopTimerManager::advance_fixed_update() {
void LoopTimerManager::set_target_fps(int fps) {
this->target_fps = fps;
+ //check if fps is lower or equals 0
+ if(fps <= 0){
+ return;
+ }
// target time per frame in seconds
this->frame_target_time = std::chrono::duration<double>(1.0) / this->target_fps;
}