[turbine] Add TimeMs alias to uint64_t
This commit is contained in:
parent
e8f5c91172
commit
0d7b89a025
@ -14,6 +14,8 @@
|
||||
|
||||
namespace turbine {
|
||||
|
||||
using TimeMs = uint64_t;
|
||||
|
||||
ox::Result<ContextUPtr> init(ox::UPtr<ox::FileSystem> &&fs, ox::CRStringView appName) noexcept;
|
||||
|
||||
ox::Error run(Context &ctx) noexcept;
|
||||
@ -21,7 +23,7 @@ ox::Error run(Context &ctx) noexcept;
|
||||
// Returns the number of milliseconds that have passed since the start of the
|
||||
// program.
|
||||
[[nodiscard]]
|
||||
uint64_t ticksMs(Context const&ctx) noexcept;
|
||||
TimeMs ticksMs(Context const&ctx) noexcept;
|
||||
|
||||
void requestShutdown(Context &ctx) noexcept;
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <keel/keel.hpp>
|
||||
#include <turbine/context.hpp>
|
||||
#include <turbine/gfx.hpp>
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
#include "turbine.hpp"
|
||||
@ -71,7 +72,7 @@ ox::Result<ContextUPtr> init(
|
||||
void shutdown(Context&) noexcept {
|
||||
}
|
||||
|
||||
uint64_t ticksMs(Context const&) noexcept {
|
||||
TimeMs ticksMs(Context const&) noexcept {
|
||||
return g_timerMs;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <turbine/context.hpp>
|
||||
#include <turbine/gfx.hpp>
|
||||
#include <turbine/event.hpp>
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
namespace turbine {
|
||||
|
||||
@ -24,7 +25,7 @@ class Context {
|
||||
struct GLFWwindow *window = nullptr;
|
||||
int refreshWithinMs = 0;
|
||||
ox::Vector<gl::Drawer*, 5> drawers;
|
||||
int64_t startTime = 0;
|
||||
TimeMs startTime = 0;
|
||||
uint64_t wakeupTime = 0;
|
||||
uint64_t keysDown = 0;
|
||||
uint64_t prevFpsCheckTime = 0;
|
||||
|
@ -45,7 +45,8 @@ ox::Result<ContextUPtr> init(
|
||||
auto ctx = ox::make_unique<Context>();
|
||||
oxReturnError(keel::init(ctx->keelCtx, std::move(fs), appName));
|
||||
using namespace std::chrono;
|
||||
ctx->startTime = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
|
||||
ctx->startTime = static_cast<TimeMs>(
|
||||
duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count());
|
||||
glfwInit();
|
||||
oxReturnError(initGfx(*ctx));
|
||||
glfwSetWindowSizeCallback(ctx->window, draw);
|
||||
@ -108,10 +109,10 @@ void shutdown(Context &ctx) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t ticksMs(Context const&ctx) noexcept {
|
||||
TimeMs ticksMs(Context const&ctx) noexcept {
|
||||
using namespace std::chrono;
|
||||
auto const now = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
|
||||
return static_cast<uint64_t>(now - ctx.startTime);
|
||||
return static_cast<TimeMs>(now) - ctx.startTime;
|
||||
}
|
||||
|
||||
bool buttonDown(Context const&ctx, Key key) noexcept {
|
||||
|
Loading…
Reference in New Issue
Block a user