Skip to content

Commit b4bf245

Browse files
committed
OpenVR SDK Update 0.9.12:
* 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]
1 parent 061cf41 commit b4bf245

24 files changed

+2923
-2430
lines changed

bin/linux32/libopenvr_api.so

4.57 KB
Binary file not shown.

bin/linux32/libopenvr_api.so.dbg

18.1 KB
Binary file not shown.

bin/linux64/libopenvr_api.so

4.81 KB
Binary file not shown.

bin/linux64/libopenvr_api.so.dbg

23.9 KB
Binary file not shown.

bin/osx32/libopenvr_api.dylib

7.27 KB
Binary file not shown.

bin/win32/openvr_api.dll

5 KB
Binary file not shown.

bin/win32/openvr_api.pdb

-96 KB
Binary file not shown.

bin/win64/openvr_api.dll

6 KB
Binary file not shown.

bin/win64/openvr_api.pdb

-104 KB
Binary file not shown.

headers/openvr.h

+580-368
Large diffs are not rendered by default.

headers/openvr_api.cs

+960-868
Large diffs are not rendered by default.

headers/openvr_api.json

+540-463
Large diffs are not rendered by default.

headers/openvr_capi.h

+590-459
Large diffs are not rendered by default.

headers/openvr_driver.h

+207-183
Large diffs are not rendered by default.

lib/linux32/libopenvr_api.so

17.9 KB
Binary file not shown.

lib/linux64/libopenvr_api.so

23.8 KB
Binary file not shown.

lib/osx32/libopenvr_api.dylib

7.27 KB
Binary file not shown.

lib/win32/openvr_api.lib

3.14 KB
Binary file not shown.

lib/win64/openvr_api.lib

3.08 KB
Binary file not shown.

samples/bin/win32/openvr_api.dll

5 KB
Binary file not shown.

samples/bin/win64/openvr_api.dll

6 KB
Binary file not shown.

samples/hellovr_opengl/hellovr_opengl_main.cpp

+39-83
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CGLRenderModel
2020
CGLRenderModel( const std::string & sRenderModelName );
2121
~CGLRenderModel();
2222

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

9090
private:
91-
bool m_bRunOnMainWindow;
92-
bool m_bUseCompositor;
9391
bool m_bDebugOpenGL;
9492
bool m_bVerbose;
9593
bool m_bPerf;
@@ -98,7 +96,6 @@ class CMainApplication
9896

9997
vr::IVRSystem *m_pHMD;
10098
vr::IVRRenderModels *m_pRenderModels;
101-
vr::IVRCompositor *m_pCompositor;
10299
std::string m_strDriver;
103100
std::string m_strDisplay;
104101
vr::TrackedDevicePose_t m_rTrackedDevicePose[ vr::k_unMaxTrackedDeviceCount ];
@@ -231,9 +228,6 @@ CMainApplication::CMainApplication( int argc, char *argv[] )
231228
, m_unRenderModelProgramID( 0 )
232229
, m_pHMD( NULL )
233230
, m_pRenderModels( NULL )
234-
, m_pCompositor( NULL )
235-
, m_bRunOnMainWindow( true )
236-
, m_bUseCompositor( true )
237231
, m_bDebugOpenGL( false )
238232
, m_bVerbose( false )
239233
, m_bPerf( false )
@@ -257,11 +251,7 @@ CMainApplication::CMainApplication( int argc, char *argv[] )
257251

258252
for( int i = 1; i < argc; i++ )
259253
{
260-
if( !stricmp( argv[i], "-windowed" ) )
261-
{
262-
m_bRunOnMainWindow = true;
263-
}
264-
else if( !stricmp( argv[i], "-gldebug" ) )
254+
if( !stricmp( argv[i], "-gldebug" ) )
265255
{
266256
m_bDebugOpenGL = true;
267257
}
@@ -286,12 +276,6 @@ CMainApplication::CMainApplication( int argc, char *argv[] )
286276
m_iSceneVolumeInit = atoi( argv[ i + 1 ] );
287277
i++;
288278
}
289-
else if( !stricmp( argv[i], "-nocompositor" ) )
290-
{
291-
m_bUseCompositor = false;
292-
m_bRunOnMainWindow = false;
293-
m_bVblank = true;
294-
}
295279
}
296280
// other initialization tasks are done in BInit
297281
memset(m_rDevClassChar, 0, sizeof(m_rDevClassChar));
@@ -338,14 +322,14 @@ bool CMainApplication::BInit()
338322
}
339323

