Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef TIME_KEEPER_H_
- #define TIME_KEEPER_H_
- class GlfwApiInterface;
- class TimeKeeper {
- public:
- explicit TimeKeeper(GlfwApiInterface *glfw_api);
- virtual ~TimeKeeper();
- void calculate();
- void reset();
- double getDelta() const;
- protected:
- GlfwApiInterface *glfw_api_;
- double frame_time_;
- double delta_;
- };
- #endif
- ///////////////////
- #include "time_keeper.h"
- #include "api/glfw_api_interface.h"
- TimeKeeper::TimeKeeper(GlfwApiInterface* glfw_api)
- : glfw_api_(glfw_api), frame_time_(0), delta_(0) {
- }
- TimeKeeper::~TimeKeeper() {
- }
- void TimeKeeper::calculate() {
- double time = glfw_api_->glfwGetTime();
- delta_ = time - frame_time_;
- frame_time_ = time;
- }
- void TimeKeeper::reset() {
- delta_ = 0;
- frame_time_ = glfw_api_->glfwGetTime();
- }
- double TimeKeeper::getDelta() const {
- return delta_;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement