MCPcopy Create free account
hub / github.com/Kitware/VTK / Initialize

Method Initialize

Rendering/OpenVR/vtkOpenVRRenderWindow.cxx:352–422  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

350
351//------------------------------------------------------------------------------
352void 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());

Callers 5

TestOpenVRInteractiveBoxFunction · 0.45
TestOpenVRRenderingFunction · 0.45
TestOpenVRInitializationFunction · 0.45

Calls 13

GetSizeFromAPIMethod · 0.95
GetWindowTitleFromAPIMethod · 0.95
CreateFramebuffersMethod · 0.95
format_to_nFunction · 0.50
SetDisplayIdMethod · 0.45
GetGenericDisplayIdMethod · 0.45
SetShowWindowMethod · 0.45
MakeCurrentMethod · 0.45
OpenGLInitMethod · 0.45
SetWindowNameMethod · 0.45
c_strMethod · 0.45

Tested by 5

TestOpenVRInteractiveBoxFunction · 0.36
TestOpenVRRenderingFunction · 0.36
TestOpenVRInitializationFunction · 0.36