340324
// Loading the SteamVR Runtime
341-
vr::HmdError eError = vr::HmdError_None;
325+
vr::EVRInitError eError = vr::VRInitError_None;
342326
m_pHMD = vr::VR_Init( &eError, vr::VRApplication_Scene );
343327

344-
if ( eError != vr::HmdError_None )
328+
if ( eError != vr::VRInitError_None )
345329
{
346330
m_pHMD = NULL;
347331
char buf[1024];
348-
sprintf_s( buf, sizeof( buf ), "Unable to init VR runtime: %s", vr::VR_GetStringForHmdError( eError ) );
332+
sprintf_s( buf, sizeof( buf ), "Unable to init VR runtime: %s", vr::VR_GetVRInitErrorAsEnglishDescription( eError ) );
349333
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "VR_Init Failed", buf, NULL );
350334
return false;
351335
}
@@ -358,7 +342,7 @@ bool CMainApplication::BInit()
358342
vr::VR_Shutdown();
359343

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

378356
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 );
379357
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
@@ -447,13 +425,10 @@ bool CMainApplication::BInit()
447425
return false;
448426
}
449427

450-
if (m_bUseCompositor)
428+
if (!BInitCompositor())
451429
{
452-
if (!BInitCompositor())
453-
{
454-
printf("%s - Failed to initialize VR Compositor!\n", __FUNCTION__);
455-
return false;
456-
}
430+
printf("%s - Failed to initialize VR Compositor!\n", __FUNCTION__);
431+
return false;
457432
}
458433

459434
return true;
@@ -501,25 +476,11 @@ bool CMainApplication::BInitGL()
501476
//-----------------------------------------------------------------------------
502477
bool CMainApplication::BInitCompositor()
503478
{
504-
vr::HmdError peError = vr::HmdError_None;
479+
vr::EVRInitError peError = vr::VRInitError_None;
505480

506-
m_pCompositor = (vr::IVRCompositor*)vr::VR_GetGenericInterface(vr::IVRCompositor_Version, &peError);
507-
508-
if ( peError != vr::HmdError_None )
481+
if ( !vr::VRCompositor() )
509482
{
510-
m_pCompositor = NULL;
511-
512-
printf( "Compositor initialization failed with error: %s\n", vr::VR_GetStringForHmdError( peError ) );
513-
return false;
514-
}
515-
516-
uint32_t unSize = m_pCompositor->GetLastError(NULL, 0);
517-
if (unSize > 1)
518-
{
519-
char* buffer = new char[unSize];
520-
m_pCompositor->GetLastError(buffer, unSize);
521-
printf( "Compositor - %s\n", buffer );
522-
delete [] buffer;
483+
printf( "Compositor initialization failed. See log file for details\n" );
523484
return false;
524485
}
525486

@@ -712,11 +673,10 @@ void CMainApplication::RenderFrame()
712673
RenderStereoTargets();
713674
RenderDistortion();
714675

715-
if ( m_pCompositor )
716-
{
717-
m_pCompositor->Submit(vr::Eye_Left, vr::API_OpenGL, (void*)leftEyeDesc.m_nResolveTextureId, NULL );
718-
m_pCompositor->Submit(vr::Eye_Right, vr::API_OpenGL, (void*)rightEyeDesc.m_nResolveTextureId, NULL );
719-
}
676+
vr::Texture_t leftEyeTexture = {(void*)leftEyeDesc.m_nResolveTextureId, vr::API_OpenGL, vr::ColorSpace_Gamma };
677+
vr::VRCompositor()->Submit(vr::Eye_Left, &leftEyeTexture );
678+
vr::Texture_t rightEyeTexture = {(void*)rightEyeDesc.m_nResolveTextureId, vr::API_OpenGL, vr::ColorSpace_Gamma };
679+
vr::VRCompositor()->Submit(vr::Eye_Right, &rightEyeTexture );
720680
}
721681

