Introduce new timer based on vsync
This commit is contained in:
25
include/PSX/Timer/frame_time_helper.hpp
Normal file
25
include/PSX/Timer/frame_time_helper.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef __JABYENGINE_FRAME_TIME_HELPER_HPP__
|
||||
#define __JABYENGINE_FRAME_TIME_HELPER_HPP__
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <limits.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
static constexpr double ms_per_frame = 1000.0/static_cast<double>(GPU::Display::frames_per_sec);
|
||||
|
||||
template<typename T>
|
||||
static constexpr T ms_to_vsync_ticks(T time_ms) {
|
||||
return static_cast<T>(static_cast<double>(time_ms)/ms_per_frame);
|
||||
}
|
||||
|
||||
static constexpr uint32_t operator ""_ms(unsigned long long time) {
|
||||
return static_cast<uint32_t>(ms_to_vsync_ticks(time));
|
||||
}
|
||||
|
||||
static constexpr size_t max_ms_time_u8 = UI8_MAX*ms_per_frame;
|
||||
static constexpr size_t max_ms_time_u16 = UI16_MAX*ms_per_frame;
|
||||
static constexpr size_t max_ms_time_u32 = UI32_MAX;
|
||||
|
||||
#undef literal_operator_template
|
||||
}
|
||||
using JabyEngine::operator""_ms;
|
||||
#endif //!__JABYENGINE_FRAME_TIME_HELPER_HPP__
|
Reference in New Issue
Block a user