1
0
Fork 0
spectre/include/Spectre/Game/FPSCounter.h
Henrik Hautakoski 50e9300667 Game/FPSCounter: change m_fps variable and getFPS() return value from float to double.
MSVC complains about loss of information because sp::Time::seconds() returns double.
2022-09-26 12:06:40 +02:00

50 lines
882 B
C++

#ifndef SPECTRE_FPS_COUNTER_H
#define SPECTRE_FPS_COUNTER_H
#include <Spectre/System/Stopwatch.h>
// Simple FPS counter.
namespace sp {
class FPSCounter
{
public :
FPSCounter();
// Add a frame to the counter.
// Should be called whenever a frame has been rendered.
void addFrame();
double getFPS() const;
// Set the update rate (in seconds).
// How often the FPS should be sampled and calculated.
void setUpdateRate(unsigned int rate);
// Update the internal time measurment.
bool update();
// Reset the frame time
void reset();
private :
// Number of frames since last update.
unsigned int m_count;
// Last time we updated the counter.
//Time m_time;
Stopwatch m_watch;
// Update rate (at what interval should we update)
Time m_updateRate;
// Calculated Frames per second.
double m_fps;
};
} // namespace sp
#endif /* SPECTRE_FPS_COUNTER_H */