| 12345678910111213141516171819202122232425262728293031323334353637 |
- //
- // time.hpp
- // engine
- //
- // Created by Sam Jaffe on 9/3/16.
- //
- #pragma once
- #include <chrono>
- namespace env::clock {
- using clock_t = std::chrono::steady_clock;
- using timestamp = std::chrono::time_point<clock_t>;
- using duration = clock_t::duration;
- struct tick {
- tick(timestamp prev) : now(clock_t::now()), since(now - prev) {}
- timestamp now;
- duration since;
- };
- inline timestamp now() { return clock_t::now(); }
- template <typename T> T current_time() {
- return std::chrono::duration<T>(now().time_since_epoch()).count();
- }
- }
- namespace env {
- struct fps {
- static clock::duration const v24;
- static clock::duration const v30;
- static clock::duration const v60;
- static clock::duration const v120;
- static clock::duration const v144;
- };
- }
|