722682
if ( m_bVblank && m_bGlFinishHack )
@@ -1656,20 +1616,7 @@ void CMainApplication::UpdateHMDMatrixPose()
16561616
if ( !m_pHMD )
16571617
return;
16581618

1659-
if ( m_pCompositor )
1660-
{
1661-
m_pCompositor->WaitGetPoses(m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, NULL, 0 );
1662-
}
1663-
else
1664-
{
1665-
// We just got done with the glFinish - the seconds since last vsync should be 0.
1666-
float fSecondsSinceLastVsync = 0.0f;
1667-
1668-
float fFrameDuration = 1.0f / m_pHMD->GetFloatTrackedDeviceProperty( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_DisplayFrequency_Float );
1669-
1670-
float fSecondsUntilPhotons = fFrameDuration - fSecondsSinceLastVsync + m_pHMD->GetFloatTrackedDeviceProperty( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SecondsFromVsyncToPhotons_Float );
1671-
m_pHMD->GetDeviceToAbsoluteTrackingPose( vr::TrackingUniverseStanding, fSecondsUntilPhotons, m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount );
1672-
}
1619+
vr::VRCompositor()->WaitGetPoses(m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, NULL, 0 );
16731620

16741621
m_iValidPoseCount = 0;
16751622
m_strPoseClasses = "";
@@ -1720,25 +1667,34 @@ CGLRenderModel *CMainApplication::FindOrLoadRenderModel( const char *pchRenderMo
17201667
// load the model if we didn't find one
17211668
if( !pRenderModel )
17221669
{
1723-
vr::RenderModel_t model;
1724-
if( !m_pRenderModels->LoadRenderModel( pchRenderModelName, &model ) )
1670+
vr::RenderModel_t *pModel = NULL;
1671+
if ( !vr::VRRenderModels()->LoadRenderModel( pchRenderModelName, &pModel ) || pModel == NULL )
17251672
{
17261673
dprintf( "Unable to load render model %s\n", pchRenderModelName );
17271674
return NULL; // move on to the next tracked device
17281675
}
17291676

1677+
vr::RenderModel_TextureMap_t *pTexture = NULL;
1678+
if ( !vr::VRRenderModels( )->LoadTexture( pModel->diffuseTextureId, &pTexture ) || pTexture == NULL )
1679+
{
1680+
dprintf( "Unable to load render texture id:%d for render model %s\n", pModel->diffuseTextureId, pchRenderModelName );
1681+
vr::VRRenderModels()->FreeRenderModel( pModel );
1682+
return NULL; // move on to the next tracked device
1683+
}
1684+
17301685
pRenderModel = new CGLRenderModel( pchRenderModelName );
1731-
if( !pRenderModel->BInit( model ) )
1686+
if ( !pRenderModel->BInit( *pModel, *pTexture ) )
17321687
{
17331688
dprintf( "Unable to create GL model from render model %s\n", pchRenderModelName );
17341689
delete pRenderModel;
1735-
m_pRenderModels->FreeRenderModel( &model );
1736-
return NULL; // move on to the next tracked device
1690+
pRenderModel = NULL;
17371691
}
1738-
1739-
m_vecRenderModels.push_back( pRenderModel );
1740-
1741-
m_pRenderModels->FreeRenderModel( &model );
1692+
else
1693+
{
1694+
m_vecRenderModels.push_back( pRenderModel );
1695+
}
1696+
vr::VRRenderModels()->FreeRenderModel( pModel );
1697+
vr::VRRenderModels()->FreeTexture( pTexture );
17421698
}
17431699
return pRenderModel;
17441700
}
@@ -1826,7 +1782,7 @@ CGLRenderModel::~CGLRenderModel()
18261782
//-----------------------------------------------------------------------------
18271783
// Purpose: Allocates and populates the GL resources for a render model
18281784
//-----------------------------------------------------------------------------
1829-
bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel )
1785+
bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel, const vr::RenderModel_TextureMap_t & vrDiffuseTexture )
18301786
{
18311787
// create and bind a VAO to hold state for this model
18321788
glGenVertexArrays( 1, &m_glVertArray );
@@ -1844,7 +1800,7 @@ bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel )
18441800
glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, sizeof( vr::RenderModel_Vertex_t ), (void *)offsetof( vr::RenderModel_Vertex_t, vNormal ) );
18451801
glEnableVertexAttribArray( 2 );
18461802
glVertexAttribPointer( 2, 2, GL_FLOAT, GL_FALSE, sizeof( vr::RenderModel_Vertex_t ), (void *)offsetof( vr::RenderModel_Vertex_t, rfTextureCoord ) );
1847-
1803+
18481804
// Create and populate the index buffer
18491805
glGenBuffers( 1, &m_glIndexBuffer );
18501806
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_glIndexBuffer );
@@ -1856,8 +1812,8 @@ bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel )
18561812
glGenTextures(1, &m_glTexture );
18571813
glBindTexture( GL_TEXTURE_2D, m_glTexture );
18581814

