Skip to content

Commit

Permalink
OpenVR SDK Update 0.9.12:
Browse files Browse the repository at this point in the history
* Renamed many enums to a more consistent naming scheme. Typedefs are in place to allow old code to continue building, but those will be removed at some point in the future.
  * HmdError -> EVRInitError
  * Hmd_Eye -> EVREye 
  * GraphicsAPIConvention -> EGraphicsAPIConvention
  * HmdTrackingResult -> ETrackingResult
  * TrackedDeviceClass -> ETrackedDeviceClass 
  * TrackingUniverseOrigin -> ETrackingUniverseOrigin
  * TrackedDeviceProperty -> ETrackedDeviceProperty
  * TrackedPropertyError -> ETrackedPropertyError
  * VRSubmitFlags_t -> EVRSubmitFlags
  * VRState_t -> EVRState
  * CollisionBoundsStyle_t -> ECollisionBoundsStyle
  * VROverlayError -> EVROverlayError
  * VRFirmwareError -> EVRFirmwareError
  * VRCompositorError -> EVRCompositorError
* Renamed all HmdError_* enum vales to VRInitError_* to match the new enum name.
* VR_GetStringForHmdError was renamed to VR_GetVRInitErrorAsEnglishDescription to match the new enum name and make it clear what this function actually does.
* VR_GetVRInitErrorAsSymbol was added. This returns the literal EVRInitError value name instead of a user-facing string. Use this to look up localized strings to display to users.

* IVRRenderModels
   * Introduced Component interface, which allows client applications to draw, label, or interact with tracked object components.
       Components may define coordinate systems, renderable geometry, associations with button state, and supports button / axis dynamics. 

      Example uses of the IVRRenderModels Component API
      *   Compositor controller rendering reflects live button/trackpad/trigger motion dynamics
      *   Client applications can query controller-agnostic render label "attachment points"
      *   Client applications can query controller-agnostic hand-pose
   * LoadRenderModel does not load textures automatically, instead an additional call to LoadTexture is required.  This enables texture reuse across model components.

* Added new event VREvent_IpdChanged, which is sent when the physical IPD has changed on hardware that supports that. Because IVRSystem::GetEyeToHeadTransform is based on the user's IPD, applications which cache the matrix returned from that function will need to query it again. Applications that call GetEyeToHeadTransform each frame can safely ignore this event.
* Functions that are used by an application to create its own window have moved to IVRExtendedDisplay. Calls to get this interface will return NULL and error VRInitError_Init_NotSupportedWithCompositor if VR Compositor is already running. Applications will need to use the compositor in that case. The functions that were moved are:
  * GetWindowBounds
  * GetEyeOutputViewport
  * GetDXGIOutputInfo
* IVRNotifications has been changed to support different types (transient and persistent) and styles of notifications. The notification system remains a work-in-progress and is not yet fully implemented.

* Changed several functions that take a texture pointer to take a Texture_t struct instead. This struct allows the caller to identify the API and color space of the source texture in addition to the texture itself.
* IVROverlay::SetOverlayGamma has been replaced with SetOverlayTextureColorSpace wich allows applications to specify that their texture is in linear or SRGB space.
* IVRCompositor::Submit may return the following two new errors now rather than silently failing:
  * TextureUsesUnsupportedFormat
  * SharedTexturesNotSupported (if your app does not use DXGI 1.1 or greater)
* IVRCompositor::GetLastError has been removed.  Errors are reported in the log.
* IVRCompositor::Get/SetVSync has been removed.
* IVRCompositor::Get/SetGamma has been removed (specify color space when submitting textures now instead).
* Added IVRCompositor::GetLastPoses - returns the last set of poses returned by WaitGetPoses.

