------------------------------------------------------------------------------
| 350 | |
| 351 | //------------------------------------------------------------------------------ |
| 352 | void vtkOpenVRRenderWindow::Initialize() |
| 353 | { |
| 354 | if (this->VRInitialized) |
| 355 | { |
| 356 | return; |
| 357 | } |
| 358 | |
| 359 | if (!this->HelperWindow) |
| 360 | { |
| 361 | vtkErrorMacro(<< "HelperWindow is not set"); |
| 362 | return; |
| 363 | } |
| 364 | |
| 365 | // Loading the SteamVR Runtime |
| 366 | vr::EVRInitError eError = vr::VRInitError_None; |
| 367 | this->HMD = vr::VR_Init(&eError, vr::VRApplication_Scene); |
| 368 | |
| 369 | if (eError != vr::VRInitError_None) |
| 370 | { |
| 371 | this->HMD = nullptr; |
| 372 | char buf[1024]; |
| 373 | auto result = vtk::format_to_n(buf, sizeof(buf), "Unable to init VR runtime: {:s}", |
| 374 | vr::VR_GetVRInitErrorAsEnglishDescription(eError)); |
| 375 | *result.out = '\0'; |
| 376 | vtkErrorMacro(<< "VR_Init Failed" << buf); |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | this->OpenVRRenderModels = |
| 381 | (vr::IVRRenderModels*)vr::VR_GetGenericInterface(vr::IVRRenderModels_Version, &eError); |
| 382 | if (!this->OpenVRRenderModels) |
| 383 | { |
| 384 | this->HMD = nullptr; |
| 385 | vr::VR_Shutdown(); |
| 386 | |
| 387 | char buf[1024]; |
| 388 | auto result = vtk::format_to_n(buf, sizeof(buf), "Unable to get render model interface: {:s}", |
| 389 | vr::VR_GetVRInitErrorAsEnglishDescription(eError)); |
| 390 | *result.out = '\0'; |
| 391 | vtkErrorMacro(<< "VR_Init Failed" << buf); |
| 392 | return; |
| 393 | } |
| 394 | |
| 395 | this->GetSizeFromAPI(); |
| 396 | |
| 397 | this->HelperWindow->SetDisplayId(this->GetGenericDisplayId()); |
| 398 | this->HelperWindow->SetShowWindow(false); |
| 399 | this->HelperWindow->Initialize(); |
| 400 | |
| 401 | this->MakeCurrent(); |
| 402 | |
| 403 | this->OpenGLInit(); |
| 404 | |
| 405 | this->MaximumHardwareLineWidth = this->HelperWindow->GetMaximumHardwareLineWidth(); |
| 406 | |
| 407 | glDepthRange(0., 1.); |
| 408 | |
| 409 | this->SetWindowName(this->GetWindowTitleFromAPI().c_str()); |