Split Linux platform target and move runtime/platform state

This commit is contained in:
2026-06-17 01:20:11 +02:00
parent 90a55b86fe
commit 3ce365fc15
16 changed files with 169 additions and 94 deletions

View File

@@ -19,20 +19,7 @@ struct RetainedLegacyStoragePaths final {
#if defined(__LINUX__) || defined(__WEB__)
[[nodiscard]] RetainedLegacyGlfwWindowState& active_legacy_glfw_window_state()
{
static RetainedLegacyGlfwWindowState state = [] {
RetainedLegacyGlfwWindowState retained;
retained.window = App::I->glfw_window;
retained.hooks.acquire_render_context = [window = retained.window] {
glfwMakeContextCurrent(window);
};
retained.hooks.present_render_context = [window = retained.window] {
glfwSwapBuffers(window);
};
retained.hooks.request_app_close = [window = retained.window] {
glfwSetWindowShouldClose(window, GLFW_TRUE);
};
return retained;
}();
static RetainedLegacyGlfwWindowState state;
return state;
}
@@ -40,24 +27,53 @@ struct RetainedLegacyStoragePaths final {
{
return active_legacy_glfw_window_state().hooks;
}
void set_legacy_glfw_window(GLFWwindow* window)
{
auto& retained = active_legacy_glfw_window_state();
retained.window = window;
retained.hooks.acquire_render_context = [window] {
glfwMakeContextCurrent(window);
};
retained.hooks.present_render_context = [window] {
glfwSwapBuffers(window);
};
retained.hooks.request_app_close = [window] {
glfwSetWindowShouldClose(window, GLFW_TRUE);
};
}
#endif
#if defined(__IOS__) || defined(__OSX__)
[[nodiscard]] RetainedLegacyAppleState& active_legacy_apple_state()
{
static RetainedLegacyAppleState state = [] {
RetainedLegacyAppleState retained;
#ifdef __IOS__
retained.ios_view = App::I->ios_view;
retained.ios_app = App::I->ios_app;
#elif defined(__OSX__)
retained.osx_view = App::I->osx_view;
retained.osx_app = App::I->osx_app;
#endif
return retained;
}();
static RetainedLegacyAppleState state;
return state;
}
void set_legacy_apple_state(
#ifdef __IOS__
GameViewController* ios_view,
AppDelegate* ios_app
#elif defined(__OSX__)
View* osx_view,
AppOSX* osx_app
#endif
)
{
auto& retained = active_legacy_apple_state();
#ifdef __IOS__
if (ios_view)
retained.ios_view = ios_view;
if (ios_app)
retained.ios_app = ios_app;
#elif defined(__OSX__)
if (osx_view)
retained.osx_view = osx_view;
if (osx_app)
retained.osx_app = osx_app;
#endif
}
#endif
[[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_storage_paths()