* Added new application type VRApplication_Background, which will not start SteamVR if it isn't already running and will not keep it running if it would otherwise shutdown.
* Added IVRSystem::AcknowledgeQuit_Exiting to allow an application to acknowledge an incoming Quit event. This extends the timout before vrserver kills the app from 5 seconds to 60 seconds.
* Added IVRSystem::AcknowledgeQuit_UserPrompt to allow an application to tell the system that the user should be prompted to save data before exiting. This will cause the dashboard to be shown with UI that prompts the user to cancel the quit/transition request or to quit the app anyway. All timeouts will be cancelled once this call is made to give the user a chance to respond.
* Quit events now have a bForced field (under event.data.process). If this is this field is true calls to AcknowledgeQuit_UserPrompt will be ignored and the app will be killed automatically after a timeout if it doesn't exit on its own.
* The concept of a "home application" has been removed from the API. No 3D application will be launched automatically when SteamVR starts.

* Chaperone data is automatically reloaded in all applications when VRServer receives VREvent_ChaperoneSettingsHaveChanged. It's no longer necessary to watch for this event in each application.
* IVRChaperoneSetup has been added to the API which includes access to Chaperone Bounds polygons.

[git-p4: depot-paths = "//vr/steamvr/sdk_release/": change = 3147743]
  • Loading branch information
JoeLudwig committed Nov 30, 2015
1 parent 061cf41 commit b4bf245
Show file tree
Hide file tree
Showing 24 changed files with 2,923 additions and 2,430 deletions.
Binary file modified bin/linux32/libopenvr_api.so
Binary file not shown.
Binary file modified bin/linux32/libopenvr_api.so.dbg
Binary file not shown.
Binary file modified bin/linux64/libopenvr_api.so
Binary file not shown.
Binary file modified bin/linux64/libopenvr_api.so.dbg
Binary file not shown.
Binary file modified bin/osx32/libopenvr_api.dylib
Binary file not shown.
Binary file not shown.
Binary file modified bin/win32/openvr_api.dll
Binary file not shown.
Binary file modified bin/win32/openvr_api.pdb
Binary file not shown.
Binary file modified bin/win64/openvr_api.dll
Binary file not shown.
Binary file modified bin/win64/openvr_api.pdb
Binary file not shown.
948 changes: 580 additions & 368 deletions headers/openvr.h

Large diffs are not rendered by default.

1,828 changes: 960 additions & 868 deletions headers/openvr_api.cs

Large diffs are not rendered by default.

1,003 changes: 540 additions & 463 deletions headers/openvr_api.json

Large diffs are not rendered by default.

1,049 changes: 590 additions & 459 deletions headers/openvr_capi.h

Large diffs are not rendered by default.

390 changes: 207 additions & 183 deletions headers/openvr_driver.h

Large diffs are not rendered by default.

Binary file modified lib/linux32/libopenvr_api.so
Binary file not shown.
Binary file modified lib/linux64/libopenvr_api.so
Binary file not shown.
Binary file modified lib/osx32/libopenvr_api.dylib
Binary file not shown.
Binary file modified lib/win32/openvr_api.lib
Binary file not shown.
Binary file modified lib/win64/openvr_api.lib
Binary file not shown.
Binary file modified samples/bin/win32/openvr_api.dll
Binary file not shown.
Binary file modified samples/bin/win64/openvr_api.dll
Binary file not shown.
122 changes: 39 additions & 83 deletions samples/hellovr_opengl/hellovr_opengl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CGLRenderModel
CGLRenderModel( const std::string & sRenderModelName );
~CGLRenderModel();

bool BInit( const vr::RenderModel_t & vrModel );
bool BInit( const vr::RenderModel_t & vrModel, const vr::RenderModel_TextureMap_t & vrDiffuseTexture );
void Cleanup();
void Draw();
const std::string & GetName() const { return m_sModelName; }
Expand Down Expand Up @@ -88,8 +88,6 @@ class CMainApplication
CGLRenderModel *FindOrLoadRenderModel( const char *pchRenderModelName );

private:
bool m_bRunOnMainWindow;
bool m_bUseCompositor;
bool m_bDebugOpenGL;
bool m_bVerbose;
bool m_bPerf;
Expand All @@ -98,7 +96,6 @@ class CMainApplication

