|
|
|
@ -3,7 +3,7 @@ |
|
|
|
|
|
|
|
|
|
FPS::FPS() { |
|
|
|
|
previousFrame = high_resolution_clock::now(); |
|
|
|
|
timeSinceUpdate = milliseconds(0); |
|
|
|
|
timeSinceUpdate = nanoseconds(0); |
|
|
|
|
framesSinceUpdate = 0; |
|
|
|
|
current = 0; |
|
|
|
|
|
|
|
|
@ -16,7 +16,7 @@ FPS::FPS() { |
|
|
|
|
void FPS::newFrame() { |
|
|
|
|
framesSinceUpdate++; |
|
|
|
|
auto thisFrame = high_resolution_clock::now(); |
|
|
|
|
timeSinceUpdate += duration_cast<milliseconds>(thisFrame - previousFrame); |
|
|
|
|
timeSinceUpdate += thisFrame - previousFrame; |
|
|
|
|
previousFrame = thisFrame; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -25,7 +25,7 @@ void FPS::setUpdateInterval(int milli) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FPS::updateCurrent() { |
|
|
|
|
current = framesSinceUpdate * 1000 / timeSinceUpdate.count(); |
|
|
|
|
current = framesSinceUpdate * 1000 * 1000 * 1000 / timeSinceUpdate.count(); |
|
|
|
|
framesSinceUpdate = 0; |
|
|
|
|
timeSinceUpdate = milliseconds(0); |
|
|
|
|
timeSinceUpdate = nanoseconds(0); |
|
|
|
|
} |
|
|
|
|