MCPcopy Create free account
hub / github.com/OGRECave/ogre-next / initOpenVR

Method initOpenVR

Samples/2.0/Tutorials/Tutorial_OpenVR/Tutorial_OpenVR.cpp:109–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107 }
108
109 void Tutorial_OpenVRGraphicsSystem::initOpenVR()
110 {
111 const Ogre::IdString workspaceName =
112 c_useRDM ? "Tutorial_OpenVRWorkspaceRDM" : "Tutorial_OpenVRWorkspaceNoRDM";
113#ifdef USE_OPEN_VR
114 // Loading the SteamVR Runtime
115 vr::EVRInitError eError = vr::VRInitError_None;
116 mHMD = vr::VR_Init( &eError, vr::VRApplication_Scene );
117
118 if( eError != vr::VRInitError_None )
119 {
120 mHMD = 0;
121 Ogre::String errorMsg = "Unable to init VR runtime: ";
122 errorMsg += vr::VR_GetVRInitErrorAsEnglishDescription( eError );
123 OGRE_EXCEPT( Ogre::Exception::ERR_RENDERINGAPI_ERROR, errorMsg,
124 "Tutorial_OpenVRGraphicsSystem::initOpenVR" );
125 }
126
127 mStrDriver = "No Driver";
128 mStrDisplay = "No Display";
129
130 mStrDriver =
131 GetTrackedDeviceString( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_TrackingSystemName_String );
132 mStrDisplay =
133 GetTrackedDeviceString( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SerialNumber_String );
134 mDeviceModelNumber =
135 GetTrackedDeviceString( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_ModelNumber_String );
136
137 initCompositorVR();
138
139 uint32_t width, height;
140 mHMD->GetRecommendedRenderTargetSize( &width, &height );
141
142 Ogre::TextureGpuManager *textureManager = mRoot->getRenderSystem()->getTextureGpuManager();
143 // Radial Density Mask requires the VR texture to be UAV & reinterpretable
144 mVrTexture = textureManager->createOrRetrieveTexture(
145 "OpenVR Both Eyes", Ogre::GpuPageOutStrategy::Discard,
146 Ogre::TextureFlags::RenderToTexture | Ogre::TextureFlags::Uav |
147 Ogre::TextureFlags::Reinterpretable,
148 Ogre::TextureTypes::Type2D );
149 mVrTexture->setResolution( width << 1u, height );
150 mVrTexture->setPixelFormat( Ogre::PFG_RGBA8_UNORM_SRGB );
151 if( !c_useRDM )
152 mVrTexture->setSampleDescription( Ogre::SampleDescription( 4u ) );
153 mVrTexture->scheduleTransitionTo( Ogre::GpuResidency::Resident );
154
155 mVrCullCamera = mSceneManager->createCamera( "VrCullCamera" );
156
157 Ogre::CompositorManager2 *compositorManager = mRoot->getCompositorManager2();
158 mVrWorkspace = compositorManager->addWorkspace( mSceneManager, mVrTexture, mCamera,
159 workspaceName, true, 0 );
160
161 createHiddenAreaMeshVR();
162
163 mOvrCompositorListener = new OpenVRCompositorListener(
164 mHMD, vr::VRCompositor(), mVrTexture, mRoot, mVrWorkspace, mCamera, mVrCullCamera );
165#else
166 Ogre::TextureGpuManager *textureManager = mRoot->getRenderSystem()->getTextureGpuManager();

Callers

nothing calls this directly

Calls 10

SampleDescriptionFunction · 0.85
getTextureGpuManagerMethod · 0.80
setPixelFormatMethod · 0.80
setSampleDescriptionMethod · 0.80
scheduleTransitionToMethod · 0.80
addWorkspaceMethod · 0.80
getRenderSystemMethod · 0.45
setResolutionMethod · 0.45
createCameraMethod · 0.45

Tested by

no test coverage detected