vr::IVRSystem *m_pHMD;
vr::IVRRenderModels *m_pRenderModels;
vr::IVRCompositor *m_pCompositor;
std::string m_strDriver;
std::string m_strDisplay;
vr::TrackedDevicePose_t m_rTrackedDevicePose[ vr::k_unMaxTrackedDeviceCount ];
Expand Down Expand Up @@ -231,9 +228,6 @@ CMainApplication::CMainApplication( int argc, char *argv[] )
, m_unRenderModelProgramID( 0 )
, m_pHMD( NULL )
, m_pRenderModels( NULL )
, m_pCompositor( NULL )
, m_bRunOnMainWindow( true )
, m_bUseCompositor( true )
, m_bDebugOpenGL( false )
, m_bVerbose( false )
, m_bPerf( false )
Expand All @@ -257,11 +251,7 @@ CMainApplication::CMainApplication( int argc, char *argv[] )

for( int i = 1; i < argc; i++ )
{
if( !stricmp( argv[i], "-windowed" ) )
{
m_bRunOnMainWindow = true;
}
else if( !stricmp( argv[i], "-gldebug" ) )
if( !stricmp( argv[i], "-gldebug" ) )
{
m_bDebugOpenGL = true;
}
Expand All @@ -286,12 +276,6 @@ CMainApplication::CMainApplication( int argc, char *argv[] )
m_iSceneVolumeInit = atoi( argv[ i + 1 ] );
i++;
}
else if( !stricmp( argv[i], "-nocompositor" ) )
{
m_bUseCompositor = false;
m_bRunOnMainWindow = false;
m_bVblank = true;
}
}
// other initialization tasks are done in BInit
memset(m_rDevClassChar, 0, sizeof(m_rDevClassChar));
Expand Down Expand Up @@ -338,14 +322,14 @@ bool CMainApplication::BInit()
}

// Loading the SteamVR Runtime
vr::HmdError eError = vr::HmdError_None;
vr::EVRInitError eError = vr::VRInitError_None;
m_pHMD = vr::VR_Init( &eError, vr::VRApplication_Scene );

if ( eError != vr::HmdError_None )
if ( eError != vr::VRInitError_None )
{
m_pHMD = NULL;
char buf[1024];
sprintf_s( buf, sizeof( buf ), "Unable to init VR runtime: %s", vr::VR_GetStringForHmdError( eError ) );
sprintf_s( buf, sizeof( buf ), "Unable to init VR runtime: %s", vr::VR_GetVRInitErrorAsEnglishDescription( eError ) );
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "VR_Init Failed", buf, NULL );
return false;
}
Expand All @@ -358,7 +342,7 @@ bool CMainApplication::BInit()
vr::VR_Shutdown();

char buf[1024];
sprintf_s( buf, sizeof( buf ), "Unable to get render model interface: %s", vr::VR_GetStringForHmdError( eError ) );
sprintf_s( buf, sizeof( buf ), "Unable to get render model interface: %s", vr::VR_GetVRInitErrorAsEnglishDescription( eError ) );
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "VR_Init Failed", buf, NULL );
return false;
}
Expand All @@ -368,12 +352,6 @@ bool CMainApplication::BInit()
m_nWindowWidth = 1280;
m_nWindowHeight = 720;
Uint32 unWindowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
if ( !m_bRunOnMainWindow )
{
m_pHMD->GetWindowBounds( &nWindowPosX, &nWindowPosY, &m_nWindowWidth, &m_nWindowHeight );
// SDL_WINDOW_FULLSCREEN seems to give us a black flicker, while SDL_WINDOW_FULLSCREEN_DESKTOP does not
unWindowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}

SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
Expand Down Expand Up @@ -447,13 +425,10 @@ bool CMainApplication::BInit()
return false;
}

if (m_bUseCompositor)
if (!BInitCompositor())
{
if (!BInitCompositor())
{
printf("%s - Failed to initialize VR Compositor!\n", __FUNCTION__);
return false;
}
printf("%s - Failed to initialize VR Compositor!\n", __FUNCTION__);
return false;
}

