When writing the X11 (linux) implementation there was a problem with X11 defining a "Display" type and we also have a Display class in the engine. So to fix that problem and minimize the risk for running into other name conflicts. We move everything from global namespace.
47 lines
No EOL
754 B
C++
47 lines
No EOL
754 B
C++
|
|
#ifndef SPECTRE_FPS_COUNTER_H
|
|
#define SPECTRE_FPS_COUNTER_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();
|
|
|
|
float getFPS() const;
|
|
|
|
// Set the update rate (in seconds).
|
|
// How often the FPS should be sampled and calculated.
|
|
void setUpdateRate(unsigned int seconds);
|
|
|
|
// Update the internal time measurment.
|
|
bool update();
|
|
|
|
// Reset the frame time
|
|
void reset();
|
|
|
|
private :
|
|
|
|
// Frame counter.
|
|
unsigned int m_count;
|
|
|
|
// time (in ms)
|
|
unsigned int m_time;
|
|
|
|
// Update rate (in ms)
|
|
unsigned int m_updateRate;
|
|
|
|
// Calculated fps.
|
|
float m_fps;
|
|
};
|
|
|
|
} // namespace sp
|
|
|
|
#endif /* SPECTRE_FPS_COUNTER_H */ |