Split Apple platform target and move platform state ownership
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
|
||||
#include "app.h"
|
||||
|
||||
#if defined(__LINUX__) || defined(__WEB__)
|
||||
#include <GLFW/glfw3.h>
|
||||
#endif
|
||||
|
||||
namespace pp::platform::legacy {
|
||||
namespace {
|
||||
|
||||
@@ -12,6 +16,50 @@ 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;
|
||||
}();
|
||||
return state;
|
||||
}
|
||||
|
||||
[[nodiscard]] RetainedLegacyGlfwWindowHooks& active_legacy_glfw_window_hooks()
|
||||
{
|
||||
return active_legacy_glfw_window_state().hooks;
|
||||
}
|
||||
#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;
|
||||
}();
|
||||
return state;
|
||||
}
|
||||
#endif
|
||||
|
||||
[[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_storage_paths()
|
||||
{
|
||||
static RetainedLegacyStoragePaths state = [] {
|
||||
|
||||
Reference in New Issue
Block a user