- Fixed DeltaTimer
This commit is contained in:
Light 2021-07-09 11:56:06 +04:30
parent 45c5073deb
commit 422241479c
2 changed files with 6 additions and 7 deletions

View file

@ -5,9 +5,9 @@ namespace Light {
void DeltaTimer::Update() void DeltaTimer::Update()
{ {
auto current = std::chrono::steady_clock::now(); float currentFrame = timer.GetElapsedTime();
m_DeltaTime = ((std::chrono::duration_cast<std::chrono::milliseconds>(current - m_Previous)).count()) / 1000.0f; m_DeltaTime = currentFrame - m_PreviousFrame;
m_Previous = current; m_PreviousFrame = currentFrame;
} }
} }

View file

@ -22,13 +22,12 @@ namespace Light {
class DeltaTimer class DeltaTimer
{ {
private: private:
std::chrono::time_point<std::chrono::steady_clock> m_Previous; Timer timer;
float m_PreviousFrame = 0.0f;
float m_DeltaTime = 60.0f / 1000.0f; float m_DeltaTime = 60.0f / 1000.0f;
public: public:
DeltaTimer(): m_Previous(std::chrono::steady_clock::now()) { }
void Update(); void Update();
inline float GetDeltaTime() const { return m_DeltaTime; } inline float GetDeltaTime() const { return m_DeltaTime; }