mirror of
https://github.com/rlabrecque/SteamworksSDK.git
synced 2026-10-10 01:23:04 +08:00
v1.28
This commit is contained in:
+10
-1
@@ -1,6 +1,6 @@
|
||||
================================================================
|
||||
|
||||
Copyright © 1996-2012, Valve Corporation, All rights reserved.
|
||||
Copyright © 1996-2014, Valve Corporation, All rights reserved.
|
||||
|
||||
================================================================
|
||||
|
||||
@@ -11,6 +11,15 @@ website at: http://partner.steamgames.com
|
||||
|
||||
Revision History:
|
||||
|
||||
----------------------------------------------------------------
|
||||
v1.28 28th January 2014
|
||||
----------------------------------------------------------------
|
||||
|
||||
* Added Steamworks Virtual Reality API via steamvr.h.
|
||||
* Added ISteamUtils::IsSteamRunningInVRMode, which returns true if the Steam Client is running in VR mode.
|
||||
* Deprecated ISteamGameserver::GetGameplayStats and ISteamGameserver::GetServerReputation. These calls already return no data and will be removed in a future SDK update.
|
||||
* Added result code k_EResultRateLimitExceeded, which can now be returned if a user has too many outstanding friend requests.
|
||||
|
||||
----------------------------------------------------------------
|
||||
v1.26a 14th November 2013
|
||||
----------------------------------------------------------------
|
||||
|
||||
@@ -37,6 +37,9 @@ typedef int HGAMEVOICECHANNEL;
|
||||
#define VOICE_OUTPUT_SAMPLE_RATE_IDEAL 11025
|
||||
#define BYTES_PER_SAMPLE 2
|
||||
|
||||
// used for VR support
|
||||
namespace vr { class IHmd; }
|
||||
|
||||
//
|
||||
// Interface that needs to be implemented for game engines on all platforms
|
||||
//
|
||||
|
||||
@@ -78,7 +78,7 @@ extern "C" void __cdecl SteamAPIDebugTextHook( int nSeverity, const char *pchDeb
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Extracts some feature from the command line
|
||||
//-----------------------------------------------------------------------------
|
||||
void ParseCommandLine( const char *pchCmdLine, const char **ppchServerAddress, const char **ppchLobbyID )
|
||||
void ParseCommandLine( const char *pchCmdLine, const char **ppchServerAddress, const char **ppchLobbyID, bool *pbUseVR )
|
||||
{
|
||||
// Look for the +connect ipaddress:port parameter in the command line,
|
||||
// Steam will pass this when a user has used the Steam Server browser to find
|
||||
@@ -102,6 +102,12 @@ void ParseCommandLine( const char *pchCmdLine, const char **ppchServerAddress, c
|
||||
// Address should be right after the +connect, +1 on the end to skip the space
|
||||
*ppchLobbyID = pchCmdLine + ( pchConnectLobby - pchCmdLine ) + strlen( pchConnectLobbyParam ) + 1;
|
||||
}
|
||||
|
||||
// look for -vr on command line. Switch to VR mode if it's thre
|
||||
const char *pchVRParam = "-vr";
|
||||
const char *pchVR = strstr( pchCmdLine, pchVRParam );
|
||||
if ( pchVR )
|
||||
*pbUseVR = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -221,16 +227,20 @@ static int RealMain( const char *pchCmdLine, HINSTANCE hInstance, int nCmdShow )
|
||||
#endif
|
||||
SteamController()->Init( rgchFullPath );
|
||||
|
||||
bool bUseVR = false;
|
||||
const char *pchServerAddress, *pchLobbyID;
|
||||
ParseCommandLine( pchCmdLine, &pchServerAddress, &pchLobbyID );
|
||||
ParseCommandLine( pchCmdLine, &pchServerAddress, &pchLobbyID, &bUseVR );
|
||||
|
||||
// do a DRM self check
|
||||
Steamworks_SelfCheck();
|
||||
|
||||
// init VR before we make the window
|
||||
|
||||
// Construct a new instance of the game engine
|
||||
// bugbug jmccaskey - make screen resolution dynamic, maybe take it on command line?
|
||||
IGameEngine *pGameEngine =
|
||||
#if defined(_WIN32)
|
||||
new CGameEngineWin32( hInstance, nCmdShow, 1024, 768 );
|
||||
new CGameEngineWin32( hInstance, nCmdShow, 1024, 768, bUseVR );
|
||||
#elif defined(OSX)
|
||||
CreateGameEngineOSX();
|
||||
#elif defined(SDL)
|
||||
|
||||
@@ -762,8 +762,9 @@ void CSpaceWarClient::OnGameJoinRequested( GameRichPresenceJoinRequested_t *pCal
|
||||
{
|
||||
// parse out the connect
|
||||
const char *pchServerAddress, *pchLobbyID;
|
||||
extern void ParseCommandLine( const char *pchCmdLine, const char **ppchServerAddress, const char **ppchLobbyID );
|
||||
ParseCommandLine( pCallback->m_rgchConnect, &pchServerAddress, &pchLobbyID );
|
||||
bool bUseVR = false;
|
||||
extern void ParseCommandLine( const char *pchCmdLine, const char **ppchServerAddress, const char **ppchLobbyID, bool *pbUseVR );
|
||||
ParseCommandLine( pCallback->m_rgchConnect, &pchServerAddress, &pchLobbyID, &bUseVR );
|
||||
|
||||
// exec
|
||||
ExecCommandLineConnect( pchServerAddress, pchLobbyID );
|
||||
|
||||
Binary file not shown.
+62
-43
@@ -240,6 +240,7 @@ enum { k_iClientRemoteClientManagerCallbacks = 3300 };
|
||||
enum { k_iClientUGCCallbacks = 3400 };
|
||||
enum { k_iSteamStreamClientCallbacks = 3500 };
|
||||
enum { k_IClientProductBuilderCallbacks = 3600 };
|
||||
enum { k_iClientShortcutsCallbacks = 3700 };
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -248,21 +249,18 @@ enum { k_IClientProductBuilderCallbacks = 3600 };
|
||||
// Do not change any of these.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CSteamCallback
|
||||
struct SteamCallback_t
|
||||
{
|
||||
public:
|
||||
virtual const char *GetCallbackName() const = 0;
|
||||
virtual uint32 GetCallbackID() const = 0;
|
||||
virtual uint8 *GetFixedData() const = 0;
|
||||
virtual uint32 GetFixedSize() const = 0;
|
||||
virtual uint32 GetNumMemberVariables() const = 0;
|
||||
virtual bool GetMemberVariable( uint32 index, uint32 &varOffset, uint32 &varSize, uint32 &varCount, const char **pszName, const char **pszType ) const = 0;
|
||||
SteamCallback_t() {}
|
||||
};
|
||||
|
||||
#define DEFINE_CALLBACK( callbackname, callbackid ) \
|
||||
struct callbackname##_t { \
|
||||
struct callbackname : SteamCallback_t { \
|
||||
enum { k_iCallback = callbackid }; \
|
||||
static callbackname##_t *GetNullPointer() { return 0; }
|
||||
static callbackname *GetNullPointer() { return 0; } \
|
||||
static const char *GetCallbackName() { return #callbackname; } \
|
||||
static uint32 GetCallbackID() { return callbackname::k_iCallback; }
|
||||
|
||||
#define CALLBACK_MEMBER( varidx, vartype, varname ) \
|
||||
public: vartype varname ; \
|
||||
@@ -281,64 +279,60 @@ struct callbackname##_t { \
|
||||
*pszName = #varname; *pszType = #vartype; }
|
||||
|
||||
|
||||
#define END_CALLBACK_INTERNAL_BEGIN( callbackname, numvars ) }; \
|
||||
class C##callbackname : public CSteamCallback { \
|
||||
public: callbackname##_t m_Data; \
|
||||
C##callbackname () { memset( &m_Data, 0, sizeof(m_Data) ); } \
|
||||
virtual const char *GetCallbackName() const { return #callbackname; } \
|
||||
virtual uint32 GetCallbackID() const { return callbackname##_t::k_iCallback; } \
|
||||
virtual uint32 GetFixedSize() const { return sizeof( m_Data ); } \
|
||||
virtual uint8 *GetFixedData() const { return (uint8*)&m_Data; } \
|
||||
virtual uint32 GetNumMemberVariables() const { return numvars; } \
|
||||
virtual bool GetMemberVariable( uint32 index, uint32 &varOffset, uint32 &varSize, uint32 &varCount, const char **pszName, const char **pszType ) const { \
|
||||
#define END_CALLBACK_INTERNAL_BEGIN( numvars ) \
|
||||
static uint32 GetNumMemberVariables() { return numvars; } \
|
||||
static bool GetMemberVariable( uint32 index, uint32 &varOffset, uint32 &varSize, uint32 &varCount, const char **pszName, const char **pszType ) { \
|
||||
switch ( index ) { default : return false;
|
||||
|
||||
|
||||
#define END_CALLBACK_INTERNAL_SWITCH( varidx ) case varidx : m_Data.GetMemberVar_##varidx( varOffset, varSize, varCount, pszName, pszType ); return true;
|
||||
#define END_CALLBACK_INTERNAL_SWITCH( varidx ) case varidx : GetMemberVar_##varidx( varOffset, varSize, varCount, pszName, pszType ); return true;
|
||||
|
||||
#define END_CALLBACK_INTERNAL_END() }; }; };
|
||||
#define END_CALLBACK_INTERNAL_END() }; } };
|
||||
|
||||
#define END_DEFINE_CALLBACK_0( callbackname ) }; \
|
||||
class C##callbackname : public CSteamCallback { \
|
||||
public: callbackname##_t m_Data; \
|
||||
virtual const char *GetCallbackName() const { return #callbackname; } \
|
||||
virtual uint32 GetCallbackID() const { return callbackname##_t::k_iCallback; } \
|
||||
virtual uint32 GetFixedSize() const { return sizeof( m_Data ); } \
|
||||
virtual uint8 *GetFixedData() const { return (uint8*)&m_Data; } \
|
||||
virtual uint32 GetNumMemberVariables() const { return 0; } \
|
||||
virtual bool GetMemberVariable( uint32 index, uint32 &varOffset, uint32 &varSize, uint32 &varCount, const char **pszName, const char **pszType ) const { return false; } \
|
||||
}; \
|
||||
#define END_DEFINE_CALLBACK_0() \
|
||||
static uint32 GetNumMemberVariables() { return 0; } \
|
||||
static bool GetMemberVariable( uint32 index, uint32 &varOffset, uint32 &varSize, uint32 &varCount, const char **pszName, const char **pszType ) { return false; } \
|
||||
};
|
||||
|
||||
|
||||
#define END_DEFINE_CALLBACK_1( callbackname ) \
|
||||
END_CALLBACK_INTERNAL_BEGIN( callbackname, 1 ) \
|
||||
#define END_DEFINE_CALLBACK_1() \
|
||||
END_CALLBACK_INTERNAL_BEGIN( 1 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 0 ) \
|
||||
END_CALLBACK_INTERNAL_END()
|
||||
|
||||
#define END_DEFINE_CALLBACK_2( callbackname ) \
|
||||
END_CALLBACK_INTERNAL_BEGIN( callbackname, 2 ) \
|
||||
#define END_DEFINE_CALLBACK_2() \
|
||||
END_CALLBACK_INTERNAL_BEGIN( 2 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 0 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 1 ) \
|
||||
END_CALLBACK_INTERNAL_END()
|
||||
|
||||
#define END_DEFINE_CALLBACK_3( callbackname ) \
|
||||
END_CALLBACK_INTERNAL_BEGIN( callbackname, 3 ) \
|
||||
#define END_DEFINE_CALLBACK_3() \
|
||||
END_CALLBACK_INTERNAL_BEGIN( 3 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 0 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 1 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 2 ) \
|
||||
END_CALLBACK_INTERNAL_END()
|
||||
|
||||
#define END_DEFINE_CALLBACK_4( callbackname ) \
|
||||
END_CALLBACK_INTERNAL_BEGIN( callbackname, 4 ) \
|
||||
#define END_DEFINE_CALLBACK_4() \
|
||||
END_CALLBACK_INTERNAL_BEGIN( 4 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 0 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 1 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 2 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 3 ) \
|
||||
END_CALLBACK_INTERNAL_END()
|
||||
|
||||
#define END_DEFINE_CALLBACK_5() \
|
||||
END_CALLBACK_INTERNAL_BEGIN( 4 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 0 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 1 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 2 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 3 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 4 ) \
|
||||
END_CALLBACK_INTERNAL_END()
|
||||
|
||||
#define END_DEFINE_CALLBACK_6( callbackname ) \
|
||||
END_CALLBACK_INTERNAL_BEGIN( callbackname, 6 ) \
|
||||
|
||||
#define END_DEFINE_CALLBACK_6() \
|
||||
END_CALLBACK_INTERNAL_BEGIN( 6 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 0 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 1 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 2 ) \
|
||||
@@ -347,8 +341,8 @@ public: callbackname##_t m_Data; \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 5 ) \
|
||||
END_CALLBACK_INTERNAL_END()
|
||||
|
||||
#define END_DEFINE_CALLBACK_7( callbackname ) \
|
||||
END_CALLBACK_INTERNAL_BEGIN( callbackname, 7 ) \
|
||||
#define END_DEFINE_CALLBACK_7() \
|
||||
END_CALLBACK_INTERNAL_BEGIN( 7 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 0 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 1 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 2 ) \
|
||||
@@ -358,4 +352,29 @@ public: callbackname##_t m_Data; \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 6 ) \
|
||||
END_CALLBACK_INTERNAL_END()
|
||||
|
||||
#define END_DEFINE_CALLBACK_8() \
|
||||
END_CALLBACK_INTERNAL_BEGIN( 7 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 0 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 1 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 2 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 3 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 4 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 5 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 6 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 7 ) \
|
||||
END_CALLBACK_INTERNAL_END()
|
||||
|
||||
#define END_DEFINE_CALLBACK_9() \
|
||||
END_CALLBACK_INTERNAL_BEGIN( 7 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 0 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 1 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 2 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 3 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 4 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 5 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 6 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 7 ) \
|
||||
END_CALLBACK_INTERNAL_SWITCH( 8 ) \
|
||||
END_CALLBACK_INTERNAL_END()
|
||||
|
||||
#endif // ISTEAMCLIENT_H
|
||||
|
||||
@@ -192,15 +192,10 @@ public:
|
||||
// returns false if we're not connected to the steam servers and thus cannot ask
|
||||
virtual bool RequestUserGroupStatus( CSteamID steamIDUser, CSteamID steamIDGroup ) = 0;
|
||||
|
||||
//
|
||||
// Query steam for server data
|
||||
//
|
||||
|
||||
// Ask for the gameplay stats for the server. Results returned in a callback
|
||||
// these two functions s are deprecated, and will not return results
|
||||
// they will be removed in a future version of the SDK
|
||||
virtual void GetGameplayStats( ) = 0;
|
||||
|
||||
// Gets the reputation score for the game server. This API also checks if the server or some
|
||||
// other server on the same IP is banned from the Steam master servers.
|
||||
virtual SteamAPICall_t GetServerReputation( ) = 0;
|
||||
|
||||
// Returns the public IP of the server according to Steam, useful when the server is
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
// levels of speech are detected.
|
||||
// nUncompressedVoiceDesiredSampleRate is necessary to know the number of bytes to return in pcbUncompressed - can be set to 0 if you don't need uncompressed (the usual case)
|
||||
// If you're upgrading from an older Steamworks API, you'll want to pass in 11025 to nUncompressedVoiceDesiredSampleRate
|
||||
virtual EVoiceResult GetAvailableVoice(uint32 *pcbCompressed, uint32 *pcbUncompressed, uint32 nUncompressedVoiceDesiredSampleRate) = 0;
|
||||
virtual EVoiceResult GetAvailableVoice( uint32 *pcbCompressed, uint32 *pcbUncompressed, uint32 nUncompressedVoiceDesiredSampleRate ) = 0;
|
||||
|
||||
// Gets the latest voice data from the microphone. Compressed data is an arbitrary format, and is meant to be handed back to
|
||||
// DecompressVoice() for playback later as a binary blob. Uncompressed data is 16-bit, signed integer, 11025Hz PCM format.
|
||||
|
||||
@@ -157,6 +157,9 @@ public:
|
||||
|
||||
// returns the language the steam client is running in, you probably want ISteamApps::GetCurrentGameLanguage instead, this is for very special usage cases
|
||||
virtual const char *GetSteamUILanguage() = 0;
|
||||
|
||||
// returns true if Steam itself is running in VR mode
|
||||
virtual bool IsSteamRunningInVR() = 0;
|
||||
};
|
||||
|
||||
#define STEAMUTILS_INTERFACE_VERSION "SteamUtils006"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -108,6 +108,7 @@ enum EResult
|
||||
k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG server are not valid !
|
||||
k_EResultRestrictedDevice = 82, // The device being used is not allowed to perform this action
|
||||
k_EResultRegionLocked = 83, // The action could not be complete because it is region restricted
|
||||
k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try again later, different from k_EResultLimitExceeded which may be permanent
|
||||
};
|
||||
|
||||
// Error codes for use with the voice functions
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace vr
|
||||
{
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// The 32-bit version of gcc has the alignment requirement for uint64 and double set to
|
||||
// 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
|
||||
// The 64-bit version of gcc has the alignment requirement for these types set to
|
||||
// 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
|
||||
// The 64-bit structure packing has to match the 32-bit structure packing for each platform.
|
||||
#pragma pack( push, 4 )
|
||||
#else
|
||||
#pragma pack( push, 8 )
|
||||
#endif
|
||||
|
||||
|
||||
// right-handed system
|
||||
// +y is up
|
||||
// +x is to the right
|
||||
// -z is going away from you
|
||||
// Distance unit is meters
|
||||
struct HmdMatrix34_t
|
||||
{
|
||||
float m[3][4];
|
||||
};
|
||||
|
||||
struct HmdMatrix44_t
|
||||
{
|
||||
float m[4][4];
|
||||
};
|
||||
|
||||
|
||||
/** Used to return the post-distortion UVs for each color channel.
|
||||
* UVs range from 0 to 1 with 0,0 in the upper left corner of the
|
||||
* source render target. The 0,0 to 1,1 range covers a single eye. */
|
||||
struct DistortionCoordinates_t
|
||||
{
|
||||
float rfRed[2];
|
||||
float rfGreen[2];
|
||||
float rfBlue[2];
|
||||
};
|
||||
|
||||
|
||||
enum Hmd_Eye
|
||||
{
|
||||
Eye_Left = 0,
|
||||
Eye_Right = 1
|
||||
};
|
||||
|
||||
enum GraphicsAPIConvention
|
||||
{
|
||||
API_DirectX = 0, // Normalized Z goes from 0 at the viewer to 1 at the far clip plane
|
||||
API_OpenGL = 1, // Normalized Z goes from 1 at the viewer to -1 at the far clip plane
|
||||
};
|
||||
|
||||
enum HmdTrackingResult
|
||||
{
|
||||
TrackingResult_Uninitialized = 1,
|
||||
|
||||
TrackingResult_Calibrating_InProgress = 100,
|
||||
TrackingResult_Calibrating_OutOfRange = 101,
|
||||
|
||||
TrackingResult_Running_OK = 200,
|
||||
TrackingResult_Running_OutOfRange = 201,
|
||||
};
|
||||
|
||||
class IHmd
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// Display Methods
|
||||
// ------------------------------------
|
||||
|
||||
/** Size and position that the window needs to be on the VR display. */
|
||||
virtual bool GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
|
||||
|
||||
/** Suggested size for the intermediate render target that the distortion pulls from. */
|
||||
virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
|
||||
|
||||
/** Gets the viewport in the frame buffer to draw the output of the disortion into */
|
||||
virtual void GetEyeOutputViewport( Hmd_Eye eEye, GraphicsAPIConvention eAPIType, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
|
||||
|
||||
/** The projection matrix for the specified eye */
|
||||
virtual HmdMatrix44_t GetProjectionMatrix( Hmd_Eye eEye, float fNearZ, float fFarZ, GraphicsAPIConvention eProjType ) = 0;
|
||||
|
||||
/** The components necessary to build your own projection matrix in case your
|
||||
* application is doing something fancy like infinite Z */
|
||||
virtual void GetProjectionRaw( Hmd_Eye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0;
|
||||
|
||||
/** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
|
||||
* the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */
|
||||
virtual DistortionCoordinates_t ComputeDistortion( Hmd_Eye eEye, float fU, float fV ) = 0;
|
||||
|
||||
/** Returns the transform between the view space and eye space. Eye space is the per-eye flavor of view
|
||||
* space that provides stereo disparity. Instead of Model * View * Projection the model is Model * View * Eye * Projection.
|
||||
* Normally View and Eye will be multiplied together and treated as View in your application.
|
||||
*/
|
||||
virtual HmdMatrix44_t GetEyeMatrix( Hmd_Eye eEye ) = 0;
|
||||
|
||||
/** For use in simple VR apps, this method returns the concatenation of the
|
||||
* tracking pose and the eye matrix to get a full view matrix for each eye.
|
||||
* This is ( GetEyeMatrix() ) * (GetWorldFromHeadPose() ^ -1 ) */
|
||||
virtual bool GetViewMatrix( float fSecondsFromNow, HmdMatrix44_t *pMatLeftView, HmdMatrix44_t *pMatRightView, HmdTrackingResult *peResult ) = 0;
|
||||
|
||||
/** [D3D9 Only]
|
||||
* Returns the adapter index that the user should pass into CreateDevice to set up D3D9 in such
|
||||
* a way that it can go full screen exclusive on the HMD. Returns -1 if there was an error.
|
||||
*/
|
||||
virtual int32_t GetD3D9AdapterIndex() = 0;
|
||||
|
||||
// ------------------------------------
|
||||
// Tracking Methods
|
||||
// ------------------------------------
|
||||
|
||||
/** The pose that the tracker thinks that the HMD will be in at the specified
|
||||
* number of seconds into the future. Pass 0 to get the current state.
|
||||
*
|
||||
* This is roughly analagous to the inverse of the view matrix in most applications, though
|
||||
* many games will need to do some additional rotation or translation on top of the rotation
|
||||
* and translation provided by the head pose.
|
||||
*
|
||||
* If this function returns true the pose has been populated with a pose that can be used by the application.
|
||||
* Check peResult for details about the pose, including messages that should be displayed to the user.
|
||||
*/
|
||||
virtual bool GetWorldFromHeadPose( float fPredictedSecondsFromNow, HmdMatrix34_t *pmPose, HmdTrackingResult *peResult ) = 0;
|
||||
|
||||
/** Passes back the pose matrix from the last successful call to GetWorldFromHeadPose(). Returns true if that matrix is
|
||||
* valid (because there has been a previous successful pose.) */
|
||||
virtual bool GetLastWorldFromHeadPose( HmdMatrix34_t *pmPose ) = 0;
|
||||
|
||||
/** Returns true if the tracker for this HMD will drift the Yaw component of its pose over time regardless of
|
||||
* actual head motion. This is true for gyro-based trackers with no ground truth. */
|
||||
virtual bool WillDriftInYaw() = 0;
|
||||
|
||||
/** Sets the zero pose for the tracker coordinate system. After this call all WorldFromHead poses will be relative
|
||||
* to the pose whenever this was called. The new zero coordinate system will not change the fact that the Y axis is
|
||||
* up in the real world, so the next pose returned from GetWorldFromHeadPose after a call to ZeroTracker may not be
|
||||
* exactly an identity matrix. */
|
||||
virtual void ZeroTracker() = 0;
|
||||
|
||||
// ------------------------------------
|
||||
// Administrative methods
|
||||
// ------------------------------------
|
||||
|
||||
/** The ID of the driver this HMD uses as a UTF-8 string. Returns the length of the ID in bytes. If
|
||||
* the buffer is not large enough to fit the ID an empty string will be returned. In general, 128 bytes
|
||||
* will be enough to fit any ID. */
|
||||
virtual uint32_t GetDriverId( char *pchBuffer, uint32_t unBufferLen ) = 0;
|
||||
|
||||
/** The ID of this display within its driver this HMD uses as a UTF-8 string. Returns the length of the ID in bytes. If
|
||||
* the buffer is not large enough to fit the ID an empty string will be returned. In general, 128 bytes
|
||||
* will be enough to fit any ID. */
|
||||
virtual uint32_t GetDisplayId( char *pchBuffer, uint32_t unBufferLen ) = 0;
|
||||
};
|
||||
|
||||
static const char * const IHmd_Version = "IHmd_002";
|
||||
|
||||
/** error codes returned by Vr_Init */
|
||||
enum HmdError
|
||||
{
|
||||
HmdError_None = 0,
|
||||
|
||||
HmdError_Init_InstallationNotFound = 100,
|
||||
HmdError_Init_InstallationCorrupt = 101,
|
||||
HmdError_Init_VRClientDLLNotFound = 102,
|
||||
HmdError_Init_FileNotFound = 103,
|
||||
HmdError_Init_FactoryNotFound = 104,
|
||||
HmdError_Init_InterfaceNotFound = 105,
|
||||
HmdError_Init_InvalidInterface = 106,
|
||||
HmdError_Init_UserConfigDirectoryInvalid = 107,
|
||||
HmdError_Init_HmdNotFound = 108,
|
||||
HmdError_Init_NotInitialized = 109,
|
||||
|
||||
HmdError_Driver_Failed = 200,
|
||||
|
||||
HmdError_IPC_ServerInitFailed = 300,
|
||||
HmdError_IPC_ConnectFailed = 301,
|
||||
HmdError_IPC_SharedStateInitFailed = 302,
|
||||
|
||||
};
|
||||
|
||||
|
||||
// figure out how to import from the VR API dll
|
||||
#if defined(_WIN32)
|
||||
|
||||
#ifdef VR_API_EXPORT
|
||||
#define VR_INTERFACE extern "C" __declspec( dllexport )
|
||||
#else
|
||||
#define VR_INTERFACE extern "C" __declspec( dllimport )
|
||||
#endif
|
||||
|
||||
#elif defined(GNUC) || defined(COMPILER_GCC)
|
||||
|
||||
#ifdef VR_API_EXPORT
|
||||
#define VR_INTERFACE extern "C" __attribute__((visibility("default")))
|
||||
#else
|
||||
#define VR_INTERFACE extern "C"
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error "Unsupported Platform."
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/** Finds the active installation of the VR API and initializes it. The priority for figuring
|
||||
* out where to load vrclient from are:
|
||||
* 1. The convar "VR_OVERRIDE", which should contain an absolute path to the root of
|
||||
* an vr API directory.
|
||||
* 2. The pchVROverride argument. This should be an absolute path or a path relative to
|
||||
* the current executable.
|
||||
* 3. The path "./vr" relative to the current executable's path.
|
||||
*
|
||||
* Each of these paths are to the "root" of the VR API install. That's the directory with
|
||||
* the "drivers" directory and a platform (i.e. "win32") directory in it, not the directory with the DLL itself.
|
||||
*/
|
||||
VR_INTERFACE IHmd *VR_Init( HmdError *peError );
|
||||
|
||||
/** unloads vrclient.dll. Any interface pointers from the interface are
|
||||
* invalid after this point */
|
||||
VR_INTERFACE void VR_Shutdown( );
|
||||
|
||||
#pragma pack( pop )
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -59,7 +59,7 @@ struct PointVertex_t
|
||||
DWORD color;
|
||||
};
|
||||
|
||||
// Vertex struct for textured quads
|
||||
// Vertex struct for textured quads in pixel space
|
||||
struct TexturedQuadVertex_t
|
||||
{
|
||||
float x, y, z, rhw;
|
||||
@@ -67,6 +67,14 @@ struct TexturedQuadVertex_t
|
||||
float u, v; // texture coordinates
|
||||
};
|
||||
|
||||
// Vertex struct for textured quads in 3D space
|
||||
struct Textured3DQuadVertex_t
|
||||
{
|
||||
float x, y, z;
|
||||
DWORD color;
|
||||
float u, v; // texture coordinates
|
||||
};
|
||||
|
||||
class CVoiceContext;
|
||||
|
||||
// WndProc declaration
|
||||
@@ -82,7 +90,7 @@ public:
|
||||
static void RemoveInstanceFromHWNDMap( HWND hWnd );
|
||||
|
||||
// Constructor
|
||||
CGameEngineWin32( HINSTANCE hInstance, int nShowCommand, int32 nWindowWidth, int32 nWindowHeight );
|
||||
CGameEngineWin32( HINSTANCE hInstance, int nShowCommand, int32 nWindowWidth, int32 nWindowHeight, bool bUseVR );
|
||||
|
||||
// Destructor
|
||||
~CGameEngineWin32() { Shutdown(); }
|
||||
@@ -143,6 +151,24 @@ public:
|
||||
// Flush any still cached quad buffers
|
||||
bool BFlushQuadBuffer();
|
||||
|
||||
// Draw a textured rectangle with full 3D points
|
||||
bool BDraw3DTexturedQuad( Textured3DQuadVertex_t vert[4], HGAMETEXTURE hTexture );
|
||||
|
||||
// Flush any still cached quad buffers
|
||||
bool BFlush3DQuadBuffer();
|
||||
|
||||
// sets the texture as the 0th one to draw with
|
||||
bool BSetTexture( HGAMETEXTURE hTexture );
|
||||
|
||||
// sets the texture as a render target.
|
||||
bool BSetRenderTarget( HGAMETEXTURE hTexture );
|
||||
|
||||
// sets the render target back to the frame buffer
|
||||
bool BUnsetRenderTarget();
|
||||
|
||||
// make sure the texture is created on the device and ready to use
|
||||
bool BReadyTexture( HGAMETEXTURE hTexture );
|
||||
|
||||
// Get the current state of a key
|
||||
bool BIsKeyDown( DWORD dwVK );
|
||||
|
||||
@@ -177,6 +203,10 @@ public:
|
||||
void RecordKeyUp( DWORD dwVK );
|
||||
|
||||
private:
|
||||
// Create a new texture returning our internal handle value for it (0 means failure)
|
||||
HGAMETEXTURE HCreateTextureInternal( byte *pRGBAData, uint32 uWidth, uint32 uHeight, D3DFORMAT eFormat );
|
||||
|
||||
|
||||
// Creates the hwnd for the game
|
||||
bool BCreateGameWindow( int nShowCommand );
|
||||
|
||||
@@ -213,6 +243,8 @@ private:
|
||||
// Handle reseting the d3d device (ie, acquire resources again)
|
||||
bool BHandleResetDevice();
|
||||
|
||||
// Loads the VR distortion shader off disk
|
||||
bool BInitializeVRShader();
|
||||
|
||||
private:
|
||||
// Tracks whether the engine is ready for use
|
||||
@@ -221,6 +253,9 @@ private:
|
||||
// Tracks if we are shutting down
|
||||
bool m_bShuttingDown;
|
||||
|
||||
// if this is not NULL we are in VR mode
|
||||
vr::IHmd *m_pVRHmd;
|
||||
|
||||
// Color we clear the background of the window to each frame
|
||||
DWORD m_dwBackgroundColor;
|
||||
|
||||
@@ -236,6 +271,9 @@ private:
|
||||
// IDirect3DDevice9 interface
|
||||
IDirect3DDevice9 *m_pD3D9Device;
|
||||
|
||||
// Depth/stencil surface associated with the back buffer
|
||||
IDirect3DSurface9 *m_pBackbufferDepth;
|
||||
|
||||
// Size of the window to display the game in
|
||||
int32 m_nWindowWidth;
|
||||
int32 m_nWindowHeight;
|
||||
@@ -270,9 +308,17 @@ private:
|
||||
uint32 m_uWidth;
|
||||
uint32 m_uHeight;
|
||||
LPDIRECT3DTEXTURE9 m_pTexture;
|
||||
LPDIRECT3DSURFACE9 m_pDepthSurface; // render targets only
|
||||
D3DFORMAT m_eFormat;
|
||||
};
|
||||
std::map<HGAMETEXTURE, TextureData_t> m_MapTextures;
|
||||
|
||||
// the render target we draw the 2D game into for VR
|
||||
HGAMETEXTURE m_hVR2DRenderTarget;
|
||||
|
||||
// the render target we draw the 3D scene into for VR
|
||||
HGAMETEXTURE m_hVRSceneRenderTarget;
|
||||
|
||||
// Vertex buffer for textured quads
|
||||
HGAMEVERTBUF m_hQuadBuffer;
|
||||
|
||||
@@ -288,6 +334,21 @@ private:
|
||||
// Where does the current batch begin
|
||||
DWORD m_dwQuadBufferBatchPos;
|
||||
|
||||
// Vertex buffer for textured quads
|
||||
HGAMEVERTBUF m_h3DQuadBuffer;
|
||||
|
||||
// Last texture used in drawing a batched quad
|
||||
HGAMETEXTURE m_h3DLastTexture;
|
||||
|
||||
// Pointer to quad 3D vertex data
|
||||
Textured3DQuadVertex_t *m_p3DQuadVertexes;
|
||||
|
||||
// How many 3D quads are awaiting flushing
|
||||
DWORD m_dw3DQuadsToFlush;
|
||||
|
||||
// Where does the current 3D batch begin
|
||||
DWORD m_dw3DQuadBufferBatchPos;
|
||||
|
||||
// White texture used when drawing filled quads
|
||||
HGAMETEXTURE m_hTextureWhite;
|
||||
|
||||
@@ -348,6 +409,12 @@ private:
|
||||
// Map of font handles to font objects
|
||||
std::map<HGAMEVOICECHANNEL, CVoiceContext* > m_MapVoiceChannel;
|
||||
uint32 m_unVoiceChannelCount;
|
||||
|
||||
// Pixel shader for VR distortion correction
|
||||
IDirect3DPixelShader9* m_pVRDistortionPixelShader;
|
||||
|
||||
// the distortion map used by the VR distortion pixel shader (one per eye)
|
||||
HGAMETEXTURE m_hVRDistortionMap[2];
|
||||
};
|
||||
|
||||
#endif // GAMEENGINEWIN32_H
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
float c_rg_to_rb_ratio = 0.522;
|
||||
|
||||
sampler2D BaseTextureSampler : register(s0);
|
||||
sampler2D DistortMapTextureSampler : register(s1);
|
||||
|
||||
struct Fullscreen_Quad_Vert {
|
||||
float4 position : SV_POSITION;
|
||||
float2 texcoord: TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Distort_Out
|
||||
{
|
||||
float4 color: COLOR;
|
||||
};
|
||||
|
||||
Distort_Out PS(Fullscreen_Quad_Vert input)
|
||||
{
|
||||
float2 vOriginal = input.texcoord;
|
||||
|
||||
float4 vRead = tex2D( DistortMapTextureSampler, vOriginal );
|
||||
|
||||
float2 vGreen;
|
||||
vGreen.r = ( vRead.x + vRead.z ) / 2;
|
||||
vGreen.g = ( vRead.y + vRead.w ) / 2;
|
||||
|
||||
float4 vFinal;
|
||||
vFinal.r = tex2D( BaseTextureSampler, vRead.xy ).r;
|
||||
vFinal.ga = tex2D( BaseTextureSampler, vGreen ).ga;
|
||||
vFinal.b = tex2D( BaseTextureSampler, vRead.zw ).b;
|
||||
|
||||
float fBoundsCheck = saturate( dot( (vGreen.xy < float2(0.05,0.05)), float2(1,1)) + dot( (vGreen.xy > float2(0.95,0.95)), float2(1,1)) );
|
||||
vFinal.xyz = lerp( vFinal.xyz, float3(0,0,0), fBoundsCheck );
|
||||
|
||||
Distort_Out o;
|
||||
o.color = vFinal;
|
||||
return o;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
fxc /E PS /T ps_3_0 /O3 /Gfa /Fo ..\D3D9VRDistort.cso D3D9VRDistort.ps
|
||||
@@ -1,15 +1,31 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1001"
|
||||
// Set your assigned depot ID here
|
||||
"DepotID" "1001"
|
||||
|
||||
// Set a root for all content.
|
||||
// All relative paths specified below (LocalPath in FileMapping entries, and FileExclusion paths)
|
||||
// will be resolved relative to this root.
|
||||
// If you don't define ContentRoot, then it will be assumed to be
|
||||
// the location of this script file, which probably isn't what you want
|
||||
"ContentRoot" "D:\MyGame\rel\master\"
|
||||
|
||||
// include all files recursivley
|
||||
"FileMapping"
|
||||
{
|
||||
// This can be a full path, or a path relative to ContentRoot
|
||||
"LocalPath" "*"
|
||||
|
||||
// This is a path relative to the install folder of your game
|
||||
"DepotPath" "."
|
||||
|
||||
// If LocalPath contains wildcards, setting this means that all
|
||||
// matching files within subdirectories of LocalPath will also
|
||||
// be included.
|
||||
"recursive" "1"
|
||||
}
|
||||
|
||||
// but exclude all symbol files
|
||||
// This can be a full path, or a path relative to ContentRoot
|
||||
"FileExclusion" "*.pdb"
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user