Document VR ownership and GLFW platform hooks

This commit is contained in:
2026-06-16 07:53:27 +02:00
parent 73c13f8cde
commit 34e2747867
5 changed files with 65 additions and 13 deletions

View File

@@ -94,6 +94,33 @@ public:
#endif
}
#if defined(__LINUX__) || defined(__WEB__)
struct RetainedLegacyGlfwWindowHooks final {
std::function<void()> acquire_render_context;
std::function<void()> present_render_context;
std::function<void()> request_app_close;
};
[[nodiscard]] RetainedLegacyGlfwWindowHooks& active_legacy_glfw_window_hooks()
{
static RetainedLegacyGlfwWindowHooks hooks = [] {
RetainedLegacyGlfwWindowHooks retained;
GLFWwindow* const window = App::I->glfw_window;
retained.acquire_render_context = [window] {
glfwMakeContextCurrent(window);
};
retained.present_render_context = [window] {
glfwSwapBuffers(window);
};
retained.request_app_close = [window] {
glfwSetWindowShouldClose(window, GLFW_TRUE);
};
return retained;
}();
return hooks;
}
#endif
#if defined(__IOS__) || defined(__OSX__)
[[nodiscard]] NSMutableArray<NSString*>* apple_file_types_array(const std::vector<std::string>& file_types)
{
@@ -412,7 +439,7 @@ public:
#elif __ANDROID__
android_async_lock();
#elif __LINUX__ || __WEB__
glfwMakeContextCurrent(App::I->glfw_window);
active_legacy_glfw_window_hooks().acquire_render_context();
#endif
}
@@ -432,7 +459,7 @@ public:
#elif __ANDROID__
android_async_swap();
#elif __LINUX__ || __WEB__
glfwSwapBuffers(App::I->glfw_window);
active_legacy_glfw_window_hooks().present_render_context();
#endif
}
@@ -743,7 +770,7 @@ public:
#ifdef __OSX__
active_apple_document_platform_services().request_app_close();
#elif __LINUX__
glfwSetWindowShouldClose(App::I->glfw_window, GLFW_TRUE);
active_legacy_glfw_window_hooks().request_app_close();
#endif
}