diff --git a/src/olympic/turbine/src/glfw/gfx.cpp b/src/olympic/turbine/src/glfw/gfx.cpp index 231c3ed4..89676307 100644 --- a/src/olympic/turbine/src/glfw/gfx.cpp +++ b/src/olympic/turbine/src/glfw/gfx.cpp @@ -78,17 +78,17 @@ static void handleGlfwCursorPosEvent(GLFWwindow*, double, double) noexcept { } static void handleGlfwMouseButtonEvent(GLFWwindow *window, int, int, int) noexcept { - auto const ctx = static_cast(glfwGetWindowUserPointer(window)); - ctx->mandatoryRefreshPeriodEnd = config::MandatoryRefreshPeriod; + auto &ctx = *static_cast(glfwGetWindowUserPointer(window)); + ctx.mandatoryRefreshPeriodEnd = ticksMs(ctx) + config::MandatoryRefreshPeriod; } static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) noexcept { - auto const ctx = static_cast(glfwGetWindowUserPointer(window)); - ctx->mandatoryRefreshPeriodEnd = config::MandatoryRefreshPeriod; + auto &ctx = *static_cast(glfwGetWindowUserPointer(window)); + ctx.mandatoryRefreshPeriodEnd = ticksMs(ctx) + config::MandatoryRefreshPeriod; if (action == GLFW_PRESS) { - handleKeyPress(*ctx, key, true); + handleKeyPress(ctx, key, true); } else if (action == GLFW_RELEASE) { - handleKeyPress(*ctx, key, false); + handleKeyPress(ctx, key, false); } } diff --git a/src/olympic/turbine/src/glfw/turbine.cpp b/src/olympic/turbine/src/glfw/turbine.cpp index 4e4b540b..4ff6f089 100644 --- a/src/olympic/turbine/src/glfw/turbine.cpp +++ b/src/olympic/turbine/src/glfw/turbine.cpp @@ -88,7 +88,7 @@ ox::Error run(Context &ctx) noexcept { tickFps(ctx, ticks); draw(ctx); auto const realSleepTime = ox::min(static_cast(ctx.refreshWithinMs), sleepTime); - if (realSleepTime && ctx.mandatoryRefreshPeriodEnd >= ticks) { + if (realSleepTime && ctx.mandatoryRefreshPeriodEnd <= ticks) { glfwWaitEventsTimeout(static_cast(realSleepTime) / 1000); } }