From 2cb7046a56c7afd27ad1742232337b80568d4b9b Mon Sep 17 00:00:00 2001 From: omigamedev Date: Wed, 17 Jun 2026 10:11:21 +0200 Subject: [PATCH] Own legacy platform services on Web and Android --- android/src/cpp/main.cpp | 3 ++- docs/modernization/roadmap.md | 5 +++++ docs/modernization/tasks.md | 5 +++++ webgl/src/main.cpp | 5 ++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/android/src/cpp/main.cpp b/android/src/cpp/main.cpp index 4c827efd..0e33f1a0 100644 --- a/android/src/cpp/main.cpp +++ b/android/src/cpp/main.cpp @@ -1090,9 +1090,10 @@ void android_main(struct android_app* state) { // Make sure glue isn't stripped. // DON'T REMOVE, even if the compiler say it's deprecated app_dummy(); + auto platform_services = pp::platform::legacy::create_platform_services(); App::I = new App; - App::I->set_platform_services(&pp::platform::legacy::platform_services()); + App::I->set_platform_services(platform_services.get()); memset(&g_engine, 0, sizeof(g_engine)); state->userData = &g_engine; diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index e8a7807c..4465d373 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -70,6 +70,11 @@ What is already real: - `pp_app_core` Latest slice: +- `webgl/src/main.cpp` now owns a TU-local legacy `PlatformServices` + instance and binds that owned service into `App` during `StartApp()`. +- `android/src/cpp/main.cpp` now owns a function-lifetime legacy + `PlatformServices` instance in `android_main()` and binds that owned service + into `App` instead of binding the process-global fallback directly. - `src/platform_legacy/legacy_platform_services.*` now exposes an ownable `create_platform_services()` entrypoint alongside the legacy fallback accessor. diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index a2e097c8..bd54fcdb 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -78,6 +78,11 @@ Completed, blocked, and superseded task history moved to the queue is now ordered by code movement instead. Current slice: +- `webgl/src/main.cpp` now binds an owned legacy `PlatformServices` instance + instead of reading the process-global fallback directly during `StartApp()`. +- `android/src/cpp/main.cpp` now binds a function-lifetime owned legacy + `PlatformServices` instance in `android_main()`, replacing the direct bind to + the process-global fallback accessor. - `src/platform_legacy/legacy_platform_services.*` now exposes an ownable `create_platform_services()` entrypoint while keeping the fallback singleton for non-migrated platforms. diff --git a/webgl/src/main.cpp b/webgl/src/main.cpp index d51d1de8..d9712b15 100644 --- a/webgl/src/main.cpp +++ b/webgl/src/main.cpp @@ -16,6 +16,7 @@ App app; GLFWwindow* wnd; float theta = 0; glm::vec2 g_cursor_pos; +std::unique_ptr g_platform_services; template class TaskCallback @@ -120,7 +121,7 @@ void StartApp() { App::I = &app; pp::platform::legacy::set_legacy_glfw_window(wnd); - app.set_platform_services(&pp::platform::legacy::platform_services()); + app.set_platform_services(g_platform_services.get()); app.initLog(); app.create(); app.width = 1024; @@ -197,6 +198,8 @@ void main_loop() int main() { + g_platform_services = pp::platform::legacy::create_platform_services(); + if (glfwInit() != GL_TRUE) printf("Failed to init GLFW"); wnd = glfwCreateWindow(1024, 768, "PanoPainter", nullptr, nullptr);