Compare commits
4 Commits
e0ec9e0c5f
...
ff05d860c4
Author | SHA1 | Date | |
---|---|---|---|
ff05d860c4 | |||
7679403742 | |||
c51a45e1ba | |||
a6e24ff2b6 |
2
deps/ox/src/ox/std/types.hpp
vendored
2
deps/ox/src/ox/std/types.hpp
vendored
@ -61,6 +61,8 @@ using uint_t = unsigned;
|
||||
|
||||
namespace ox {
|
||||
|
||||
using CString = char const*;
|
||||
|
||||
/**
|
||||
* Aliases type T in size and alignment to allow allocating space for a T
|
||||
* without running the constructor.
|
||||
|
@ -45,7 +45,7 @@ ox::Error run(
|
||||
ox::StringView project,
|
||||
ox::StringView appName,
|
||||
ox::StringView projectDataDir,
|
||||
ox::SpanView<char const*> argv) noexcept;
|
||||
ox::SpanView<ox::CString> argv) noexcept;
|
||||
|
||||
namespace OLYMPIC_PROJECT_NAMESPACE {
|
||||
void registerKeelModules() noexcept;
|
||||
|
@ -101,6 +101,6 @@ ox::Error run(
|
||||
[[maybe_unused]] ox::StringView project,
|
||||
[[maybe_unused]] ox::StringView appName,
|
||||
ox::StringView projectDataDir,
|
||||
ox::SpanView<char const*> argv) noexcept {
|
||||
ox::SpanView<ox::CString> argv) noexcept {
|
||||
return ::run(argv, projectDataDir);
|
||||
}
|
||||
|
@ -71,6 +71,6 @@ ox::Error run(
|
||||
ox::StringView project,
|
||||
ox::StringView appName,
|
||||
ox::StringView projectDataDir,
|
||||
ox::SpanView<char const*> args) noexcept {
|
||||
ox::SpanView<ox::CString> args) noexcept {
|
||||
return studio::run(ox::sfmt("{} {}", project, appName), projectDataDir, args);
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ using TimeMs = uint64_t;
|
||||
|
||||
ox::Result<ContextUPtr> init(ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept;
|
||||
|
||||
ox::Result<ContextUPtr> init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept;
|
||||
|
||||
ox::Error run(Context &ctx) noexcept;
|
||||
|
||||
// Returns the number of milliseconds that have passed since the start of the
|
||||
|
@ -18,6 +18,11 @@ target_include_directories(
|
||||
../include
|
||||
)
|
||||
|
||||
target_sources(
|
||||
Turbine PUBLIC
|
||||
turbine.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
Turbine PUBLIC
|
||||
Keel
|
||||
|
@ -20,7 +20,7 @@ class Context {
|
||||
ox::AnyPtr applicationData;
|
||||
|
||||
// GLFW impl data ////////////////////////////////////////////////////////
|
||||
int uninterruptedRefreshes = 3;
|
||||
TimeMs mandatoryRefreshPeriodEnd{};
|
||||
ox::UPtr<BaseClipboardObject> clipboard;
|
||||
struct GLFWwindow *window = nullptr;
|
||||
int refreshWithinMs = 0;
|
||||
|
@ -72,14 +72,16 @@ static void handleKeyPress(Context &ctx, int key, bool down) noexcept {
|
||||
static void handleGlfwCursorPosEvent(GLFWwindow*, double, double) noexcept {
|
||||
}
|
||||
|
||||
static constexpr TimeMs MandatoryRefreshPeriod = 168;
|
||||
|
||||
static void handleGlfwMouseButtonEvent(GLFWwindow *window, int, int, int) noexcept {
|
||||
auto const ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||
ctx->uninterruptedRefreshes = 25;
|
||||
ctx->mandatoryRefreshPeriodEnd = MandatoryRefreshPeriod;
|
||||
}
|
||||
|
||||
static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) noexcept {
|
||||
auto const ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||
ctx->uninterruptedRefreshes = 25;
|
||||
ctx->mandatoryRefreshPeriodEnd = MandatoryRefreshPeriod;
|
||||
if (action == GLFW_PRESS) {
|
||||
handleKeyPress(*ctx, key, true);
|
||||
} else if (action == GLFW_RELEASE) {
|
||||
|
@ -88,14 +88,10 @@ ox::Error run(Context &ctx) noexcept {
|
||||
tickFps(ctx, ticks);
|
||||
draw(ctx);
|
||||
auto const realSleepTime = ox::min(static_cast<uint64_t>(ctx.refreshWithinMs), sleepTime);
|
||||
if (realSleepTime) {
|
||||
if (ctx.uninterruptedRefreshes) {
|
||||
--ctx.uninterruptedRefreshes;
|
||||
} else {
|
||||
if (realSleepTime && ctx.mandatoryRefreshPeriodEnd >= ticks) {
|
||||
glfwWaitEventsTimeout(static_cast<double>(realSleepTime) / 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
shutdown(ctx);
|
||||
return {};
|
||||
}
|
||||
|
13
src/olympic/turbine/src/turbine.cpp
Normal file
13
src/olympic/turbine/src/turbine.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
#include <keel/keel.hpp>
|
||||
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
namespace turbine {
|
||||
|
||||
ox::Result<ContextUPtr> init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept {
|
||||
oxRequireM(fs, keel::loadRomFs(fsPath));
|
||||
return init(std::move(fs), appName);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user