2023-02-23 18:00:06 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
struct Throttle
|
|
|
|
{
|
|
|
|
void set_frame_rate(double frame_rate);
|
|
|
|
void advance();
|
|
|
|
void reset();
|
|
|
|
void wait_for_frame();
|
2023-02-23 22:24:01 +01:00
|
|
|
void wait_for_frame_and_rebase_time();
|
2023-02-23 18:00:06 +01:00
|
|
|
std::chrono::microseconds remaining();
|
|
|
|
double max_frame_rate = 0.0;
|
|
|
|
double frame_duration = 0.0;
|
|
|
|
std::chrono::microseconds frame_duration_us;
|
|
|
|
std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds> then;
|
|
|
|
};
|