#pragma once
#include "ofConstants.h"
#include "ofUtils.h"
#include <queue>
class ofFpsCounter {
public:
ofFpsCounter();
ofFpsCounter(double targetFps);
void newFrame();
void update();
double getFps() const;
uint64_t getNumFrames() const;
uint64_t getLastFrameNanos() const;
double getLastFrameSecs() const;
uint64_t getLastFrameFilteredNanos() const;
double getLastFrameFilteredSecs() const;
void setFilterAlpha(float alpha);
private:
void update(double now);
uint64_t nFrameCount;
ofTime then;
double fps;
std::chrono::nanoseconds lastFrameTime;
std::chrono::nanoseconds filteredTime;
double filterAlpha;
std::queue<double> timestamps;
};
Comments