Split Linux platform target and move runtime/platform state
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -32,6 +32,7 @@ struct RetainedLegacyGlfwWindowState final {
|
||||
|
||||
[[nodiscard]] RetainedLegacyGlfwWindowState& active_legacy_glfw_window_state();
|
||||
[[nodiscard]] RetainedLegacyGlfwWindowHooks& active_legacy_glfw_window_hooks();
|
||||
void set_legacy_glfw_window(GLFWwindow* window);
|
||||
#endif
|
||||
|
||||
#if defined(__IOS__) || defined(__OSX__)
|
||||
@@ -46,6 +47,15 @@ struct RetainedLegacyAppleState final {
|
||||
};
|
||||
|
||||
[[nodiscard]] RetainedLegacyAppleState& active_legacy_apple_state();
|
||||
void set_legacy_apple_state(
|
||||
#ifdef __IOS__
|
||||
GameViewController* ios_view,
|
||||
AppDelegate* ios_app
|
||||
#elif defined(__OSX__)
|
||||
View* osx_view,
|
||||
AppOSX* osx_app
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
|
||||
[[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_storage_paths();
|
||||
|
||||
Reference in New Issue
Block a user