return true;
Expand Down Expand Up @@ -501,25 +476,11 @@ bool CMainApplication::BInitGL()
//-----------------------------------------------------------------------------
bool CMainApplication::BInitCompositor()
{
vr::HmdError peError = vr::HmdError_None;
vr::EVRInitError peError = vr::VRInitError_None;

m_pCompositor = (vr::IVRCompositor*)vr::VR_GetGenericInterface(vr::IVRCompositor_Version, &peError);

if ( peError != vr::HmdError_None )
if ( !vr::VRCompositor() )
{
m_pCompositor = NULL;

printf( "Compositor initialization failed with error: %s\n", vr::VR_GetStringForHmdError( peError ) );
return false;
}

uint32_t unSize = m_pCompositor->GetLastError(NULL, 0);
if (unSize > 1)
{
char* buffer = new char[unSize];
m_pCompositor->GetLastError(buffer, unSize);
printf( "Compositor - %s\n", buffer );
delete [] buffer;
printf( "Compositor initialization failed. See log file for details\n" );
return false;
}

Expand Down Expand Up @@ -712,11 +673,10 @@ void CMainApplication::RenderFrame()
RenderStereoTargets();
RenderDistortion();

if ( m_pCompositor )
{
m_pCompositor->Submit(vr::Eye_Left, vr::API_OpenGL, (void*)leftEyeDesc.m_nResolveTextureId, NULL );
m_pCompositor->Submit(vr::Eye_Right, vr::API_OpenGL, (void*)rightEyeDesc.m_nResolveTextureId, NULL );
}
vr::Texture_t leftEyeTexture = {(void*)leftEyeDesc.m_nResolveTextureId, vr::API_OpenGL, vr::ColorSpace_Gamma };
vr::VRCompositor()->Submit(vr::Eye_Left, &leftEyeTexture );
vr::Texture_t rightEyeTexture = {(void*)rightEyeDesc.m_nResolveTextureId, vr::API_OpenGL, vr::ColorSpace_Gamma };
vr::VRCompositor()->Submit(vr::Eye_Right, &rightEyeTexture );
}

if ( m_bVblank && m_bGlFinishHack )
Expand Down Expand Up @@ -1656,20 +1616,7 @@ void CMainApplication::UpdateHMDMatrixPose()
if ( !m_pHMD )
return;

if ( m_pCompositor )
{
m_pCompositor->WaitGetPoses(m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, NULL, 0 );
}
else
{
// We just got done with the glFinish - the seconds since last vsync should be 0.
float fSecondsSinceLastVsync = 0.0f;

float fFrameDuration = 1.0f / m_pHMD->GetFloatTrackedDeviceProperty( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_DisplayFrequency_Float );

float fSecondsUntilPhotons = fFrameDuration - fSecondsSinceLastVsync + m_pHMD->GetFloatTrackedDeviceProperty( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SecondsFromVsyncToPhotons_Float );
m_pHMD->GetDeviceToAbsoluteTrackingPose( vr::TrackingUniverseStanding, fSecondsUntilPhotons, m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount );
}
vr::VRCompositor()->WaitGetPoses(m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, NULL, 0 );

