This repository has been archived on 2026-04-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Tortuga/client/frame_rate.hpp
T
2013-05-02 22:45:26 +10:00

30 lines
444 B
C++

#ifndef FRAMERATE_HPP_
#define FRAMERATE_HPP_
#include <ctime>
class FrameRate {
public:
FrameRate() {
frameCount = lastFrameRate = tick = 0;
}
int Calculate() {
frameCount++;
if (clock() - tick >= CLOCKS_PER_SEC) {
lastFrameRate = frameCount;
frameCount = 0;
tick = clock();
}
return lastFrameRate;
}
int GetFrameRate() {
return lastFrameRate;
}
private:
int frameCount;
int lastFrameRate;
int tick;
};
#endif