Centralize Win32 app runtime binding setup

This commit is contained in:
2026-06-17 12:19:24 +02:00
parent a267386188
commit aec78fb838
5 changed files with 27 additions and 12 deletions

View File

@@ -17,13 +17,9 @@ int run_main_application(int argc, char** argv)
{
const auto instance = GetModuleHandle(NULL);
auto& owned_app = retained_owned_app();
owned_app = std::make_unique<App>();
auto* app = owned_app.get();
bind_app(app);
bind_runtime(&app->runtime());
app->set_platform_services(&pp::platform::windows::platform_services());
app->initLog();
auto& app = initialize_bound_app_runtime();
app.set_platform_services(&pp::platform::windows::platform_services());
app.initLog();
pp::platform::windows::init_shcore_API();
pp::platform::windows::initialize_stylus_input();
@@ -37,13 +33,13 @@ int run_main_application(int argc, char** argv)
pp::platform::windows::initialize_retained_input_state();
pp::platform::windows::setup_exception_handler(*app);
pp::platform::windows::setup_exception_handler(app);
pp::platform::windows::read_WMI_info();
app->create();
app.create();
auto startup = pp::platform::windows::initialize_main_window_startup_state(*app);
auto startup = pp::platform::windows::initialize_main_window_startup_state(app);
auto context = pp::platform::windows::OpenGlWindowContext {};
switch (pp::platform::windows::initialize_main_window_and_gl(
startup,
@@ -70,8 +66,8 @@ int run_main_application(int argc, char** argv)
switch (const_hash(argv[1]))
{
case const_hash("convert"):
app->initShaders();
app->cmd_convert(argv[2], argv[3]);
app.initShaders();
app.cmd_convert(argv[2], argv[3]);
release_bound_app();
return 0;
case const_hash("-vrmode"):

View File

@@ -24,6 +24,16 @@ struct RetainedWindowsRuntimeState final {
}
App& initialize_bound_app_runtime()
{
auto& owned_app = retained_owned_app();
owned_app = std::make_unique<App>();
auto& app = *owned_app;
bind_app(&app);
bind_runtime(&app.runtime());
return app;
}
void bind_app(App* app) noexcept
{
auto& state = retained_runtime_state();

View File

@@ -8,6 +8,7 @@ class WacomTablet;
namespace pp::platform::windows {
[[nodiscard]] App& initialize_bound_app_runtime();
void bind_app(App* app) noexcept;
[[nodiscard]] App* bound_app() noexcept;
void release_bound_app() noexcept;