Time
- Fixed DeltaTimer
This commit is contained in:
parent
45c5073deb
commit
422241479c
2 changed files with 6 additions and 7 deletions
|
@ -5,9 +5,9 @@ namespace Light {
|
|||
|
||||
void DeltaTimer::Update()
|
||||
{
|
||||
auto current = std::chrono::steady_clock::now();
|
||||
m_DeltaTime = ((std::chrono::duration_cast<std::chrono::milliseconds>(current - m_Previous)).count()) / 1000.0f;
|
||||
m_Previous = current;
|
||||
float currentFrame = timer.GetElapsedTime();
|
||||
m_DeltaTime = currentFrame - m_PreviousFrame;
|
||||
m_PreviousFrame = currentFrame;
|
||||
}
|
||||
|
||||
}
|
|
@ -22,13 +22,12 @@ namespace Light {
|
|||
class DeltaTimer
|
||||
{
|
||||
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;
|
||||
|
||||
|
||||
public:
|
||||
DeltaTimer(): m_Previous(std::chrono::steady_clock::now()) { }
|
||||
|
||||
void Update();
|
||||
|
||||
inline float GetDeltaTime() const { return m_DeltaTime; }
|
||||
|
|
Loading…
Add table
Reference in a new issue