Enable sourcevr build, make it build (but still not work) with modern openvr api

This commit is contained in:
mittorn
2023-09-15 20:31:16 +03:00
parent b7bd94c52e
commit 82d805508c
6 changed files with 76 additions and 1241 deletions
+20 -12
View File
@@ -207,7 +207,11 @@ void CDistortionTextureRegen::RegenerateTextureBits( ITexture *pTexture, IVTFTex
float u = ( (float)x + 0.5f) / fWidth;
float v = ( (float)y + 0.5f) / fHeight;
DistortionCoordinates_t coords = g_SourceVirtualReality.GetHmd()->ComputeDistortion( m_eEye, u, v );
DistortionCoordinates_t coords;
if(!g_SourceVirtualReality.GetHmd()->ComputeDistortion( m_eEye, u, v, &coords ))
{
Warning("ComputeDistortion failed");
}
coords.rfRed[0] = Clamp( coords.rfRed[0], 0.f, 1.f ) * fUScale + fUOffset;
coords.rfGreen[0] = Clamp( coords.rfGreen[0], 0.f, 1.f ) * fUScale + fUOffset;
@@ -277,9 +281,9 @@ bool CSourceVirtualReality::GetDisplayBounds( VRRect_t *pRect )
{
if( m_pHmd )
{
int32_t x, y;
uint32_t width, height;
m_pHmd->GetWindowBounds( &x, &y, &width, &height );
int32_t x = 0, y = 0;
uint32_t width = 1024, height = 1024;
m_pExtDisplay->GetWindowBounds( &x, &y, &width, &height );
pRect->nX = x;
pRect->nY = y;
pRect->nWidth = width;
@@ -421,7 +425,8 @@ void CSourceVirtualReality::GetViewportBounds( VREye eEye, int *pnX, int *pnY, i
else
{
uint32_t x, y, w, h;
m_pHmd->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
// m_pHmd->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
m_pExtDisplay->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
if( pnX && pnY )
{
*pnX = x;
@@ -530,8 +535,8 @@ bool CSourceVirtualReality::WillDriftInYaw()
void CSourceVirtualReality::AcquireNewZeroPose()
{
// just let the next tracker update re-zero us
if( m_pHmd )
m_pHmd->ResetSeatedZeroPose();
if( m_pChap )
m_pChap->ResetZeroPose(TrackingUniverseSeated);
}
bool CSourceVirtualReality::SampleTrackingState ( float PlayerGameFov, float fPredictionSeconds )
@@ -608,7 +613,7 @@ bool CSourceVirtualReality::DoDistortionProcessing ( VREye eEye )
// This is where we are rendering to
uint32_t x, y, w, h;
m_pHmd->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
m_pExtDisplay->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
pRenderContext->DrawScreenSpaceRectangle ( pDistortMaterial,
x, y, w, h,
@@ -682,7 +687,7 @@ bool CSourceVirtualReality::CompositeHud ( VREye eEye, float ndcHudBounds[4], bo
CMatRenderContextPtr pRenderContext( materials );
uint32_t x, y, w, h;
m_pHmd->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
m_pExtDisplay->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
pRenderContext->DrawScreenSpaceRectangle ( pDistortHUDMaterial,
x, y, w, h,
@@ -706,14 +711,17 @@ bool CSourceVirtualReality::StartTracker()
// Initialize SteamVR
vr::HmdError err;
m_pHmd = vr::VR_Init( &err );
if( err != HmdError_None )
m_pHmd = vr::VR_Init( &err, vr::VRApplication_Scene );
m_pExtDisplay = vr::VRExtendedDisplay();
m_pChap = vr::VRChaperone();
if( err != vr::VRInitError_None )
{
Msg( "Unable to initialize HMD tracker. Error code %d\n", err );
return false;
}
m_pHmd->ResetSeatedZeroPose();
m_pChap->ResetZeroPose(TrackingUniverseSeated);
m_bHaveValidPose = false;
m_ZeroFromHeadPose.Identity();
+2
View File
@@ -124,6 +124,8 @@ private:
CMaterialReference m_blackMaterial;
vr::IVRSystem *m_pHmd;
vr::IVRExtendedDisplay *m_pExtDisplay;
vr::IVRChaperone *m_pChap;
bool m_bHaveValidPose;
VMatrix m_ZeroFromHeadPose;
+49
View File
@@ -0,0 +1,49 @@
#! /usr/bin/env python
# encoding: utf-8
from waflib import Utils
import os
top = '.'
PROJECT_NAME = 'sourcevr'
def options(opt):
# stub
return
def configure(conf):
conf.env.append_unique('DEFINES',['strncpy=use_Q_strncpy_instead',
'_snprintf=use_Q_snprintf_instead','SOURCEVR_DLL'])
conf.check_cfg(package='openvr', uselib_store='OPENVR', args=['--cflags', '--libs'])
def build(bld):
source = [
"sourcevirtualreality.cpp"
]
includes = [
'.',
'../public',
'../public/tier0',
'../public/tier1'
] + bld.env.INCLUDES_SDL2
defines = []
libs = ['tier0','tier1','tier2', 'tier3','vstdlib','mathlib','OPENVR']
install_path = bld.env.LIBDIR
bld.shlib(
source = source,
target = PROJECT_NAME,
name = PROJECT_NAME,
features = 'c cxx',
includes = includes,
defines = defines,
use = libs,
install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count()
)