MCPcopy Create free account
hub / github.com/StereoKit/StereoKit / platform_init

Function platform_init

StereoKitC/platforms/platform.cpp:71–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69///////////////////////////////////////////
70
71bool platform_init() {
72 device_data_init(&device_data);
73
74 local = sk_malloc_zero_t(platform_state_t, 1);
75 const sk_settings_t* settings = sk_get_settings_ref();
76
77 // Set up any platform dependent variables
78 if (!platform_impl_init()) {
79 log_fail_reason(80, log_error, "Platform initialization failed!");
80 return false;
81 }
82
83 // Initialize graphics
84 void* luid = nullptr;
85#if defined(SK_XR_OPENXR)
86 if (settings->mode == app_mode_xr)
87 luid = openxr_get_luid();
88#endif
89 skg_callback_log([](skg_log_ level, const char *text) {
90 switch (level) {
91 case skg_log_info: log_diagf("[<~mag>sk_gpu<~clr>] %s", text); break;
92 case skg_log_warning: log_warnf("[<~mag>sk_gpu<~clr>] %s", text); break;
93 case skg_log_critical: log_errf ("[<~mag>sk_gpu<~clr>] %s", text); break;
94 }
95 });
96 if (skg_init(settings->app_name, luid) <= 0) {
97 log_fail_reason(95, log_error, "Failed to initialize sk_gpu!");
98 return false;
99 }
100 device_data.gpu = string_copy(skg_adapter_name());
101
102 // Start up the current mode!
103 bool result = platform_set_mode(settings->mode);
104 if (result == false && settings->no_flatscreen_fallback == false && settings->mode != app_mode_simulator) {
105 log_clear_any_fail_reason();
106 log_infof("Couldn't create an XR app, falling back to Simulator");
107 result = platform_set_mode(app_mode_simulator);
108 }
109 if (result == false)
110 log_errf("Couldn't initialize a <~grn>%s<~clr> mode app!", app_mode_str(settings->mode));
111 return result;
112}
113
114///////////////////////////////////////////
115

Callers

nothing calls this directly

Calls 15

device_data_initFunction · 0.85
sk_get_settings_refFunction · 0.85
log_fail_reasonFunction · 0.85
openxr_get_luidFunction · 0.85
skg_callback_logFunction · 0.85
log_diagfFunction · 0.85
log_warnfFunction · 0.85
log_errfFunction · 0.85
skg_initFunction · 0.85
string_copyFunction · 0.85
skg_adapter_nameFunction · 0.85
platform_set_modeFunction · 0.85

Tested by

no test coverage detected