mirror of
https://github.com/celisej567/source-engine.git
synced 2025-12-31 21:48:22 +03:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9cf6b2c7e | ||
|
|
f4e00c3159 | ||
|
|
82d805508c |
@@ -501,6 +501,7 @@ public:
|
||||
DELEGATE_TO_OBJECT_0( bool, OnFlushBufferedPrimitives, GetRenderContextInternal() );
|
||||
void OnThreadEvent( uint32 threadEvent );
|
||||
ShaderAPITextureHandle_t GetShaderAPITextureBindHandle( ITexture *pTexture, int nFrame, int nTextureChannel ); // JasonM ????
|
||||
uint32_t GetShaderAPIGLTexture( ITexture *pTexture, int nFrame, int nTextureChannel ); // fuck
|
||||
|
||||
|
||||
|
||||
|
||||
53
materialsystem/gltexturehack.cpp
Normal file
53
materialsystem/gltexturehack.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "pch_materialsystem.h"
|
||||
#include "togl/rendermechanism.h"
|
||||
|
||||
#define MATSYS_INTERNAL
|
||||
|
||||
#include "cmaterialsystem.h"
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Base implementation of the shader rendering interface
|
||||
//-----------------------------------------------------------------------------
|
||||
class CShaderAPIBase : public IShaderAPI
|
||||
{
|
||||
public:
|
||||
// constructor, destructor
|
||||
CShaderAPIBase();
|
||||
virtual ~CShaderAPIBase();
|
||||
|
||||
// Called when the device is initializing or shutting down
|
||||
virtual bool OnDeviceInit() = 0;
|
||||
virtual void OnDeviceShutdown() = 0;
|
||||
|
||||
// Pix events
|
||||
virtual void BeginPIXEvent( unsigned long color, const char *szName ) = 0;
|
||||
virtual void EndPIXEvent() = 0;
|
||||
virtual void AdvancePIXFrame() = 0;
|
||||
|
||||
// Release, reacquire objects
|
||||
virtual void ReleaseShaderObjects() = 0;
|
||||
virtual void RestoreShaderObjects() = 0;
|
||||
|
||||
// Resets the render state to its well defined initial value
|
||||
virtual void ResetRenderState( bool bFullReset = true ) = 0;
|
||||
|
||||
// Returns a d3d texture associated with a texture handle
|
||||
virtual IDirect3DBaseTexture9* GetD3DTexture( ShaderAPITextureHandle_t hTexture ) = 0;
|
||||
|
||||
// Queues a non-full reset of render state next BeginFrame.
|
||||
virtual void QueueResetRenderState() = 0;
|
||||
|
||||
// Methods of IShaderDynamicAPI
|
||||
public:
|
||||
virtual void GetCurrentColorCorrection( ShaderColorCorrectionInfo_t* pInfo );
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
uint32_t CMaterialSystem::GetShaderAPIGLTexture( ITexture *pTexture, int nFrame, int nTextureChannel )
|
||||
{
|
||||
ShaderAPITextureHandle_t handle = ShaderSystem()->GetShaderAPITextureBindHandle( pTexture, nFrame, nTextureChannel );
|
||||
IDirect3DTexture9* pTex = ((CShaderAPIBase*)g_pShaderAPI)->GetD3DTexture(handle);
|
||||
IDirect3DSurface9* surf = pTex->m_surfZero;
|
||||
CGLMTex *tex = surf->m_tex;
|
||||
return tex->GetTexName();
|
||||
}
|
||||
@@ -2276,7 +2276,7 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual uint32_t GetShaderAPIGLTexture(ITexture*, int, int) {return 0;}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ def build(bld):
|
||||
'cmatrendercontext.cpp',
|
||||
'cmatqueuedrendercontext.cpp',
|
||||
'ctexturecompositor.cpp',
|
||||
'gltexturehack.cpp',
|
||||
'../public/tier0/memoverride.cpp'
|
||||
]
|
||||
|
||||
|
||||
@@ -1093,6 +1093,7 @@ public:
|
||||
|
||||
// Performs final verification of all compositor templates (after they've all been initially loaded).
|
||||
virtual bool VerifyTextureCompositorTemplates( ) = 0;
|
||||
virtual uint32_t GetShaderAPIGLTexture( ITexture *pTexture, int nFrame, int nTextureChannel ) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,130 +0,0 @@
|
||||
//====== Copyright (c) 1996-2014, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose: Header for flatted SteamAPI. Use this for binding to other languages.
|
||||
// This file is auto-generated, do not edit it.
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef __OPENVR_API_FLAT_H__
|
||||
#define __OPENVR_API_FLAT_H__
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// OPENVR API export macro
|
||||
#if defined( _WIN32 ) && !defined( _X360 )
|
||||
#if defined( OPENVR_API_EXPORTS )
|
||||
#define S_API extern "C" __declspec( dllexport )
|
||||
#elif defined( OPENVR_API_NODLL )
|
||||
#define S_API extern "C"
|
||||
#else
|
||||
#define S_API extern "C" __declspec( dllimport )
|
||||
#endif // OPENVR_API_EXPORTS
|
||||
#elif defined( GNUC )
|
||||
#if defined( OPENVR_API_EXPORTS )
|
||||
#define S_API extern "C" __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define S_API extern "C"
|
||||
#endif // OPENVR_API_EXPORTS
|
||||
#else // !WIN32
|
||||
#if defined( OPENVR_API_EXPORTS )
|
||||
#define S_API extern "C"
|
||||
#else
|
||||
#define S_API extern "C"
|
||||
#endif // OPENVR_API_EXPORTS
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include "openvr.h"
|
||||
#include "ivrsystem.h"
|
||||
#include "ivrcameraaccess.h"
|
||||
#include "ivrchaperone.h"
|
||||
#include "ivrchaperonesetup.h"
|
||||
#include "ivrcompositor.h"
|
||||
|
||||
|
||||
S_API void VR_IVRSystem_GetWindowBounds(intptr_t instancePtr, int32_t * pnX, int32_t * pnY, uint32_t * pnWidth, uint32_t * pnHeight);
|
||||
S_API void VR_IVRSystem_GetRecommendedRenderTargetSize(intptr_t instancePtr, uint32_t * pnWidth, uint32_t * pnHeight);
|
||||
S_API void VR_IVRSystem_GetEyeOutputViewport(intptr_t instancePtr, vr::Hmd_Eye eEye, uint32_t * pnX, uint32_t * pnY, uint32_t * pnWidth, uint32_t * pnHeight);
|
||||
S_API struct vr::HmdMatrix44_t VR_IVRSystem_GetProjectionMatrix(intptr_t instancePtr, vr::Hmd_Eye eEye, float fNearZ, float fFarZ, vr::GraphicsAPIConvention eProjType);
|
||||
S_API void VR_IVRSystem_GetProjectionRaw(intptr_t instancePtr, vr::Hmd_Eye eEye, float * pfLeft, float * pfRight, float * pfTop, float * pfBottom);
|
||||
S_API struct vr::DistortionCoordinates_t VR_IVRSystem_ComputeDistortion(intptr_t instancePtr, vr::Hmd_Eye eEye, float fU, float fV);
|
||||
S_API struct vr::HmdMatrix34_t VR_IVRSystem_GetEyeToHeadTransform(intptr_t instancePtr, vr::Hmd_Eye eEye);
|
||||
S_API bool VR_IVRSystem_GetTimeSinceLastVsync(intptr_t instancePtr, float * pfSecondsSinceLastVsync, uint64_t * pulFrameCounter);
|
||||
S_API int32_t VR_IVRSystem_GetD3D9AdapterIndex(intptr_t instancePtr);
|
||||
S_API void VR_IVRSystem_GetDXGIOutputInfo(intptr_t instancePtr, int32_t * pnAdapterIndex, int32_t * pnAdapterOutputIndex);
|
||||
S_API bool VR_IVRSystem_AttachToWindow(intptr_t instancePtr, void * hWnd);
|
||||
S_API void VR_IVRSystem_GetDeviceToAbsoluteTrackingPose(intptr_t instancePtr, vr::TrackingUniverseOrigin eOrigin, float fPredictedSecondsToPhotonsFromNow, struct vr::TrackedDevicePose_t * pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount);
|
||||
S_API void VR_IVRSystem_ResetSeatedZeroPose(intptr_t instancePtr);
|
||||
S_API struct vr::HmdMatrix34_t VR_IVRSystem_GetSeatedZeroPoseToStandingAbsoluteTrackingPose(intptr_t instancePtr);
|
||||
S_API bool VR_IVRSystem_LoadRenderModel(intptr_t instancePtr, const char * pchRenderModelName, struct vr::RenderModel_t * pRenderModel);
|
||||
S_API void VR_IVRSystem_FreeRenderModel(intptr_t instancePtr, struct vr::RenderModel_t * pRenderModel);
|
||||
S_API vr::TrackedDeviceClass VR_IVRSystem_GetTrackedDeviceClass(intptr_t instancePtr, vr::TrackedDeviceIndex_t unDeviceIndex);
|
||||
S_API bool VR_IVRSystem_IsTrackedDeviceConnected(intptr_t instancePtr, vr::TrackedDeviceIndex_t unDeviceIndex);
|
||||
S_API bool VR_IVRSystem_GetBoolTrackedDeviceProperty(intptr_t instancePtr, vr::TrackedDeviceIndex_t unDeviceIndex, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError * pError);
|
||||
S_API float VR_IVRSystem_GetFloatTrackedDeviceProperty(intptr_t instancePtr, vr::TrackedDeviceIndex_t unDeviceIndex, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError * pError);
|
||||
S_API int32_t VR_IVRSystem_GetInt32TrackedDeviceProperty(intptr_t instancePtr, vr::TrackedDeviceIndex_t unDeviceIndex, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError * pError);
|
||||
S_API uint64_t VR_IVRSystem_GetUint64TrackedDeviceProperty(intptr_t instancePtr, vr::TrackedDeviceIndex_t unDeviceIndex, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError * pError);
|
||||
S_API struct vr::HmdMatrix34_t VR_IVRSystem_GetMatrix34TrackedDeviceProperty(intptr_t instancePtr, vr::TrackedDeviceIndex_t unDeviceIndex, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError * pError);
|
||||
S_API uint32_t VR_IVRSystem_GetStringTrackedDeviceProperty(intptr_t instancePtr, vr::TrackedDeviceIndex_t unDeviceIndex, vr::TrackedDeviceProperty prop, char * pchValue, uint32_t unBufferSize, vr::TrackedPropertyError * pError);
|
||||
S_API const char * VR_IVRSystem_GetPropErrorNameFromEnum(intptr_t instancePtr, vr::TrackedPropertyError error);
|
||||
S_API bool VR_IVRSystem_PollNextEvent(intptr_t instancePtr, struct vr::VREvent_t * pEvent);
|
||||
S_API bool VR_IVRSystem_PollNextEventWithPose(intptr_t instancePtr, vr::TrackingUniverseOrigin eOrigin, vr::VREvent_t * pEvent, vr::TrackedDevicePose_t * pTrackedDevicePose);
|
||||
S_API const char * VR_IVRSystem_GetEventTypeNameFromEnum(intptr_t instancePtr, vr::EVREventType eType);
|
||||
S_API struct vr::HiddenAreaMesh_t VR_IVRSystem_GetHiddenAreaMesh(intptr_t instancePtr, vr::Hmd_Eye eEye);
|
||||
S_API bool VR_IVRSystem_GetControllerState(intptr_t instancePtr, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t * pControllerState);
|
||||
S_API bool VR_IVRSystem_GetControllerStateWithPose(intptr_t instancePtr, vr::TrackingUniverseOrigin eOrigin, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t * pControllerState, struct vr::TrackedDevicePose_t * pTrackedDevicePose);
|
||||
S_API void VR_IVRSystem_TriggerHapticPulse(intptr_t instancePtr, vr::TrackedDeviceIndex_t unControllerDeviceIndex, uint32_t unAxisId, unsigned short usDurationMicroSec);
|
||||
S_API const char * VR_IVRSystem_GetButtonIdNameFromEnum(intptr_t instancePtr, vr::EVRButtonId eButtonId);
|
||||
S_API const char * VR_IVRSystem_GetControllerAxisTypeNameFromEnum(intptr_t instancePtr, vr::EVRControllerAxisType eAxisType);
|
||||
S_API bool VR_IVRSystem_HandleControllerOverlayInteractionAsMouse(intptr_t instancePtr, const vr::Compositor_OverlaySettings & overlaySettings, vr::HmdVector2_t vecWindowClientPositionOnScreen, vr::HmdVector2_t vecWindowClientSize, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::EVRControllerEventOutputType eOutputType);
|
||||
S_API bool VR_IVRSystem_CaptureInputFocus(intptr_t instancePtr);
|
||||
S_API void VR_IVRSystem_ReleaseInputFocus(intptr_t instancePtr);
|
||||
S_API bool VR_IVRSystem_IsInputFocusCapturedByAnotherProcess(intptr_t instancePtr);
|
||||
S_API uint32_t VR_IVRCameraAccess_GetCameraCount(intptr_t instancePtr);
|
||||
S_API uint32_t VR_IVRCameraAccess_GetCameraId(intptr_t instancePtr, uint32_t unCameraIndex, char * pchBuffer, uint32_t unBufferLen);
|
||||
S_API bool VR_IVRCameraAccess_EnableCamera(intptr_t instancePtr, uint32_t unCameraIndex, bool bEnabled);
|
||||
S_API bool VR_IVRCameraAccess_GetCameraInfo(intptr_t instancePtr, uint32_t unCameraIndex, struct vr::CameraInfo_t * pCameraInfo);
|
||||
S_API bool VR_IVRCameraAccess_GetCameraImage(intptr_t instancePtr, uint32_t unCameraIndex, struct vr::CameraImage_t * pCameraImage);
|
||||
S_API vr::ChaperoneCalibrationState VR_IVRChaperone_GetCalibrationState(intptr_t instancePtr);
|
||||
S_API bool VR_IVRChaperone_GetSoftBoundsInfo(intptr_t instancePtr, struct vr::ChaperoneSoftBoundsInfo_t * pInfo);
|
||||
S_API bool VR_IVRChaperone_GetHardBoundsInfo(intptr_t instancePtr, struct vr::HmdQuad_t * pQuadsBuffer, uint32_t * punQuadsCount);
|
||||
S_API bool VR_IVRChaperone_GetSeatedBoundsInfo(intptr_t instancePtr, struct vr::ChaperoneSeatedBoundsInfo_t * pInfo);
|
||||
S_API bool VR_IVRChaperoneSetup_CommitWorkingCopy(intptr_t instancePtr, const char * pchCalibrationName);
|
||||
S_API void VR_IVRChaperoneSetup_RevertWorkingCopy(intptr_t instancePtr);
|
||||
S_API bool VR_IVRChaperoneSetup_GetWorkingSoftBoundsInfo(intptr_t instancePtr, struct vr::ChaperoneSoftBoundsInfo_t * pInfo);
|
||||
S_API bool VR_IVRChaperoneSetup_GetWorkingHardBoundsInfo(intptr_t instancePtr, struct vr::HmdQuad_t * pQuadsBuffer, uint32_t * punQuadsCount);
|
||||
S_API bool VR_IVRChaperoneSetup_GetWorkingSeatedZeroPoseToRawTrackingPose(intptr_t instancePtr, struct vr::HmdMatrix34_t * pmatSeatedZeroPoseToRawTrackingPose);
|
||||
S_API bool VR_IVRChaperoneSetup_GetWorkingStandingZeroPoseToRawTrackingPose(intptr_t instancePtr, struct vr::HmdMatrix34_t * pmatStandingZeroPoseToRawTrackingPose);
|
||||
S_API void VR_IVRChaperoneSetup_SetWorkingSoftBoundsInfo(intptr_t instancePtr, const struct vr::ChaperoneSoftBoundsInfo_t * pInfo);
|
||||
S_API void VR_IVRChaperoneSetup_SetWorkingHardBoundsInfo(intptr_t instancePtr, struct vr::HmdQuad_t * pQuadsBuffer, uint32_t unQuadsCount);
|
||||
S_API void VR_IVRChaperoneSetup_SetWorkingSeatedZeroPoseToRawTrackingPose(intptr_t instancePtr, const struct vr::HmdMatrix34_t & matSeatedZeroPoseToRawTrackingPose);
|
||||
S_API void VR_IVRChaperoneSetup_SetWorkingStandingZeroPoseToRawTrackingPose(intptr_t instancePtr, const struct vr::HmdMatrix34_t & matStandingZeroPoseToRawTrackingPose);
|
||||
S_API uint32_t VR_IVRCompositor_GetLastError(intptr_t instancePtr, char * pchBuffer, uint32_t unBufferSize);
|
||||
S_API void VR_IVRCompositor_SetVSync(intptr_t instancePtr, bool bVSync);
|
||||
S_API bool VR_IVRCompositor_GetVSync(intptr_t instancePtr);
|
||||
S_API void VR_IVRCompositor_SetGamma(intptr_t instancePtr, float fGamma);
|
||||
S_API float VR_IVRCompositor_GetGamma(intptr_t instancePtr);
|
||||
S_API void VR_IVRCompositor_SetGraphicsDevice(intptr_t instancePtr, vr::Compositor_DeviceType eType, void * pDevice);
|
||||
S_API void VR_IVRCompositor_WaitGetPoses(intptr_t instancePtr, struct vr::TrackedDevicePose_t * pPoseArray, uint32_t unPoseArrayCount);
|
||||
S_API void VR_IVRCompositor_Submit(intptr_t instancePtr, vr::Hmd_Eye eEye, void * pTexture, struct vr::Compositor_TextureBounds * pBounds);
|
||||
S_API void VR_IVRCompositor_ClearLastSubmittedFrame(intptr_t instancePtr);
|
||||
S_API void VR_IVRCompositor_GetOverlayDefaults(intptr_t instancePtr, struct vr::Compositor_OverlaySettings * pSettings);
|
||||
S_API void VR_IVRCompositor_SetOverlay(intptr_t instancePtr, void * pTexture, struct vr::Compositor_OverlaySettings * pSettings);
|
||||
S_API void VR_IVRCompositor_SetOverlayRaw(intptr_t instancePtr, void * buffer, uint32_t width, uint32_t height, uint32_t depth, struct vr::Compositor_OverlaySettings * pSettings);
|
||||
S_API void VR_IVRCompositor_SetOverlayFromFile(intptr_t instancePtr, const char * pchFilePath, struct vr::Compositor_OverlaySettings * pSettings);
|
||||
S_API void VR_IVRCompositor_ClearOverlay(intptr_t instancePtr);
|
||||
S_API bool VR_IVRCompositor_GetFrameTiming(intptr_t instancePtr, struct vr::Compositor_FrameTiming * pTiming, uint32_t unFramesAgo);
|
||||
S_API void VR_IVRCompositor_FadeToColor(intptr_t instancePtr, float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, bool bBackground);
|
||||
S_API void VR_IVRCompositor_FadeGrid(intptr_t instancePtr, float fSeconds, bool bFadeIn);
|
||||
S_API void VR_IVRCompositor_CompositorBringToFront(intptr_t instancePtr);
|
||||
S_API void VR_IVRCompositor_CompositorGoToBack(intptr_t instancePtr);
|
||||
S_API void VR_IVRCompositor_CompositorQuit(intptr_t instancePtr);
|
||||
S_API bool VR_IVRCompositor_IsFullscreen(intptr_t instancePtr);
|
||||
S_API bool VR_IVRCompositor_ComputeOverlayIntersection(intptr_t instancePtr, const struct vr::Compositor_OverlaySettings * pSettings, float fAspectRatio, vr::TrackingUniverseOrigin eOrigin, vr::HmdVector3_t vSource, vr::HmdVector3_t vDirection, vr::HmdVector2_t * pvecIntersectionUV, vr::HmdVector3_t * pvecIntersectionTrackingSpace);
|
||||
S_API void VR_IVRCompositor_SetTrackingSpace(intptr_t instancePtr, vr::TrackingUniverseOrigin eOrigin);
|
||||
S_API vr::TrackingUniverseOrigin VR_IVRCompositor_GetTrackingSpace(intptr_t instancePtr);
|
||||
#endif // __OPENVR_API_FLAT_H__
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ CSourceVirtualReality::CSourceVirtualReality()
|
||||
m_textureGeneratorRight( vr::Eye_Right )
|
||||
{
|
||||
m_bActive = false;
|
||||
m_bUsingOffscreenRenderTarget = false;
|
||||
m_bUsingOffscreenRenderTarget = true;
|
||||
m_pHmd = NULL;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -420,8 +424,9 @@ 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 );
|
||||
uint32_t x = 0, y = 0, w = 640, h = 480;
|
||||
// m_pHmd->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
|
||||
m_pExtDisplay->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
|
||||
if( pnX && pnY )
|
||||
{
|
||||
*pnX = x;
|
||||
@@ -446,14 +451,14 @@ VMatrix CSourceVirtualReality::GetMideyePose()
|
||||
// ----------------------------------------------------------------------
|
||||
inline static void ComposeProjectionTransform(float fLeft, float fRight, float fTop, float fBottom, float zNear, float zFar, float fovScale, VMatrix *pmProj )
|
||||
{
|
||||
if( fovScale != 1.0f && fovScale > 0.f )
|
||||
/*if( fovScale != 1.0f && fovScale > 0.f )
|
||||
{
|
||||
float fFovScaleAdjusted = tan( atan( fTop ) / fovScale ) / fTop;
|
||||
fRight *= fFovScaleAdjusted;
|
||||
fLeft *= fFovScaleAdjusted;
|
||||
fTop *= fFovScaleAdjusted;
|
||||
fBottom *= fFovScaleAdjusted;
|
||||
}
|
||||
}*/
|
||||
|
||||
float idx = 1.0f / (fRight - fLeft);
|
||||
float idy = 1.0f / (fBottom - fTop);
|
||||
@@ -530,15 +535,21 @@ 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 )
|
||||
{
|
||||
if( !m_pHmd || !m_bActive )
|
||||
return false;
|
||||
|
||||
vr::VREvent_t event;
|
||||
while( m_pHmd->PollNextEvent( &event, sizeof( event ) ) )
|
||||
{
|
||||
//ProcessVREvent( event );
|
||||
}
|
||||
vr::TrackedDevicePose_t m_rTrackedDevicePose[ vr::k_unMaxTrackedDeviceCount ];
|
||||
vr::VRCompositor()->WaitGetPoses(m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, NULL, 0 );
|
||||
// If tracker can't return a pose (it's possibly recalibrating itself)
|
||||
// then we will freeze tracking at its current state, rather than
|
||||
// snapping it back to the zero position
|
||||
@@ -572,6 +583,7 @@ bool CSourceVirtualReality::SampleTrackingState ( float PlayerGameFov, float fPr
|
||||
|
||||
return true;
|
||||
}
|
||||
#include "togl/rendermechanism.h"
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -589,10 +601,16 @@ bool CSourceVirtualReality::DoDistortionProcessing ( VREye eEye )
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
|
||||
IMaterial *pDistortMaterial;
|
||||
ITexture *pDistortTexture;
|
||||
|
||||
if( eEye == VREye_Left )
|
||||
pDistortMaterial = m_DistortLeftMaterial;
|
||||
else
|
||||
pDistortMaterial = m_DistortRightMaterial;
|
||||
if( eEye == VREye_Left )
|
||||
pDistortTexture = m_pDistortionTextureLeft;
|
||||
else
|
||||
pDistortTexture = m_pDistortionTextureRight;
|
||||
|
||||
if( !UsingOffscreenRenderTarget() )
|
||||
{
|
||||
@@ -602,17 +620,48 @@ bool CSourceVirtualReality::DoDistortionProcessing ( VREye eEye )
|
||||
return false;
|
||||
|
||||
Rect_t r;
|
||||
r.x = !eEye?0:640;
|
||||
r.y = 0;
|
||||
r.width = 640;
|
||||
r.height = 480;
|
||||
this->GetViewportBounds( eEye, &r.x, &r.y, &r.width, &r.height );
|
||||
pRenderContext->CopyRenderTargetToTextureEx( pFullFrameFB1, 0, &r, &r );
|
||||
}
|
||||
|
||||
// This is where we are rendering to
|
||||
uint32_t x, y, w, h;
|
||||
m_pHmd->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
|
||||
x = !eEye?0:640;
|
||||
y = 0;
|
||||
w = 640;
|
||||
h = 480;
|
||||
//m_pExtDisplay->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
|
||||
|
||||
pRenderContext->DrawScreenSpaceRectangle ( pDistortMaterial,
|
||||
x, y, w, h,
|
||||
0, 0, distortionTextureSize-1,distortionTextureSize-1,distortionTextureSize,distortionTextureSize);
|
||||
// pRenderContext->DrawScreenSpaceRectangle ( pDistortMaterial,
|
||||
// x, y, w, h,
|
||||
// 0, 0, distortionTextureSize-1,distortionTextureSize-1,distortionTextureSize,distortionTextureSize);
|
||||
|
||||
static int id = -1;
|
||||
//static CDynamicFunctionOpenGL< true, GLvoid ( APIENTRY *)(GLenum pname, GLint *params), GLvoid > glGetIntegerv("glGetIntegerv");
|
||||
// pRenderContext->Bind(pDistortMaterial);
|
||||
// pRenderContext->Flush( true );
|
||||
// ShaderAPITextureHandle_t hndl = materials->GetShaderAPITextureBindHandle(pDistortTexture,0,0);
|
||||
//if(id < 0)
|
||||
id = materials->GetShaderAPIGLTexture(m_pPredistortRT,0,0);
|
||||
|
||||
static int last_tex[2] = {-1, -1};
|
||||
// glGetIntegerv(GL_TEXTURE_BINDING_2D, &id);
|
||||
if(id > 0)
|
||||
last_tex[eEye != VREye_Left] = id;
|
||||
// Msg("tex %d\n", id);
|
||||
const vr::VRTextureBounds_t bounds = { 0.0f, 1.0f, 1.0f, 0.0f };
|
||||
vr::Texture_t eyeTexture = {(void*)(uintptr_t)last_tex[eEye != VREye_Left], vr::TextureType_OpenGL, vr::ColorSpace_Gamma };
|
||||
if(last_tex[eEye != VREye_Left] <= 0)
|
||||
return true;
|
||||
materials->Flush();
|
||||
// if(eEye != VREye_Left)
|
||||
// return 0;
|
||||
glFinish();
|
||||
vr::VRCompositor()->Submit(SourceEyeToHmdEye( eEye ), &eyeTexture, &bounds );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -682,11 +731,20 @@ 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 );
|
||||
x = !eEye?0:640;
|
||||
y = 0;
|
||||
w = 640;
|
||||
h = 480;
|
||||
m_pExtDisplay->GetEyeOutputViewport( SourceEyeToHmdEye( eEye ), &x, &y, &w, &h );
|
||||
int id = materials->GetShaderAPIGLTexture(g_StereoGuiTexture,0,0);
|
||||
vr::Texture_t guiTexture = {(void*)(uintptr_t)id, vr::TextureType_OpenGL, vr::ColorSpace_Gamma };
|
||||
const vr::VRTextureBounds_t bounds = { 0.0f, 1.0f, 1.0f, 0.0f };
|
||||
vr::VROverlay()->SetOverlayTextureBounds(m_GuiOverlay, &bounds);
|
||||
vr::VROverlay()->SetOverlayTexture(m_GuiOverlay, &guiTexture);
|
||||
|
||||
pRenderContext->DrawScreenSpaceRectangle ( pDistortHUDMaterial,
|
||||
x, y, w, h,
|
||||
0, 0, distortionTextureSize-1,distortionTextureSize-1,distortionTextureSize,distortionTextureSize);
|
||||
// pRenderContext->DrawScreenSpaceRectangle ( pDistortHUDMaterial,
|
||||
// x, y, w, h,
|
||||
// 0, 0, distortionTextureSize-1,distortionTextureSize-1,distortionTextureSize,distortionTextureSize);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -706,14 +764,22 @@ 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();
|
||||
if( !vr::VRCompositor() )
|
||||
{
|
||||
Msg("Compositor initialization failed. See log file for details");
|
||||
}
|
||||
vr::VROverlay()->CreateOverlay("GuiOverlayKey", "GuiOverlay", &m_GuiOverlay);
|
||||
vr::VROverlay()->ShowOverlay(m_GuiOverlay);
|
||||
m_pChap->ResetZeroPose(TrackingUniverseSeated);
|
||||
|
||||
m_bHaveValidPose = false;
|
||||
m_ZeroFromHeadPose.Identity();
|
||||
|
||||
@@ -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;
|
||||
|
||||
50
sourcevr/wscript
Executable file
50
sourcevr/wscript
Executable file
@@ -0,0 +1,50 @@
|
||||
#! /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'])
|
||||
conf.check(lib='GL', uselib_store='GL')
|
||||
|
||||
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', 'GL']
|
||||
|
||||
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()
|
||||
)
|
||||
|
||||
9
wscript
9
wscript
@@ -79,6 +79,7 @@ projects={
|
||||
'utils/vtex',
|
||||
'unicode',
|
||||
'video',
|
||||
'sourcevr'
|
||||
],
|
||||
'tests': [
|
||||
'appframework',
|
||||
@@ -358,10 +359,10 @@ def check_deps(conf):
|
||||
else:
|
||||
conf.check_pkg('freetype2', 'FT2', FT2_CHECK)
|
||||
conf.check_pkg('fontconfig', 'FC', FC_CHECK)
|
||||
if conf.env.DEST_OS == "darwin":
|
||||
conf.env.FRAMEWORK_OPENAL = "OpenAL"
|
||||
else:
|
||||
conf.check_cfg(package='openal', uselib_store='OPENAL', args=['--cflags', '--libs'])
|
||||
# if conf.env.DEST_OS == "darwin":
|
||||
# conf.env.FRAMEWORK_OPENAL = "OpenAL"
|
||||
# else:
|
||||
# conf.check_cfg(package='openal', uselib_store='OPENAL', args=['--cflags', '--libs'])
|
||||
conf.check_cfg(package='libjpeg', uselib_store='JPEG', args=['--cflags', '--libs'])
|
||||
conf.check_cfg(package='libpng', uselib_store='PNG', args=['--cflags', '--libs'])
|
||||
conf.check_cfg(package='libcurl', uselib_store='CURL', args=['--cflags', '--libs'])
|
||||
|
||||
Reference in New Issue
Block a user