| 266 | #endif |
| 267 | |
| 268 | void OS_Windows::initialize() { |
| 269 | crash_handler.initialize(); |
| 270 | |
| 271 | #ifdef WINDOWS_DEBUG_OUTPUT_ENABLED |
| 272 | error_handlers.errfunc = _error_handler; |
| 273 | error_handlers.userdata = this; |
| 274 | add_error_handler(&error_handlers); |
| 275 | #endif |
| 276 | |
| 277 | #ifdef THREADS_ENABLED |
| 278 | init_thread_win(); |
| 279 | #endif |
| 280 | |
| 281 | FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES); |
| 282 | FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_USERDATA); |
| 283 | FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_FILESYSTEM); |
| 284 | FileAccess::make_default<FileAccessWindowsPipe>(FileAccess::ACCESS_PIPE); |
| 285 | DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_RESOURCES); |
| 286 | DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_USERDATA); |
| 287 | DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_FILESYSTEM); |
| 288 | |
| 289 | NetSocketWinSock::make_default(); |
| 290 | |
| 291 | // We need to know how often the clock is updated |
| 292 | QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second); |
| 293 | QueryPerformanceCounter((LARGE_INTEGER *)&ticks_start); |
| 294 | |
| 295 | #if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP |
| 296 | // set minimum resolution for periodic timers, otherwise Sleep(n) may wait at least as |
| 297 | // long as the windows scheduler resolution (~16-30ms) even for calls like Sleep(1) |
| 298 | TIMECAPS time_caps; |
| 299 | if (timeGetDevCaps(&time_caps, sizeof(time_caps)) == MMSYSERR_NOERROR) { |
| 300 | delay_resolution = time_caps.wPeriodMin * 1000; |
| 301 | timeBeginPeriod(time_caps.wPeriodMin); |
| 302 | } else { |
| 303 | ERR_PRINT("Unable to detect sleep timer resolution."); |
| 304 | delay_resolution = 1000; |
| 305 | timeBeginPeriod(1); |
| 306 | } |
| 307 | #else |
| 308 | delay_resolution = 1000; |
| 309 | #endif |
| 310 | |
| 311 | process_map = memnew((HashMap<ProcessID, ProcessInfo>)); |
| 312 | |
| 313 | // Add current Godot PID to the list of known PIDs |
| 314 | ProcessInfo current_pi = {}; |
| 315 | PROCESS_INFORMATION current_pi_pi = {}; |
| 316 | current_pi.pi = current_pi_pi; |
| 317 | current_pi.pi.hProcess = GetCurrentProcess(); |
| 318 | process_map->insert(GetCurrentProcessId(), current_pi); |
| 319 | |
| 320 | IPWindows::make_default(); |
| 321 | main_loop = nullptr; |
| 322 | |
| 323 | HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&dwrite_factory)); |
| 324 | if (SUCCEEDED(hr)) { |
| 325 | hr = dwrite_factory->GetSystemFontCollection(&font_collection, false); |
no test coverage detected