| 69 | /////////////////////////////////////////// |
| 70 | |
| 71 | bool 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 |
nothing calls this directly
no test coverage detected