#include <thread>

#include "Platform.hpp"

void Platform::frame(std::function<void(FloatSeconds const &)> func)
{
	auto t_start = std::chrono::steady_clock::now();
	auto t_target = (t_start + FRAME_TIME_TARGET);

	func(frame_time_prev);

	auto t_end = std::chrono::steady_clock::now();
	if(t_end < t_target) {
		std::this_thread::sleep_until(t_target);
		frame_time_prev = (t_target - t_start);
	} else {
		frame_time_prev = (t_end - t_start);
	}
}

void Platform::set_title([[maybe_unused]] std::string const &title)
{
}

void Platform::exit()
{
}