1859-
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, vrModel.diffuseTexture.unWidth, vrModel.diffuseTexture.unHeight,
1860-
0, GL_RGBA, GL_UNSIGNED_BYTE, vrModel.diffuseTexture.rubTextureMapData );
1815+
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, vrDiffuseTexture.unWidth, vrDiffuseTexture.unHeight,
1816+
0, GL_RGBA, GL_UNSIGNED_BYTE, vrDiffuseTexture.rubTextureMapData );
18611817

18621818
// If this renders black ask McJohn what's wrong.
18631819
glGenerateMipmap(GL_TEXTURE_2D);

samples/helloworldoverlay/openvroverlaycontroller.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ COpenVROverlayController *COpenVROverlayController::SharedInstance()
3636
//-----------------------------------------------------------------------------
3737
COpenVROverlayController::COpenVROverlayController()
3838
: BaseClass()
39-
, m_eLastHmdError( vr::HmdError_None )
40-
, m_eCompositorError( vr::HmdError_None )
41-
, m_eOverlayError( vr::HmdError_None )
39+
, m_eLastHmdError( vr::VRInitError_None )
40+
, m_eCompositorError( vr::VRInitError_None )
41+
, m_eOverlayError( vr::VRInitError_None )
4242
, m_strVRDriver( "No Driver" )
4343
, m_strVRDisplay( "No Display" )
4444
, m_pOpenGLContext( NULL )
@@ -193,7 +193,8 @@ void COpenVROverlayController::OnSceneChanged( const QList<QRectF>& )
193193
GLuint unTexture = m_pFbo->texture();
194194
if( unTexture != 0 )
195195
{
196-
vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, vr::API_OpenGL, (void*)unTexture );
196+
vr::Texture_t texture = {(void*)unTexture, vr::API_OpenGL, vr::ColorSpace_Auto };
197+
vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, &texture );
197198
}
198199
}
199200

@@ -361,10 +362,10 @@ void COpenVROverlayController::SetWidget( QWidget *pWidget )
361362
//-----------------------------------------------------------------------------
362363
bool COpenVROverlayController::ConnectToVRRuntime()
363364
{
364-
m_eLastHmdError = vr::HmdError_None;
365+
m_eLastHmdError = vr::VRInitError_None;
365366
vr::IVRSystem *pVRSystem = vr::VR_Init( &m_eLastHmdError, vr::VRApplication_Overlay );
366367

367-
if ( m_eLastHmdError != vr::HmdError_None )
368+
if ( m_eLastHmdError != vr::VRInitError_None )
368369
{
369370
m_strVRDriver = "No Driver";
370371
m_strVRDisplay = "No Display";

0 commit comments

Comments
 (0)