mirror of
https://github.com/Kbz-8/42_vox.git
synced 2026-03-04 04:56:37 +00:00
adding fps display
This commit is contained in:
22
Application/FpsCounter.cpp
git.filemode.normal_file
22
Application/FpsCounter.cpp
git.filemode.normal_file
@@ -0,0 +1,22 @@
|
||||
#include <FpsCounter.h>
|
||||
#include <chrono>
|
||||
|
||||
FpsCounter::FpsCounter()
|
||||
{
|
||||
m_past = std::chrono::high_resolution_clock::now();
|
||||
m_now = m_past;
|
||||
}
|
||||
|
||||
void FpsCounter::Update()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
m_now = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if(std::chrono::duration_cast<std::chrono::seconds>(m_now - m_past) >= 1s)
|
||||
{
|
||||
m_past = m_now;
|
||||
m_current_fps = m_counter;
|
||||
m_counter = 0;
|
||||
}
|
||||
m_counter++;
|
||||
}
|
||||
Reference in New Issue
Block a user