Skip to content

Commit

Permalink
Updated the HelloVR sample to the new SDK.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//vr/steamvr/sdk_release/": change = 2826896]
  • Loading branch information
JoeLudwig committed Jun 11, 2015
1 parent 29d6b20 commit 6e1abf5
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions samples/hellovr_opengl/hellovr_opengl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class CMainApplication
bool m_bGlFinishHack;

vr::IVRSystem *m_pHMD;
vr::IVRRenderModels *m_pRenderModels;
vr::IVRCompositor *m_pCompositor;
std::string m_strDriver;
std::string m_strDisplay;
Expand Down Expand Up @@ -229,6 +230,7 @@ CMainApplication::CMainApplication( int argc, char *argv[] )
, m_unControllerTransformProgramID( 0 )
, m_unRenderModelProgramID( 0 )
, m_pHMD( NULL )
, m_pRenderModels( NULL )
, m_pCompositor( NULL )
, m_bRunOnMainWindow( true )
, m_bUseCompositor( true )
Expand Down Expand Up @@ -349,6 +351,18 @@ bool CMainApplication::BInit()
}


m_pRenderModels = (vr::IVRRenderModels *)vr::VR_GetGenericInterface( vr::IVRRenderModels_Version, &eError );
if( !m_pRenderModels )
{
m_pHMD = NULL;
vr::VR_Shutdown();

char buf[1024];
sprintf_s( buf, sizeof( buf ), "Unable to get render model interface: %s", vr::VR_GetStringForHmdError( eError ) );
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "VR_Init Failed", buf, NULL );
return false;
}

int nWindowPosX = 700;
int nWindowPosY = 100;
m_nWindowWidth = 1280;
Expand Down Expand Up @@ -703,7 +717,7 @@ void CMainApplication::RenderFrame()
if ( m_pCompositor )
{
// Flip y-axis since GL UV coords are backwards.
vr::Compositor_TextureBounds bounds;
vr::VRTextureBounds_t bounds;
bounds.uMin = 0;
bounds.vMin = 1;
bounds.uMax = 1;
Expand Down Expand Up @@ -1653,7 +1667,7 @@ void CMainApplication::UpdateHMDMatrixPose()

if ( m_pCompositor )
{
m_pCompositor->WaitGetPoses(m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount);
m_pCompositor->WaitGetPoses(m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, NULL, 0 );
}
else
{
Expand Down Expand Up @@ -1716,7 +1730,7 @@ CGLRenderModel *CMainApplication::FindOrLoadRenderModel( const char *pchRenderMo
if( !pRenderModel )
{
vr::RenderModel_t model;
if( !m_pHMD->LoadRenderModel( pchRenderModelName, &model ) )
if( !m_pRenderModels->LoadRenderModel( pchRenderModelName, &model ) )
{
dprintf( "Unable to load render model %s\n", pchRenderModelName );
return NULL; // move on to the next tracked device
Expand All @@ -1727,13 +1741,13 @@ CGLRenderModel *CMainApplication::FindOrLoadRenderModel( const char *pchRenderMo
{
dprintf( "Unable to create GL model from render model %s\n", pchRenderModelName );
delete pRenderModel;
m_pHMD->FreeRenderModel( &model );
m_pRenderModels->FreeRenderModel( &model );
return NULL; // move on to the next tracked device
}

m_vecRenderModels.push_back( pRenderModel );

m_pHMD->FreeRenderModel( &model );
m_pRenderModels->FreeRenderModel( &model );
}
return pRenderModel;
}
Expand Down

0 comments on commit 6e1abf5

Please sign in to comment.