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