Retain Apple bridge services and bind Win32 runtime
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "platform_windows/windows_runtime_shell.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "app_runtime.h"
|
||||
#include "log.h"
|
||||
#include "platform_windows/windows_bootstrap_helpers.h"
|
||||
#include "platform_windows/windows_lifecycle_shell.h"
|
||||
@@ -16,6 +17,16 @@ namespace pp::platform::windows {
|
||||
|
||||
namespace {
|
||||
|
||||
struct RetainedWindowsRuntimeState final {
|
||||
AppRuntime* runtime = nullptr;
|
||||
};
|
||||
|
||||
[[nodiscard]] RetainedWindowsRuntimeState& retained_runtime_state()
|
||||
{
|
||||
static RetainedWindowsRuntimeState state;
|
||||
return state;
|
||||
}
|
||||
|
||||
void register_touch_window(HWND hWnd)
|
||||
{
|
||||
// link: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registertouchwindow
|
||||
@@ -102,12 +113,23 @@ void shutdown_main_window_runtime(const MainWindowStartupState& startup, HINSTAN
|
||||
|
||||
}
|
||||
|
||||
void bind_runtime(AppRuntime* runtime) noexcept
|
||||
{
|
||||
retained_runtime_state().runtime = runtime;
|
||||
}
|
||||
|
||||
AppRuntime* bound_runtime() noexcept
|
||||
{
|
||||
return retained_runtime_state().runtime;
|
||||
}
|
||||
|
||||
int run_main_application(int argc, char** argv)
|
||||
{
|
||||
auto& state = retained_state();
|
||||
state.hInst = GetModuleHandle(NULL);
|
||||
|
||||
App::I = new App();
|
||||
bind_runtime(&App::I->runtime());
|
||||
App::I->set_platform_services(&pp::platform::windows::platform_services());
|
||||
App::I->initLog();
|
||||
|
||||
@@ -136,8 +158,10 @@ int run_main_application(int argc, char** argv)
|
||||
case pp::platform::windows::MainStartupResult::Ok:
|
||||
break;
|
||||
case pp::platform::windows::MainStartupResult::GladLoadFailure:
|
||||
bind_runtime(nullptr);
|
||||
return 0;
|
||||
case pp::platform::windows::MainStartupResult::MissingCoreContextSupport:
|
||||
bind_runtime(nullptr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -151,6 +175,7 @@ int run_main_application(int argc, char** argv)
|
||||
case const_hash("convert"):
|
||||
App::I->initShaders();
|
||||
App::I->cmd_convert(argv[2], argv[3]);
|
||||
bind_runtime(nullptr);
|
||||
return 0;
|
||||
case const_hash("-vrmode"):
|
||||
start_in_vr = true;
|
||||
|
||||
Reference in New Issue
Block a user