[olympic/turbine] East const Turbine, cleanup
This commit is contained in:
parent
58d13a3ad9
commit
72e54da017
@ -37,7 +37,7 @@ ox::String getClipboardText(Context &ctx) noexcept;
|
|||||||
|
|
||||||
void setClipboardText(Context &ctx, ox::CRStringView text) noexcept;
|
void setClipboardText(Context &ctx, ox::CRStringView text) noexcept;
|
||||||
|
|
||||||
void setClipboardObject(Context &ctx, ox::UniquePtr<BaseClipboardObject> &&obj) noexcept;
|
void setClipboardObject(Context &ctx, ox::UPtr<BaseClipboardObject> &&obj) noexcept;
|
||||||
|
|
||||||
ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView typeName, int typeVersion) noexcept;
|
ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView typeName, int typeVersion) noexcept;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ void setClipboardText(Context &ctx, ox::CRStringView text) noexcept {
|
|||||||
glfwSetClipboardString(ctx.window, cstr.get());
|
glfwSetClipboardString(ctx.window, cstr.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setClipboardObject(Context &ctx, ox::UniquePtr<BaseClipboardObject> &&obj) noexcept {
|
void setClipboardObject(Context &ctx, ox::UPtr<BaseClipboardObject> &&obj) noexcept {
|
||||||
ctx.clipboard = std::move(obj);
|
ctx.clipboard = std::move(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ void removeDrawer(Context &ctx, Drawer *cd) noexcept {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleGlfwError(int err, const char *desc) noexcept {
|
static void handleGlfwError(int err, char const*desc) noexcept {
|
||||||
oxErrf("GLFW error ({}): {}\n", err, desc);
|
oxErrf("GLFW error ({}): {}\n", err, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +57,8 @@ static void handleKeyPress(Context &ctx, int key, bool down) noexcept {
|
|||||||
map[GLFW_KEY_ESCAPE] = Key::Escape;
|
map[GLFW_KEY_ESCAPE] = Key::Escape;
|
||||||
return map;
|
return map;
|
||||||
}();
|
}();
|
||||||
const auto eventHandler = keyEventHandler(ctx);
|
auto const eventHandler = keyEventHandler(ctx);
|
||||||
const auto k = keyMap[static_cast<std::size_t>(key)];
|
auto const k = keyMap[static_cast<std::size_t>(key)];
|
||||||
setKeyDownStatus(ctx, k, down);
|
setKeyDownStatus(ctx, k, down);
|
||||||
if (eventHandler) {
|
if (eventHandler) {
|
||||||
eventHandler(ctx, k, down);
|
eventHandler(ctx, k, down);
|
||||||
@ -69,12 +69,12 @@ static void handleGlfwCursorPosEvent(GLFWwindow*, double, double) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handleGlfwMouseButtonEvent(GLFWwindow *window, int, int, int) noexcept {
|
static void handleGlfwMouseButtonEvent(GLFWwindow *window, int, int, int) noexcept {
|
||||||
const auto ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
|
auto const ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||||
ctx->uninterruptedRefreshes = 25;
|
ctx->uninterruptedRefreshes = 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) noexcept {
|
static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) noexcept {
|
||||||
const auto ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
|
auto const ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||||
ctx->uninterruptedRefreshes = 25;
|
ctx->uninterruptedRefreshes = 25;
|
||||||
if (action == GLFW_PRESS) {
|
if (action == GLFW_PRESS) {
|
||||||
handleKeyPress(*ctx, key, true);
|
handleKeyPress(*ctx, key, true);
|
||||||
|
@ -55,8 +55,8 @@ ox::Result<ContextUPtr> init(
|
|||||||
static void tickFps(Context &ctx, uint64_t nowMs) noexcept {
|
static void tickFps(Context &ctx, uint64_t nowMs) noexcept {
|
||||||
++ctx.draws;
|
++ctx.draws;
|
||||||
if (ctx.draws >= 500) {
|
if (ctx.draws >= 500) {
|
||||||
const auto duration = static_cast<double>(nowMs - ctx.prevFpsCheckTime) / 1000.0;
|
auto const duration = static_cast<double>(nowMs - ctx.prevFpsCheckTime) / 1000.0;
|
||||||
const auto fps = static_cast<int>(static_cast<double>(ctx.draws) / duration);
|
auto const fps = static_cast<int>(static_cast<double>(ctx.draws) / duration);
|
||||||
if constexpr(config::GlFpsPrint) {
|
if constexpr(config::GlFpsPrint) {
|
||||||
oxOutf("FPS: {}\n", fps);
|
oxOutf("FPS: {}\n", fps);
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ ox::Error run(Context &ctx) noexcept {
|
|||||||
int sleepTime = 0;
|
int sleepTime = 0;
|
||||||
while (!glfwWindowShouldClose(ctx.window)) {
|
while (!glfwWindowShouldClose(ctx.window)) {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
const auto ticks = ticksMs(ctx);
|
auto const ticks = ticksMs(ctx);
|
||||||
if (ctx.wakeupTime <= ticks) {
|
if (ctx.wakeupTime <= ticks) {
|
||||||
sleepTime = ctx.updateHandler(ctx);
|
sleepTime = ctx.updateHandler(ctx);
|
||||||
if (sleepTime >= 0) {
|
if (sleepTime >= 0) {
|
||||||
@ -108,7 +108,7 @@ void shutdown(Context &ctx) noexcept {
|
|||||||
|
|
||||||
uint64_t ticksMs(Context const&ctx) noexcept {
|
uint64_t ticksMs(Context const&ctx) noexcept {
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
const auto now = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
|
auto const now = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
|
||||||
return static_cast<uint64_t>(now - ctx.startTime);
|
return static_cast<uint64_t>(now - ctx.startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user