----------------------------------------------------------------------------- Purpose: -----------------------------------------------------------------------------
| 586 | // Purpose: |
| 587 | //----------------------------------------------------------------------------- |
| 588 | bool CMainApplication::BInit() |
| 589 | { |
| 590 | if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER ) < 0 ) |
| 591 | { |
| 592 | dprintf("%s - SDL could not initialize! SDL Error: %s\n", __FUNCTION__, SDL_GetError()); |
| 593 | return false; |
| 594 | } |
| 595 | |
| 596 | // Loading the SteamVR Runtime |
| 597 | vr::EVRInitError eError = vr::VRInitError_None; |
| 598 | m_pHMD = vr::VR_Init( &eError, vr::VRApplication_Scene ); |
| 599 | |
| 600 | if ( eError != vr::VRInitError_None ) |
| 601 | { |
| 602 | m_pHMD = NULL; |
| 603 | char buf[1024]; |
| 604 | sprintf_s( buf, sizeof( buf ), "Unable to init VR runtime: %s", vr::VR_GetVRInitErrorAsEnglishDescription( eError ) ); |
| 605 | SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "VR_Init Failed", buf, NULL ); |
| 606 | return false; |
| 607 | } |
| 608 | |
| 609 | m_pRenderModels = (vr::IVRRenderModels *)vr::VR_GetGenericInterface( vr::IVRRenderModels_Version, &eError ); |
| 610 | if( !m_pRenderModels ) |
| 611 | { |
| 612 | m_pHMD = NULL; |
| 613 | vr::VR_Shutdown(); |
| 614 | |
| 615 | char buf[1024]; |
| 616 | sprintf_s( buf, sizeof( buf ), "Unable to get render model interface: %s", vr::VR_GetVRInitErrorAsEnglishDescription( eError ) ); |
| 617 | SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "VR_Init Failed", buf, NULL ); |
| 618 | return false; |
| 619 | } |
| 620 | |
| 621 | int nWindowPosX = 700; |
| 622 | int nWindowPosY = 100; |
| 623 | Uint32 unWindowFlags = SDL_WINDOW_SHOWN; |
| 624 | |
| 625 | m_pCompanionWindow = SDL_CreateWindow( "hellovr [Vulkan]", nWindowPosX, nWindowPosY, m_nCompanionWindowWidth, m_nCompanionWindowHeight, unWindowFlags ); |
| 626 | if (m_pCompanionWindow == NULL) |
| 627 | { |
| 628 | dprintf( "%s - Window could not be created! SDL Error: %s\n", __FUNCTION__, SDL_GetError() ); |
| 629 | return false; |
| 630 | } |
| 631 | |
| 632 | m_strDriver = "No Driver"; |
| 633 | m_strDisplay = "No Display"; |
| 634 | |
| 635 | m_strDriver = GetTrackedDeviceString( m_pHMD, vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_TrackingSystemName_String ); |
| 636 | m_strDisplay = GetTrackedDeviceString( m_pHMD, vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SerialNumber_String ); |
| 637 | |
| 638 | std::string strWindowTitle = "hellovr [Vulkan] - " + m_strDriver + " " + m_strDisplay; |
| 639 | SDL_SetWindowTitle( m_pCompanionWindow, strWindowTitle.c_str() ); |
| 640 | |
| 641 | // cube array |
| 642 | m_iSceneVolumeWidth = m_iSceneVolumeInit; |
| 643 | m_iSceneVolumeHeight = m_iSceneVolumeInit; |
| 644 | m_iSceneVolumeDepth = m_iSceneVolumeInit; |
| 645 |
no test coverage detected