m_iValidPoseCount = 0;
m_strPoseClasses = "";
Expand Down Expand Up @@ -1720,25 +1667,34 @@ CGLRenderModel *CMainApplication::FindOrLoadRenderModel( const char *pchRenderMo
// load the model if we didn't find one
if( !pRenderModel )
{
vr::RenderModel_t model;
if( !m_pRenderModels->LoadRenderModel( pchRenderModelName, &model ) )
vr::RenderModel_t *pModel = NULL;
if ( !vr::VRRenderModels()->LoadRenderModel( pchRenderModelName, &pModel ) || pModel == NULL )
{
dprintf( "Unable to load render model %s\n", pchRenderModelName );
return NULL; // move on to the next tracked device
}

vr::RenderModel_TextureMap_t *pTexture = NULL;
if ( !vr::VRRenderModels( )->LoadTexture( pModel->diffuseTextureId, &pTexture ) || pTexture == NULL )
{
dprintf( "Unable to load render texture id:%d for render model %s\n", pModel->diffuseTextureId, pchRenderModelName );
vr::VRRenderModels()->FreeRenderModel( pModel );
return NULL; // move on to the next tracked device
}

pRenderModel = new CGLRenderModel( pchRenderModelName );
if( !pRenderModel->BInit( model ) )
if ( !pRenderModel->BInit( *pModel, *pTexture ) )
{
dprintf( "Unable to create GL model from render model %s\n", pchRenderModelName );
delete pRenderModel;
m_pRenderModels->FreeRenderModel( &model );
return NULL; // move on to the next tracked device
pRenderModel = NULL;
}

m_vecRenderModels.push_back( pRenderModel );

m_pRenderModels->FreeRenderModel( &model );
else
{
m_vecRenderModels.push_back( pRenderModel );
}
vr::VRRenderModels()->FreeRenderModel( pModel );
vr::VRRenderModels()->FreeTexture( pTexture );
}
return pRenderModel;
}
Expand Down Expand Up @@ -1826,7 +1782,7 @@ CGLRenderModel::~CGLRenderModel()
//-----------------------------------------------------------------------------
// Purpose: Allocates and populates the GL resources for a render model
//-----------------------------------------------------------------------------
bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel )
bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel, const vr::RenderModel_TextureMap_t & vrDiffuseTexture )
{
// create and bind a VAO to hold state for this model
glGenVertexArrays( 1, &m_glVertArray );
Expand All @@ -1844,7 +1800,7 @@ bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel )
glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, sizeof( vr::RenderModel_Vertex_t ), (void *)offsetof( vr::RenderModel_Vertex_t, vNormal ) );
glEnableVertexAttribArray( 2 );
glVertexAttribPointer( 2, 2, GL_FLOAT, GL_FALSE, sizeof( vr::RenderModel_Vertex_t ), (void *)offsetof( vr::RenderModel_Vertex_t, rfTextureCoord ) );

// Create and populate the index buffer
glGenBuffers( 1, &m_glIndexBuffer );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_glIndexBuffer );
Expand All @@ -1856,8 +1812,8 @@ bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel )
glGenTextures(1, &m_glTexture );
glBindTexture( GL_TEXTURE_2D, m_glTexture );

glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, vrModel.diffuseTexture.unWidth, vrModel.diffuseTexture.unHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE, vrModel.diffuseTexture.rubTextureMapData );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, vrDiffuseTexture.unWidth, vrDiffuseTexture.unHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE, vrDiffuseTexture.rubTextureMapData );

// If this renders black ask McJohn what's wrong.
glGenerateMipmap(GL_TEXTURE_2D);
Expand Down
13 changes: 7 additions & 6 deletions samples/helloworldoverlay/openvroverlaycontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ COpenVROverlayController *COpenVROverlayController::SharedInstance()
//-----------------------------------------------------------------------------
COpenVROverlayController::COpenVROverlayController()
: BaseClass()
, m_eLastHmdError( vr::HmdError_None )
, m_eCompositorError( vr::HmdError_None )
, m_eOverlayError( vr::HmdError_None )
, m_eLastHmdError( vr::VRInitError_None )
, m_eCompositorError( vr::VRInitError_None )
, m_eOverlayError( vr::VRInitError_None )
, m_strVRDriver( "No Driver" )
, m_strVRDisplay( "No Display" )
, m_pOpenGLContext( NULL )
Expand Down Expand Up @@ -193,7 +193,8 @@ void COpenVROverlayController::OnSceneChanged( const QList<QRectF>& )
GLuint unTexture = m_pFbo->texture();
if( unTexture != 0 )
{
vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, vr::API_OpenGL, (void*)unTexture );
vr::Texture_t texture = {(void*)unTexture, vr::API_OpenGL, vr::ColorSpace_Auto };
vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, &texture );
}
}

Expand Down Expand Up @@ -361,10 +362,10 @@ void COpenVROverlayController::SetWidget( QWidget *pWidget )
//-----------------------------------------------------------------------------
bool COpenVROverlayController::ConnectToVRRuntime()
{
m_eLastHmdError = vr::HmdError_None;
m_eLastHmdError = vr::VRInitError_None;
vr::IVRSystem *pVRSystem = vr::VR_Init( &m_eLastHmdError, vr::VRApplication_Overlay );

if ( m_eLastHmdError != vr::HmdError_None )
if ( m_eLastHmdError != vr::VRInitError_None )
{
m_strVRDriver = "No Driver";
m_strVRDisplay = "No Display";
Expand Down

0 comments on commit b4bf245

Please sign in to comment.