mirror of
https://github.com/rlabrecque/SteamworksSDK.git
synced 2026-10-10 01:23:04 +08:00
v1.13
This commit is contained in:
+59
-4
@@ -1,6 +1,6 @@
|
||||
================================================================
|
||||
|
||||
Copyright © 1996-2010, Valve Corporation, All rights reserved.
|
||||
Copyright © 1996-2011, Valve Corporation, All rights reserved.
|
||||
|
||||
================================================================
|
||||
|
||||
@@ -11,12 +11,66 @@ website at: http://partner.steamgames.com
|
||||
|
||||
Revision History:
|
||||
|
||||
----------------------------------------------------------------
|
||||
v1.13 26th April 2011
|
||||
----------------------------------------------------------------
|
||||
|
||||
Rich Presence
|
||||
* added a new Rich Presence system to allow for sharing game specific per user data between users
|
||||
* ISteamFriends::SetRichPresense() can be used to set key/value presence data for the current user
|
||||
* ISteamFriends::GetFriendRichPresence() and related functions can be used to retrieve presence data for a particular user
|
||||
* Two special presence keys exist:
|
||||
** the "connect" key can be set to specify a custom command line used by friends when joining that user
|
||||
** the "status" key can be set to specify custom text that will show up in the 'view game info' dialog in the Steam friends list
|
||||
|
||||
HTTP
|
||||
* added ISteamHTTP, which exposes methods for making HTTP requests
|
||||
|
||||
Downloadable Content
|
||||
* added ISteamApps::GetDLCCount() and ISteamApps::BGetDLCDataByIndex() to allow for enumerating DLC content for the current title
|
||||
* added ISteamApps::InstallDLC() and ISteamApps::UninstallDLC() to control installing optional content
|
||||
|
||||
P2P Networking
|
||||
* added ISteamNetworking::CloseP2PChannelWithUser(), to allow for closing a single channel to a user. When all channels are closed, the connection to that user is automatically closed.
|
||||
* added ISteamNetworking::AllowP2PPacketRelay(), which can be used to prevent allowing P2P connections from falling back to relay
|
||||
|
||||
Voice
|
||||
* ISteamUser::GetAvailableVoice() & ISteamUser::GetVoice() now take the desired sample rate to determine the number of uncompressed bytes to return
|
||||
* added ISteamUser::GetVoiceOptimalSampleRate() to return the frequency of the voice data as it's stored internally
|
||||
|
||||
Friends
|
||||
* added ISteamFriends methods to retrieve the list of users the player has recently played with
|
||||
|
||||
Content Tool
|
||||
* all files are now encrypted by default
|
||||
* add command line option to app creation wizard
|
||||
* add command line edit option by right clicking on app
|
||||
* update cache size in CDDB after each build
|
||||
* look for install scripts at build time and automatically add CDDB flag
|
||||
* fix language names for chinese
|
||||
* add menu button to easily rev version
|
||||
* warn if rebuilding existing version
|
||||
* allow specifying subfolder when ftp-ing depots to valve
|
||||
* better error messaging if ftp fails
|
||||
* clean up various small display bugs
|
||||
* don't trash ValidOSList tag when updating CDDB
|
||||
|
||||
OSX DirectX to OpenGL
|
||||
* added the graphics layer used to port Valve games to OSX which can now be used by all Steamworks developers
|
||||
* included in the Steamworks Example application. Can be enabled by building with DX9MODE=1
|
||||
|
||||
|
||||
----------------------------------------------------------------
|
||||
v1.12 10th November 2010
|
||||
----------------------------------------------------------------
|
||||
|
||||
Cloud
|
||||
* added a set of function to handle publishing User Generated Content (UGC) files to the backend, and to download others users UGC files. This enables games to have users easily publish & share content with each other.
|
||||
* Added ISteamRemoteStorage::FileForget() which tells a file to remain on disk but to be removed from the backend. This can be used to manage which files should be synchronized if you have more files to store than your quota allows.
|
||||
* Added ISteamRemoteStorage::FilePersisted() to tell if the file is set to be synchronized with the backend.
|
||||
* Added ISteamRemoteStorage::FileDelete() which tells a file to be deleted locally, from cloud, and from other clients that have the file. This can be used to properly delete a save file rather than writing a 1-byte file as a sentinel.
|
||||
* Added ISteamRemoteStorage::SetSyncPlatforms(), GetSyncPlatforms() to tell steam which platforms a file should be synchronized to. This allows OSX not to download PC-specific files, or vice-versa.
|
||||
* Added ISteamRemoteStorage::IsCloudEnabledForAccount(), IsCloudEnabledForApp(), and SetCloudEnabledForApp(). When cloud is disabled the APIs still work as normal and an alternate location on disk is not needed. It just means the files will not be synchronized with the backend.
|
||||
|
||||
Leaderboards
|
||||
* added ISteamUserStats::DownloadLeaderboardEntriesForUsers(), which downloads scores for an arbitrary set of users
|
||||
@@ -35,8 +89,9 @@ Authentication
|
||||
* added ISteamApps::BIsSubscribedFromFreeWeekend(), so games can show different offers or information for users who currently only have rights to play the game due to a free weekend promotion
|
||||
* added ISteamGameServer::GetAuthSessionTicket(), BeginAuthSession(), EndAuthSession(), and CancelAuthTicket(), matching what exists in ISteamUser. This allows game servers and clients to authenticate each other in a unified manner.
|
||||
|
||||
Steamworks Example
|
||||
* added OpenGL and OSX support
|
||||
OSX
|
||||
* The Steamworks Spacewar example now builds/runs on OS X
|
||||
* The OSX retail install setup application is now contained in goldmaster\disk_assets\SteamRetailInstaller.dmg
|
||||
|
||||
PS3
|
||||
* added several functions regarding PS3 support. This is still a work in progress, and no PS3 binaries are included.
|
||||
@@ -341,4 +396,4 @@ The Steamworks SDK has been updated to simplfy game server authentication and be
|
||||
v1.0:
|
||||
----------------------------------------------------------------
|
||||
|
||||
- Initial Steamworks SDK release
|
||||
- Initial Steamworks SDK release
|
||||
|
||||
+42
-51
@@ -33,10 +33,15 @@ void MiniDumpFunction( unsigned int nExceptionCode, EXCEPTION_POINTERS *pExcepti
|
||||
}
|
||||
#endif
|
||||
|
||||
static int Alert( const char *lpCaption, const char *lpText )
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Helper to display critical errors
|
||||
//-----------------------------------------------------------------------------
|
||||
int Alert( const char *lpCaption, const char *lpText )
|
||||
{
|
||||
#ifndef _WIN32
|
||||
fprintf( stderr, "Message: '%s', Detail: '%s'\n", lpCaption, lpText );
|
||||
return 0;
|
||||
#else
|
||||
return ::MessageBox( NULL, lpText, lpCaption, MB_OK );
|
||||
#endif
|
||||
@@ -60,10 +65,40 @@ 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 )
|
||||
{
|
||||
// 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
|
||||
// a server for our game and is trying to join it.
|
||||
const char *pchConnectParam = "+connect";
|
||||
const char *pchConnect = strstr( pchCmdLine, pchConnectParam );
|
||||
*ppchServerAddress = NULL;
|
||||
if ( pchConnect && strlen( pchCmdLine ) > (pchConnect - pchCmdLine) + strlen( pchConnectParam ) + 1 )
|
||||
{
|
||||
// Address should be right after the +connect, +1 on the end to skip the space
|
||||
*ppchServerAddress = pchCmdLine + ( pchConnect - pchCmdLine ) + strlen( pchConnectParam ) + 1;
|
||||
}
|
||||
|
||||
// look for +connect_lobby lobbyid paramter on the command line
|
||||
// Steam will pass this in if a user taken up an invite to a lobby
|
||||
const char *pchConnectLobbyParam = "+connect_lobby";
|
||||
const char *pchConnectLobby = strstr( pchCmdLine, pchConnectParam );
|
||||
*ppchLobbyID = NULL;
|
||||
if ( pchConnectLobby && strlen( pchCmdLine ) > (pchConnectLobby - pchCmdLine) + strlen( pchConnectLobbyParam ) + 1 )
|
||||
{
|
||||
// Address should be right after the +connect, +1 on the end to skip the space
|
||||
*ppchLobbyID = pchCmdLine + ( pchConnectLobby - pchCmdLine ) + strlen( pchConnectLobbyParam ) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Main loop code shared between all platforms
|
||||
//-----------------------------------------------------------------------------
|
||||
void RunGameLoop( IGameEngine *pGameEngine, const char *pchServerAddress, const char *pchLobbyID )
|
||||
void RunGameLoop( IGameEngine *pGameEngine, const char *pchServerAddress, const char *pchLobbyID )
|
||||
{
|
||||
// Make sure it initialized ok
|
||||
if ( pGameEngine->BReadyForUse() )
|
||||
@@ -75,31 +110,7 @@ void RunGameLoop( IGameEngine *pGameEngine, const char *pchServerAddress, const
|
||||
pGameEngine->SetBackgroundColor( 0, 0, 0, 0 );
|
||||
|
||||
// If +connect was used to specify a server address, connect now
|
||||
if ( pchServerAddress )
|
||||
{
|
||||
int32 octet0 = 0, octet1 = 0, octet2 = 0, octet3 = 0;
|
||||
int32 uPort = 0;
|
||||
int nConverted = sscanf( pchServerAddress, "%d.%d.%d.%d:%d", &octet0, &octet1, &octet2, &octet3, &uPort );
|
||||
if ( nConverted == 5 )
|
||||
{
|
||||
char rgchIPAddress[128];
|
||||
_snprintf( rgchIPAddress, ARRAYSIZE( rgchIPAddress ), "%d.%d.%d.%d", octet0, octet1, octet2, octet3 );
|
||||
uint32 unIPAddress = ( octet3 ) + ( octet2 << 8 ) + ( octet1 << 16 ) + ( octet0 << 24 );
|
||||
pGameClient->InitiateServerConnection( unIPAddress, uPort );
|
||||
}
|
||||
}
|
||||
|
||||
// if +connect_lobby was used to specify a lobby to join, connect now
|
||||
if ( pchLobbyID )
|
||||
{
|
||||
CSteamID steamIDLobby( (uint64)atoll( pchLobbyID ) );
|
||||
if ( steamIDLobby.IsValid() )
|
||||
{
|
||||
// act just like we had selected it from the menu
|
||||
LobbyBrowserMenuItem_t menuItem = { steamIDLobby, k_EClientJoiningLobby };
|
||||
pGameClient->OnMenuSelection( menuItem );
|
||||
}
|
||||
}
|
||||
pGameClient->ExecCommandLineConnect( pchServerAddress, pchLobbyID );
|
||||
|
||||
// test a user specific secret before entering main loop
|
||||
Steamworks_TestSecret();
|
||||
@@ -137,6 +148,7 @@ void RunGameLoop( IGameEngine *pGameEngine, const char *pchServerAddress, const
|
||||
// Purpose: Real main entry point for the program
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _PS3
|
||||
|
||||
static int RealMain( const char *pchCmdLine, HINSTANCE hInstance, int nCmdShow )
|
||||
{
|
||||
|
||||
@@ -184,29 +196,8 @@ static int RealMain( const char *pchCmdLine, HINSTANCE hInstance, int nCmdShow )
|
||||
// with important UI in your game.
|
||||
SteamUtils()->SetOverlayNotificationPosition( k_EPositionTopRight );
|
||||
|
||||
// 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
|
||||
// a server for our game and is trying to join it.
|
||||
const char *pchConnectParam = "+connect";
|
||||
const char *pchConnect = strstr( pchCmdLine, pchConnectParam );
|
||||
const char *pchServerAddress = NULL;
|
||||
if ( pchConnect && strlen( pchCmdLine ) > (pchConnect - pchCmdLine) + strlen( pchConnectParam ) + 1 )
|
||||
{
|
||||
// Address should be right after the +connect, +1 on the end to skip the space
|
||||
pchServerAddress = pchCmdLine + ( pchConnect - pchCmdLine ) + strlen( pchConnectParam ) + 1;
|
||||
}
|
||||
|
||||
// look for +connect_lobby lobbyid paramter on the command line
|
||||
// Steam will pass this in if a user taken up an invite to a lobby
|
||||
const char *pchConnectLobbyParam = "+connect_lobby";
|
||||
const char *pchConnectLobby = strstr( pchCmdLine, pchConnectParam );
|
||||
const char *pchLobbyID = NULL;
|
||||
if ( pchConnectLobby && strlen( pchCmdLine ) > (pchConnectLobby - pchCmdLine) + strlen( pchConnectLobbyParam ) + 1 )
|
||||
{
|
||||
// Address should be right after the +connect, +1 on the end to skip the space
|
||||
pchLobbyID = pchCmdLine + ( pchConnectLobby - pchCmdLine ) + strlen( pchConnectLobbyParam ) + 1;
|
||||
}
|
||||
|
||||
const char *pchServerAddress, *pchLobbyID;
|
||||
ParseCommandLine( pchCmdLine, &pchServerAddress, &pchLobbyID );
|
||||
// do a DRM self check
|
||||
Steamworks_SelfCheck();
|
||||
|
||||
@@ -215,7 +206,7 @@ static int RealMain( const char *pchCmdLine, HINSTANCE hInstance, int nCmdShow )
|
||||
IGameEngine *pGameEngine =
|
||||
#if defined(_WIN32)
|
||||
new CGameEngineWin32( hInstance, nCmdShow, 1024, 768 );
|
||||
#else if defined(OSX)
|
||||
#elif defined(OSX)
|
||||
CreateGameEngineOSX();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@
|
||||
CSpaceWarClient *g_pSpaceWarClient = NULL;
|
||||
CSpaceWarClient* SpaceWarClient() { return g_pSpaceWarClient; }
|
||||
|
||||
#if defined(WIN32)
|
||||
#define atoll _atoi64
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -33,7 +38,10 @@ CSpaceWarClient::CSpaceWarClient( IGameEngine *pGameEngine ) :
|
||||
m_IPCFailureCallback( this, &CSpaceWarClient::OnIPCFailure ),
|
||||
m_SteamShutdownCallback( this, &CSpaceWarClient::OnSteamShutdown ),
|
||||
m_SteamServersConnected( this, &CSpaceWarClient::OnSteamServersConnected ),
|
||||
m_SteamServerConnectFailure( this, &CSpaceWarClient::OnSteamServerConnectFailure )
|
||||
m_SteamServersDisconnected( this, &CSpaceWarClient::OnSteamServersDisconnected ),
|
||||
m_SteamServerConnectFailure( this, &CSpaceWarClient::OnSteamServerConnectFailure ),
|
||||
m_GameJoinRequested( this, &CSpaceWarClient::OnGameJoinRequested ),
|
||||
m_CallbackGameOverlayActivated( this, &CSpaceWarClient::OnGameOverlayActivated )
|
||||
{
|
||||
Init( pGameEngine );
|
||||
}
|
||||
@@ -231,6 +239,10 @@ void CSpaceWarClient::OnReceiveServerInfo( CSteamID steamIDGameServer, bool bVAC
|
||||
m_unServerIP = p2pSessionState.m_nRemoteIP;
|
||||
m_usServerPort = p2pSessionState.m_nRemotePort;
|
||||
|
||||
// set how to connect to the game server, using the Rich Presence API
|
||||
// this lets our friends connect to this game via their friends list
|
||||
UpdateRichPresenceConnectionInfo();
|
||||
|
||||
MsgClientBeginAuthentication_t msg;
|
||||
#ifdef USE_GS_AUTH_API
|
||||
char rgchToken[1024];
|
||||
@@ -272,6 +284,9 @@ void CSpaceWarClient::OnReceiveServerAuthenticationResponse( bool bSuccess, uint
|
||||
m_uPlayerShipIndex = uPlayerPosition;
|
||||
m_eConnectedStatus = k_EClientConnectedAndAuthenticated;
|
||||
|
||||
// set information so our friends can join the lobby
|
||||
UpdateRichPresenceConnectionInfo();
|
||||
|
||||
// send a ping, to measure round-trip time
|
||||
m_ulPingSentTime = m_pGameEngine->GetGameTickCount();
|
||||
MsgClientPing_t msg;
|
||||
@@ -461,6 +476,9 @@ void CSpaceWarClient::SetGameState( EClientGameState eState )
|
||||
|
||||
// Let the stats handler check the state (so it can detect wins, losses, etc...)
|
||||
m_pStatsAndAchievements->OnGameStateChange( eState );
|
||||
|
||||
// update any rich presence state
|
||||
UpdateRichPresenceConnectionInfo();
|
||||
}
|
||||
|
||||
|
||||
@@ -709,6 +727,22 @@ void CSpaceWarClient::OnReceiveServerExiting()
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Steam is asking us to join a game, based on the user selecting
|
||||
// 'join game' on a friend in their friends list
|
||||
// the string comes from the "connect" field set in the friends' rich presence
|
||||
//-----------------------------------------------------------------------------
|
||||
void CSpaceWarClient::OnGameJoinRequested( GameRichPresenceJoinRequested_t *pCallback )
|
||||
{
|
||||
// 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 );
|
||||
|
||||
// exec
|
||||
ExecCommandLineConnect( pchServerAddress, pchLobbyID );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Finishes up entering a lobby of our own creation
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -757,10 +791,11 @@ void CSpaceWarClient::OnLobbyEntered( LobbyEnter_t *pCallback, bool bIOFailure )
|
||||
}
|
||||
|
||||
// success
|
||||
|
||||
// move forward the state
|
||||
SetGameState( k_EClientInLobby );
|
||||
m_steamIDLobby = pCallback->m_ulSteamIDLobby;
|
||||
m_pLobby->SetLobbySteamID( m_steamIDLobby );
|
||||
SetGameState( k_EClientInLobby );
|
||||
}
|
||||
|
||||
|
||||
@@ -965,6 +1000,31 @@ void CSpaceWarClient::OnSteamServersConnected( SteamServersConnected_t *callback
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles notification that we are now connected to Steam
|
||||
//-----------------------------------------------------------------------------
|
||||
void CSpaceWarClient::OnSteamServersDisconnected( SteamServersDisconnected_t *callback )
|
||||
{
|
||||
SetGameState( k_EClientConnectingToSteam );
|
||||
m_pConnectingMenu->OnConnectFailure();
|
||||
OutputDebugString( "Got SteamServersDisconnected_t\n" );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles notification that the Steam overlay is shown/hidden, note, this
|
||||
// doesn't mean the overlay will or will not draw, it may still draw when not active.
|
||||
// This does mean the time when the overlay takes over input focus from the game.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CSpaceWarClient::OnGameOverlayActivated( GameOverlayActivated_t *callback )
|
||||
{
|
||||
if ( callback->m_bActive )
|
||||
OutputDebugString( "Steam overlay now active\n" );
|
||||
else
|
||||
OutputDebugString( "Steam overlay now inactive\n" );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles notification that we are now connected to Steam
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1762,3 +1822,60 @@ void CSpaceWarClient::OnRequestEncryptedAppTicket( EncryptedAppTicketResponse_t
|
||||
OutputDebugString( "Calling RequestEncryptedAppTicket while not connected to steam results in this error\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Updates what we show to friends about what we're doing and how to connect
|
||||
//-----------------------------------------------------------------------------
|
||||
void CSpaceWarClient::UpdateRichPresenceConnectionInfo()
|
||||
{
|
||||
// connect string that will come back to us on the command line when a friend tries to join our game
|
||||
char rgchConnectString[128];
|
||||
rgchConnectString[0] = 0;
|
||||
|
||||
if ( m_eConnectedStatus == k_EClientConnectedAndAuthenticated && m_unServerIP && m_usServerPort )
|
||||
{
|
||||
// game server connection method
|
||||
_snprintf( rgchConnectString, sizeof(rgchConnectString), "+connect %d:%d", m_unServerIP, m_usServerPort );
|
||||
}
|
||||
else if ( m_steamIDLobby.IsValid() )
|
||||
{
|
||||
// lobby connection method
|
||||
_snprintf( rgchConnectString, sizeof(rgchConnectString), "+connect_lobby %llu", m_steamIDLobby.ConvertToUint64() );
|
||||
}
|
||||
|
||||
SteamFriends()->SetRichPresence( "connect", rgchConnectString );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: applies a command-line connect
|
||||
//-----------------------------------------------------------------------------
|
||||
void CSpaceWarClient::ExecCommandLineConnect( const char *pchServerAddress, const char *pchLobbyID )
|
||||
{
|
||||
if ( pchServerAddress )
|
||||
{
|
||||
int32 octet0 = 0, octet1 = 0, octet2 = 0, octet3 = 0;
|
||||
int32 uPort = 0;
|
||||
int nConverted = sscanf( pchServerAddress, "%d.%d.%d.%d:%d", &octet0, &octet1, &octet2, &octet3, &uPort );
|
||||
if ( nConverted == 5 )
|
||||
{
|
||||
char rgchIPAddress[128];
|
||||
_snprintf( rgchIPAddress, ARRAYSIZE( rgchIPAddress ), "%d.%d.%d.%d", octet0, octet1, octet2, octet3 );
|
||||
uint32 unIPAddress = ( octet3 ) + ( octet2 << 8 ) + ( octet1 << 16 ) + ( octet0 << 24 );
|
||||
InitiateServerConnection( unIPAddress, uPort );
|
||||
}
|
||||
}
|
||||
|
||||
// if +connect_lobby was used to specify a lobby to join, connect now
|
||||
if ( pchLobbyID )
|
||||
{
|
||||
CSteamID steamIDLobby( (uint64)atoll( pchLobbyID ) );
|
||||
if ( steamIDLobby.IsValid() )
|
||||
{
|
||||
// act just like we had selected it from the menu
|
||||
LobbyBrowserMenuItem_t menuItem = { steamIDLobby, k_EClientJoiningLobby };
|
||||
OnMenuSelection( menuItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,6 +169,8 @@ public:
|
||||
|
||||
void RetrieveEncryptedAppTicket();
|
||||
|
||||
void ExecCommandLineConnect( const char *pchServerAddress, const char *pchLobbyID );
|
||||
|
||||
private:
|
||||
|
||||
// Receive a response from the server for a connection attempt
|
||||
@@ -207,6 +209,9 @@ private:
|
||||
// Draw text telling the user a connection attempt is in progress
|
||||
void DrawConnectionAttemptText();
|
||||
|
||||
// Updates what we show to friends about what we're doing and how to connect
|
||||
void UpdateRichPresenceConnectionInfo();
|
||||
|
||||
// Server we are connected to
|
||||
CSpaceWarServer *m_pServer;
|
||||
|
||||
@@ -349,11 +354,14 @@ private:
|
||||
|
||||
// callback for when the lobby game server has started
|
||||
STEAM_CALLBACK( CSpaceWarClient, OnLobbyGameCreated, LobbyGameCreated_t, m_LobbyGameCreated );
|
||||
STEAM_CALLBACK( CSpaceWarClient, OnGameJoinRequested, GameRichPresenceJoinRequested_t, m_GameJoinRequested );
|
||||
STEAM_CALLBACK( CSpaceWarClient, OnAvatarImageLoaded, AvatarImageLoaded_t, m_AvatarImageLoadedCreated );
|
||||
|
||||
// callbacks for Steam connection state
|
||||
STEAM_CALLBACK( CSpaceWarClient, OnSteamServersConnected, SteamServersConnected_t, m_SteamServersConnected );
|
||||
STEAM_CALLBACK( CSpaceWarClient, OnSteamServersDisconnected, SteamServersDisconnected_t, m_SteamServersDisconnected );
|
||||
STEAM_CALLBACK( CSpaceWarClient, OnSteamServerConnectFailure, SteamServerConnectFailure_t, m_SteamServerConnectFailure );
|
||||
STEAM_CALLBACK( CSpaceWarClient, OnGameOverlayActivated, GameOverlayActivated_t, m_CallbackGameOverlayActivated );
|
||||
|
||||
// lobby browser menu
|
||||
CLobbyBrowser *m_pLobbyBrowser;
|
||||
|
||||
@@ -52,9 +52,18 @@ void CStarField::Render()
|
||||
Init();
|
||||
}
|
||||
|
||||
static int counter; // per starfield draw..
|
||||
counter++;
|
||||
|
||||
for( size_t i = 0; i < m_VecStars.size(); ++i )
|
||||
{
|
||||
m_pGameEngine->BDrawPoint( m_VecStars[i].x, m_VecStars[i].y, m_VecStars[i].color );
|
||||
float x = m_VecStars[i].x;
|
||||
float y = m_VecStars[i].y;
|
||||
float scoot = (float)counter * (float)(m_VecStars[i].color & 0xFF) / (4.0f * 255.0f);
|
||||
float newy = y - scoot; // make things float up
|
||||
while( newy < 0.0f ) newy += m_nHeight; // keep it on screen
|
||||
|
||||
m_pGameEngine->BDrawPoint( x, newy, m_VecStars[i].color );
|
||||
}
|
||||
|
||||
m_pGameEngine->BFlushPointBuffer();
|
||||
|
||||
@@ -43,7 +43,8 @@ CStatsAndAchievements::CStatsAndAchievements( IGameEngine *pGameEngine )
|
||||
m_GameID( SteamUtils()->GetAppID() ),
|
||||
m_CallbackUserStatsReceived( this, &CStatsAndAchievements::OnUserStatsReceived ),
|
||||
m_CallbackUserStatsStored( this, &CStatsAndAchievements::OnUserStatsStored ),
|
||||
m_CallbackAchievementStored( this, &CStatsAndAchievements::OnAchievementStored )
|
||||
m_CallbackAchievementStored( this, &CStatsAndAchievements::OnAchievementStored ),
|
||||
m_CallbackPS3TrophiesInstalled( this, &CStatsAndAchievements::OnPS3TrophiesInstalled )
|
||||
{
|
||||
m_pSteamUser = SteamUser();
|
||||
m_pSteamUserStats = SteamUserStats();
|
||||
@@ -65,6 +66,9 @@ CStatsAndAchievements::CStatsAndAchievements( IGameEngine *pGameEngine )
|
||||
m_hDisplayFont = pGameEngine->HCreateFont( ACHDISP_FONT_HEIGHT, FW_MEDIUM, false, "Arial" );
|
||||
if ( !m_hDisplayFont )
|
||||
OutputDebugString( "Stats font was not created properly, text won't draw\n" );
|
||||
|
||||
m_bInstalledPS3Trophies = false;
|
||||
m_bStartedPS3TrophyInstall = false;
|
||||
}
|
||||
#pragma warning( pop )
|
||||
|
||||
@@ -73,8 +77,31 @@ CStatsAndAchievements::CStatsAndAchievements( IGameEngine *pGameEngine )
|
||||
//-----------------------------------------------------------------------------
|
||||
void CStatsAndAchievements::RunFrame()
|
||||
{
|
||||
if ( !m_bRequestedStats )
|
||||
// On PS3, must first install trophies before using the stats system
|
||||
if ( !m_bInstalledPS3Trophies )
|
||||
{
|
||||
#ifdef _PS3
|
||||
// PS3 trophies should be installed before writing to disk. Check PS3TrophiesInstalled_t to determine
|
||||
// if trophy installation failed because the machine is out of free HD space.
|
||||
if ( !m_bStartedPS3TrophyInstall )
|
||||
{
|
||||
if ( !m_pSteamUserStats->InstallPS3Trophies() )
|
||||
{
|
||||
OutputDebugString( "Failed to install PS3 trophies. This is a fatal error\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
m_bStartedPS3TrophyInstall = true;
|
||||
}
|
||||
|
||||
// wait for PS3TrophiesInstalled_t
|
||||
#else
|
||||
m_bInstalledPS3Trophies = true;
|
||||
m_bStartedPS3TrophyInstall = true;
|
||||
#endif
|
||||
}
|
||||
else if ( !m_bRequestedStats )
|
||||
{
|
||||
// Is Steam Loaded? if no, can't get stats, done
|
||||
if ( NULL == m_pSteamUserStats || NULL == m_pSteamUser )
|
||||
{
|
||||
@@ -82,8 +109,10 @@ void CStatsAndAchievements::RunFrame()
|
||||
return;
|
||||
}
|
||||
|
||||
LoadUserStatsOnPS3();
|
||||
|
||||
// If yes, request our stats
|
||||
bool bSuccess = m_pSteamUserStats->RequestCurrentStats( );
|
||||
bool bSuccess = m_pSteamUserStats->RequestCurrentStats();
|
||||
|
||||
// This function should only return false if we weren't logged in, and we already checked that.
|
||||
// But handle it being false again anyway, just ask again later.
|
||||
@@ -289,6 +318,8 @@ void CStatsAndAchievements::OnUserStatsReceived( UserStatsReceived_t *pCallback
|
||||
m_pSteamUserStats->GetStat( "FeetTraveled", &m_flTotalFeetTraveled );
|
||||
m_pSteamUserStats->GetStat( "MaxFeetTraveled", &m_flMaxFeetTraveled );
|
||||
m_pSteamUserStats->GetStat( "AverageSpeed", &m_flAverageSpeed );
|
||||
|
||||
SaveUserStatsOnPS3();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -311,6 +342,7 @@ void CStatsAndAchievements::OnUserStatsStored( UserStatsStored_t *pCallback )
|
||||
if ( k_EResultOK == pCallback->m_eResult )
|
||||
{
|
||||
OutputDebugString( "StoreStats - success\n" );
|
||||
SaveUserStatsOnPS3();
|
||||
}
|
||||
else if ( k_EResultInvalidParam == pCallback->m_eResult )
|
||||
{
|
||||
@@ -357,6 +389,33 @@ void CStatsAndAchievements::OnAchievementStored( UserAchievementStored_t *pCallb
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: An achievement was stored
|
||||
//-----------------------------------------------------------------------------
|
||||
void CStatsAndAchievements::OnPS3TrophiesInstalled( PS3TrophiesInstalled_t *pCallback )
|
||||
{
|
||||
// we may get callbacks for other games' stats arriving, ignore them
|
||||
if ( m_GameID.ToUint64() == pCallback->m_nGameID )
|
||||
{
|
||||
if ( pCallback->m_eResult != k_EResultOK )
|
||||
{
|
||||
// this is a fatal error. Usually the PS3 would have already displayed a fatal error to the user and forced the game to exit. If the system
|
||||
// could not display that error, you should display the appropriate message to the user then exit.
|
||||
char buffer[256];
|
||||
if ( pCallback->m_eResult == k_EResultDiskFull )
|
||||
_snprintf( buffer, 256, "Failed to install PS3 trophies because the HD is full (required space=%llu)\n", pCallback->m_ulRequiredDiskSpace );
|
||||
else
|
||||
_snprintf( buffer, 256, "Failed to install PS3 trophies (%d)", pCallback->m_eResult );
|
||||
|
||||
OutputDebugString( buffer );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
m_bInstalledPS3Trophies = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Display the user's stats and achievements
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -520,4 +579,71 @@ void CStatsAndAchievements::DrawStatInfo( RECT &rect, const char *pchName, float
|
||||
char rgchBuffer[256];
|
||||
_snprintf( rgchBuffer, sizeof( rgchBuffer), "%s: %.1f", pchName, flValue );
|
||||
m_pGameEngine->BDrawString( m_hDisplayFont, rect, D3DCOLOR_ARGB( 255, 25, 200, 25 ), TEXTPOS_LEFT|TEXTPOS_VCENTER, rgchBuffer );
|
||||
}
|
||||
|
||||
bool CStatsAndAchievements::LoadUserStatsOnPS3()
|
||||
{
|
||||
#ifdef _PS3
|
||||
// On PS3, we need to load the user's stats & achievement information from the save container. In this example, we are simply
|
||||
// reading the data from a known location on disk
|
||||
FILE *file = fopen( GetUserSaveDataPath(), "rb" );
|
||||
if ( !file )
|
||||
{
|
||||
// we need to tell Steam that there is no data
|
||||
SteamUserStats()->SetUserStatsData( NULL, 0 );
|
||||
return true;
|
||||
}
|
||||
|
||||
fseek( file, 0, SEEK_END );
|
||||
long nSize = ftell( file );
|
||||
fseek( file, 0, SEEK_SET );
|
||||
|
||||
byte *buffer = new byte[nSize];
|
||||
fread( buffer, 1, nSize, file );
|
||||
fclose( file );
|
||||
|
||||
bool bRet = SteamUserStats()->SetUserStatsData( buffer, nSize );
|
||||
delete [] buffer;
|
||||
|
||||
return bRet;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CStatsAndAchievements::SaveUserStatsOnPS3()
|
||||
{
|
||||
#ifdef _PS3
|
||||
// On PS3, we need to save the user's stats & achievement information into the save container. In this example, we are simply
|
||||
// saving the data to a known location on disk
|
||||
|
||||
// get required buffer size
|
||||
uint32 unSize = 0;
|
||||
if ( !SteamUserStats()->GetUserStatsData( NULL, 0, &unSize ) && unSize == 0 )
|
||||
return false;
|
||||
|
||||
// get data
|
||||
byte *buffer = new byte[unSize];
|
||||
uint32 unWritten = 0;
|
||||
bool bRet = SteamUserStats()->GetUserStatsData( buffer, unSize, &unWritten );
|
||||
if ( bRet )
|
||||
{
|
||||
FILE *file = fopen( GetUserSaveDataPath(), "wb" );
|
||||
if ( file )
|
||||
{
|
||||
bRet = (fwrite( buffer, 1, unWritten, file ) == unWritten);
|
||||
fclose( file );
|
||||
}
|
||||
else
|
||||
{
|
||||
bRet = false;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] buffer;
|
||||
|
||||
return bRet;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
@@ -58,6 +58,8 @@ public:
|
||||
STEAM_CALLBACK( CStatsAndAchievements, OnUserStatsReceived, UserStatsReceived_t, m_CallbackUserStatsReceived );
|
||||
STEAM_CALLBACK( CStatsAndAchievements, OnUserStatsStored, UserStatsStored_t, m_CallbackUserStatsStored );
|
||||
STEAM_CALLBACK( CStatsAndAchievements, OnAchievementStored, UserAchievementStored_t, m_CallbackAchievementStored );
|
||||
STEAM_CALLBACK( CStatsAndAchievements, OnPS3TrophiesInstalled, PS3TrophiesInstalled_t, m_CallbackPS3TrophiesInstalled );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -72,6 +74,10 @@ private:
|
||||
void DrawAchievementInfo( RECT &rect, Achievement_t &ach );
|
||||
void DrawStatInfo( RECT &rect, const char *pchName, float flValue );
|
||||
|
||||
// PS3 specific
|
||||
bool LoadUserStatsOnPS3();
|
||||
bool SaveUserStatsOnPS3();
|
||||
|
||||
// our GameID
|
||||
CGameID m_GameID;
|
||||
|
||||
@@ -106,6 +112,10 @@ private:
|
||||
float m_flTotalFeetTraveled;
|
||||
float m_flMaxFeetTraveled;
|
||||
float m_flAverageSpeed;
|
||||
|
||||
// PS3 specific
|
||||
bool m_bStartedPS3TrophyInstall;
|
||||
bool m_bInstalledPS3Trophies;
|
||||
};
|
||||
|
||||
#endif // STATS_AND_ACHIEVEMENTS_H
|
||||
+21
-10
@@ -131,13 +131,19 @@ typedef unsigned char uint8;
|
||||
#define VK_DOWN 0x28
|
||||
#define VK_SELECT 0x29
|
||||
|
||||
typedef struct tagRECT
|
||||
{
|
||||
LONG left;
|
||||
LONG top;
|
||||
LONG right;
|
||||
LONG bottom;
|
||||
} RECT;
|
||||
#ifndef VALVE_RECT_DEFINED
|
||||
#define VALVE_RECT_DEFINED
|
||||
|
||||
typedef struct tagRECT
|
||||
{
|
||||
LONG left;
|
||||
LONG top;
|
||||
LONG right;
|
||||
LONG bottom;
|
||||
} RECT;
|
||||
|
||||
#define _RECT tagRECT
|
||||
#endif
|
||||
|
||||
#define D3DCOLOR_ARGB(a,r,g,b) \
|
||||
((DWORD)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
|
||||
@@ -161,6 +167,9 @@ typedef struct tagRECT
|
||||
#define DWARGB_TO_DWABGR(color) \
|
||||
((DWORD)(( (((((color)>>24)&0xff))<<24)|(((((color))&0xff))<<16)|(((color>>8)&0xff)<<8)|((color)>>16)&0xff)))
|
||||
|
||||
#define DWRGBA_TO_DWARGB(color) \
|
||||
((DWORD)(( (((((color))&0xff))<<24)|(((((color>>24))&0xff))<<16)|(((color>>16)&0xff)<<8)|((color)>>8)&0xff)))
|
||||
|
||||
// steam api header file
|
||||
#include "steam/steam_api.h"
|
||||
#include "steam/isteamuserstats.h"
|
||||
@@ -169,6 +178,8 @@ typedef struct tagRECT
|
||||
#include "steam/steam_gameserver.h"
|
||||
|
||||
extern void OutputDebugString( const char *pchMsg );
|
||||
extern int Alert( const char *lpCaption, const char *lpText );
|
||||
extern const char *GetUserSaveDataPath();
|
||||
|
||||
// No _snprintf on POSIX, use snprintf
|
||||
#ifndef _snprintf
|
||||
@@ -184,8 +195,8 @@ extern void OutputDebugString( const char *pchMsg );
|
||||
#include "cegclient.h"
|
||||
#else
|
||||
#define Steamworks_InitCEGLibrary() (true)
|
||||
#define Steamworks_TermCEGLibrary() (true)
|
||||
#define Steamworks_TestSecret() (true)
|
||||
#define Steamworks_SelfCheck() (true)
|
||||
#define Steamworks_TermCEGLibrary()
|
||||
#define Steamworks_TestSecret()
|
||||
#define Steamworks_SelfCheck()
|
||||
#endif
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
================================================================
|
||||
|
||||
Copyright © 1996-2011, Valve Corporation, All rights reserved.
|
||||
|
||||
================================================================
|
||||
|
||||
OSX DirectX to OpenGL Conversion Library
|
||||
|
||||
Contains all support files required to assist in converting DirectX applications to OpenGL on OSX. For reference,
|
||||
this library can be enabled in the Steamworks Example by building with the compile time flag DX9MODE=1.
|
||||
|
||||
@@ -0,0 +1,362 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// cglmbuffer.cpp
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "glmgr.h"
|
||||
#include "glmdisplay.h"
|
||||
#include "cglmbuffer.h"
|
||||
|
||||
// void BindBufferARB(enum target, uint buffer);
|
||||
// void DeleteBuffersARB(sizei n, const uint *buffers);
|
||||
// void GenBuffersARB(sizei n, uint *buffers);
|
||||
// boolean IsBufferARB(uint buffer);
|
||||
//
|
||||
// void BufferDataARB(enum target, sizeiptrARB size, const void *data,
|
||||
// enum usage);
|
||||
// void BufferSubDataARB(enum target, intptrARB offset, sizeiptrARB size,
|
||||
// const void *data);
|
||||
// void GetBufferSubDataARB(enum target, intptrARB offset,
|
||||
// sizeiptrARB size, void *data);
|
||||
//
|
||||
// void *MapBufferARB(enum target, enum access);
|
||||
// boolean UnmapBufferARB(enum target);
|
||||
//
|
||||
// void GetBufferParameterivARB(enum target, enum pname, int *params);
|
||||
// void GetBufferPointervARB(enum target, enum pname, void **params);
|
||||
//
|
||||
//New Tokens
|
||||
//
|
||||
// Accepted by the <target> parameters of BindBufferARB, BufferDataARB,
|
||||
// BufferSubDataARB, MapBufferARB, UnmapBufferARB,
|
||||
// GetBufferSubDataARB, GetBufferParameterivARB, and
|
||||
// GetBufferPointervARB:
|
||||
//
|
||||
// ARRAY_BUFFER_ARB 0x8892
|
||||
// ELEMENT_ARRAY_BUFFER_ARB 0x8893
|
||||
//
|
||||
// Accepted by the <pname> parameter of GetBooleanv, GetIntegerv,
|
||||
// GetFloatv, and GetDoublev:
|
||||
//
|
||||
// ARRAY_BUFFER_BINDING_ARB 0x8894
|
||||
// ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
|
||||
// VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
|
||||
// NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
|
||||
// COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
|
||||
// INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
|
||||
// TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
|
||||
// EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
|
||||
// SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
|
||||
// FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
|
||||
// WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
|
||||
//
|
||||
// Accepted by the <pname> parameter of GetVertexAttribivARB:
|
||||
//
|
||||
// VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
|
||||
//
|
||||
// Accepted by the <usage> parameter of BufferDataARB:
|
||||
//
|
||||
// STREAM_DRAW_ARB 0x88E0
|
||||
// STREAM_READ_ARB 0x88E1
|
||||
// STREAM_COPY_ARB 0x88E2
|
||||
// STATIC_DRAW_ARB 0x88E4
|
||||
// STATIC_READ_ARB 0x88E5
|
||||
// STATIC_COPY_ARB 0x88E6
|
||||
// DYNAMIC_DRAW_ARB 0x88E8
|
||||
// DYNAMIC_READ_ARB 0x88E9
|
||||
// DYNAMIC_COPY_ARB 0x88EA
|
||||
//
|
||||
// Accepted by the <access> parameter of MapBufferARB:
|
||||
//
|
||||
// READ_ONLY_ARB 0x88B8
|
||||
// WRITE_ONLY_ARB 0x88B9
|
||||
// READ_WRITE_ARB 0x88BA
|
||||
//
|
||||
// Accepted by the <pname> parameter of GetBufferParameterivARB:
|
||||
//
|
||||
// BUFFER_SIZE_ARB 0x8764
|
||||
// BUFFER_USAGE_ARB 0x8765
|
||||
// BUFFER_ACCESS_ARB 0x88BB
|
||||
// BUFFER_MAPPED_ARB 0x88BC
|
||||
//
|
||||
// Accepted by the <pname> parameter of GetBufferPointervARB:
|
||||
//
|
||||
// BUFFER_MAP_POINTER_ARB 0x88BD
|
||||
|
||||
// http://www.opengl.org/registry/specs/ARB/pixel_buffer_object.txt
|
||||
// Accepted by the <target> parameters of BindBuffer, BufferData,
|
||||
// BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
|
||||
// GetBufferParameteriv, and GetBufferPointerv:
|
||||
// PIXEL_PACK_BUFFER_ARB 0x88EB
|
||||
// PIXEL_UNPACK_BUFFER_ARB 0x88EC
|
||||
|
||||
|
||||
// gl_bufmode: zero means we mark all vertex/index buffers static
|
||||
|
||||
// non zero means buffers are initially marked static..
|
||||
// ->but can shift to dynamic upon first 'discard' (orphaning)
|
||||
|
||||
//ConVar gl_bufmode( "gl_bufmode", "1" );
|
||||
int gl_bufmode = 1;
|
||||
|
||||
CGLMBuffer::CGLMBuffer( GLMContext *ctx, EGLMBufferType type, uint size, uint options )
|
||||
{
|
||||
m_ctx = ctx;
|
||||
m_type = type;
|
||||
switch(m_type)
|
||||
{
|
||||
case kGLMVertexBuffer: m_buffGLTarget = GL_ARRAY_BUFFER_ARB; break;
|
||||
case kGLMIndexBuffer: m_buffGLTarget = GL_ELEMENT_ARRAY_BUFFER_ARB; break;
|
||||
case kGLMUniformBuffer: m_buffGLTarget = GL_UNIFORM_BUFFER_EXT; break;
|
||||
case kGLMPixelBuffer: m_buffGLTarget = GL_PIXEL_UNPACK_BUFFER_ARB; break;
|
||||
|
||||
default: //Assert(!"Unknown buffer type" );
|
||||
break;
|
||||
}
|
||||
m_size = size;
|
||||
m_bound = false;
|
||||
m_mapped = false;
|
||||
m_lastMappedAddress = NULL;
|
||||
|
||||
m_enableAsyncMap = false;
|
||||
m_enableExplicitFlush = false;
|
||||
m_dirtyMinOffset = m_dirtyMaxOffset = 0; // adjust/grow on lock, clear on unlock
|
||||
|
||||
m_ctx->CheckCurrent();
|
||||
m_revision = rand();
|
||||
|
||||
// make a decision about pseudo mode
|
||||
// this looked like it didn't help much or was actually slower, so leave it available but only as opt-in.
|
||||
// a more clever implementation would be able to select pseudo buf storage for small batches only..
|
||||
m_pseudo = false; // (m_type==kGLMIndexBuffer) && (CommandLine()->FindParm("-gl_enable_pseudobufs"));
|
||||
if (m_pseudo)
|
||||
{
|
||||
m_name = 0;
|
||||
m_pseudoBuf = (char*)malloc( size );
|
||||
|
||||
m_ctx->BindBufferToCtx( m_type, NULL ); // exit with no buffer bound
|
||||
}
|
||||
else
|
||||
{
|
||||
glGenBuffersARB( 1, &m_name );
|
||||
GLMCheckError();
|
||||
|
||||
m_ctx->BindBufferToCtx( m_type, this ); // causes glBindBufferARB
|
||||
|
||||
// buffers start out static, but if they get orphaned and gl_bufmode is non zero,
|
||||
// then they will get flipped to dynamic.
|
||||
|
||||
GLenum hint = GL_STATIC_DRAW_ARB;
|
||||
switch(m_type)
|
||||
{
|
||||
case kGLMVertexBuffer: hint = (options & GLMBufferOptionDynamic) ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB; break;
|
||||
case kGLMIndexBuffer: hint = (options & GLMBufferOptionDynamic) ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB; break;
|
||||
case kGLMUniformBuffer: hint = GL_DYNAMIC_DRAW_ARB; break; // "fwiw" - shrug
|
||||
case kGLMPixelBuffer: hint = (options & GLMBufferOptionDynamic) ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB; break;
|
||||
|
||||
default: //Assert(!"Unknown buffer type" );
|
||||
break;
|
||||
}
|
||||
|
||||
glBufferDataARB( m_buffGLTarget, m_size, NULL, hint ); // may ultimately need more hints to set the usage correctly (esp for streaming)
|
||||
|
||||
this->SetModes( false, true, true );
|
||||
|
||||
m_ctx->BindBufferToCtx( m_type, NULL ); // unbind me
|
||||
}
|
||||
}
|
||||
|
||||
CGLMBuffer::~CGLMBuffer( )
|
||||
{
|
||||
m_ctx->CheckCurrent();
|
||||
|
||||
if (m_pseudo)
|
||||
{
|
||||
free (m_pseudoBuf);
|
||||
m_pseudoBuf = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
glDeleteBuffersARB( 1, &m_name );
|
||||
GLMCheckError();
|
||||
}
|
||||
|
||||
m_ctx = NULL;
|
||||
m_name = 0;
|
||||
m_bound = 0;
|
||||
|
||||
m_lastMappedAddress = NULL;
|
||||
}
|
||||
|
||||
void CGLMBuffer::SetModes ( bool asyncMap, bool explicitFlush, bool force )
|
||||
{
|
||||
// assumes buffer is bound. called by constructor and by Lock.
|
||||
|
||||
if (m_pseudo)
|
||||
{
|
||||
// ignore it...
|
||||
}
|
||||
else
|
||||
{
|
||||
if (force || (m_enableAsyncMap != asyncMap) )
|
||||
{
|
||||
// note the sense of the parameter, it's TRUE if you *want* serialization, so for async you turn it to false.
|
||||
glBufferParameteriAPPLE( this->m_buffGLTarget, GL_BUFFER_SERIALIZED_MODIFY_APPLE, asyncMap==false );
|
||||
m_enableAsyncMap = asyncMap;
|
||||
}
|
||||
|
||||
if (force || (m_enableExplicitFlush != explicitFlush) )
|
||||
{
|
||||
// note the sense of the parameter, it's TRUE if you *want* auto-flush-on-unmap, so for explicit-flush, you turn it to false.
|
||||
glBufferParameteriAPPLE( this->m_buffGLTarget, GL_BUFFER_FLUSHING_UNMAP_APPLE, explicitFlush==false );
|
||||
m_enableExplicitFlush = explicitFlush;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGLMBuffer::FlushRange ( uint offset, uint size )
|
||||
{
|
||||
if (m_pseudo)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
else
|
||||
{
|
||||
// assumes buffer is bound.
|
||||
glFlushMappedBufferRangeAPPLE(this->m_buffGLTarget, (GLintptr)offset, (GLsizeiptr)size);
|
||||
}
|
||||
}
|
||||
|
||||
//ConVar gl_buffer_alignment_quantum ( "gl_buffer_alignment_quantum", "32" ); // the alignment we use pre-SLGU
|
||||
//ConVar gl_buffer_alignment_quantum_slgu( "gl_buffer_alignment_quantum_slgu", "2" ); // alignment used post-SLGU
|
||||
|
||||
int gl_buffer_alignment_quantum = 32;
|
||||
int gl_buffer_alignment_quantum_slgu = 2;
|
||||
|
||||
void CGLMBuffer::Lock( GLMBuffLockParams *params, char **addressOut )
|
||||
{
|
||||
char *resultPtr = NULL;
|
||||
|
||||
//Assert( !m_mapped);
|
||||
|
||||
m_ctx->CheckCurrent();
|
||||
GLMCheckError();
|
||||
|
||||
if (params->m_offset >= m_size)
|
||||
Debugger();
|
||||
|
||||
if (params->m_offset + params->m_size > m_size)
|
||||
Debugger();
|
||||
|
||||
// bind (yes, even for pseudo - this binds name 0)
|
||||
m_ctx->BindBufferToCtx( this->m_type, this );
|
||||
|
||||
if (m_pseudo)
|
||||
{
|
||||
// discard is a no-op
|
||||
|
||||
// async map modes are a no-op
|
||||
|
||||
// latch last mapped address (silly..)
|
||||
m_lastMappedAddress = (float*)m_pseudoBuf;
|
||||
|
||||
// calc lock address
|
||||
resultPtr = m_pseudoBuf + params->m_offset;
|
||||
|
||||
// dirty range is a no-op
|
||||
}
|
||||
else
|
||||
{
|
||||
// perform discard if requested
|
||||
if (params->m_discard)
|
||||
{
|
||||
// observe gl_bufmode on any orphan event.
|
||||
// if orphaned and bufmode is nonzero, flip it to dynamic.
|
||||
GLenum hint = gl_bufmode /*.GetInt()*/ ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB;
|
||||
glBufferDataARB( m_buffGLTarget, m_size, NULL, hint );
|
||||
|
||||
m_lastMappedAddress = NULL;
|
||||
|
||||
m_revision++; // revision grows on orphan event
|
||||
}
|
||||
|
||||
// adjust async map option appropriately, leave explicit flush unchanged
|
||||
this->SetModes( params->m_nonblocking, m_enableExplicitFlush );
|
||||
|
||||
// map
|
||||
char *mapPtr = (char*)glMapBufferARB( this->m_buffGLTarget, GL_READ_WRITE_ARB );
|
||||
|
||||
if (!mapPtr)
|
||||
{
|
||||
Debugger();
|
||||
}
|
||||
|
||||
if (m_lastMappedAddress)
|
||||
{
|
||||
// just check if it moved
|
||||
//Assert (m_lastMappedAddress == (float*)mapPtr);
|
||||
}
|
||||
|
||||
m_lastMappedAddress = (float*)mapPtr;
|
||||
|
||||
// calculate offset location
|
||||
resultPtr = mapPtr + params->m_offset;
|
||||
|
||||
// adjust dirty range
|
||||
if (m_dirtyMinOffset != m_dirtyMaxOffset)
|
||||
{
|
||||
// grow range
|
||||
m_dirtyMinOffset = std::min( m_dirtyMinOffset, params->m_offset );
|
||||
m_dirtyMaxOffset = std::min( m_dirtyMaxOffset, params->m_offset+params->m_size );
|
||||
}
|
||||
else
|
||||
{
|
||||
// set range
|
||||
m_dirtyMinOffset = params->m_offset;
|
||||
m_dirtyMaxOffset = params->m_offset+params->m_size;
|
||||
}
|
||||
|
||||
// pad and clamp dirty range to choice of boundary
|
||||
uint quantum = (m_ctx->Caps().m_hasPerfPackage1) ? gl_buffer_alignment_quantum_slgu /*.GetInt()*/ : gl_buffer_alignment_quantum /*.GetInt()*/ ;
|
||||
uint quantum_mask = quantum - 1;
|
||||
|
||||
m_dirtyMinOffset = m_dirtyMinOffset & (~quantum_mask);
|
||||
m_dirtyMaxOffset = (m_dirtyMaxOffset + quantum_mask) & (~quantum_mask);
|
||||
m_dirtyMaxOffset = std::min( m_dirtyMaxOffset, m_size );
|
||||
}
|
||||
|
||||
m_mapped = true;
|
||||
|
||||
*addressOut = resultPtr;
|
||||
}
|
||||
|
||||
void CGLMBuffer::Unlock( void )
|
||||
{
|
||||
m_ctx->CheckCurrent();
|
||||
|
||||
//Assert (m_mapped);
|
||||
|
||||
if (m_pseudo)
|
||||
{
|
||||
// nothing to do actually
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ctx->BindBufferToCtx( this->m_type, this );
|
||||
|
||||
// time to do explicit flush
|
||||
if (m_enableExplicitFlush)
|
||||
{
|
||||
this->FlushRange( m_dirtyMinOffset, m_dirtyMaxOffset - m_dirtyMinOffset );
|
||||
}
|
||||
|
||||
// clear dirty range no matter what
|
||||
m_dirtyMinOffset = m_dirtyMaxOffset = 0; // adjust/grow on lock, clear on unlock
|
||||
|
||||
glUnmapBuffer( this->m_buffGLTarget );
|
||||
|
||||
}
|
||||
|
||||
m_mapped = false;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// cglmprogram.h
|
||||
// GLMgr buffers (index / vertex)
|
||||
// ... maybe add PBO later as well
|
||||
//===============================================================================
|
||||
|
||||
#ifndef CGLMBUFFER_H
|
||||
#define CGLMBUFFER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
// ext links
|
||||
|
||||
// http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// forward declarations
|
||||
|
||||
class GLMContext;
|
||||
|
||||
enum EGLMBufferType
|
||||
{
|
||||
kGLMVertexBuffer,
|
||||
kGLMIndexBuffer,
|
||||
kGLMUniformBuffer, // for bindable uniform
|
||||
kGLMPixelBuffer, // for PBO
|
||||
|
||||
kGLMNumBufferTypes
|
||||
};
|
||||
|
||||
// pass this in "options" to constructor to make a dynamic buffer
|
||||
#define GLMBufferOptionDynamic 0x00000001
|
||||
|
||||
struct GLMBuffLockParams
|
||||
{
|
||||
uint m_offset;
|
||||
uint m_size;
|
||||
bool m_nonblocking;
|
||||
bool m_discard;
|
||||
};
|
||||
|
||||
class CGLMBuffer
|
||||
{
|
||||
|
||||
public:
|
||||
void Lock( GLMBuffLockParams *params, char **addressOut );
|
||||
void Unlock( void );
|
||||
|
||||
//protected:
|
||||
friend class GLMContext; // only GLMContext can make CGLMBuffer objects
|
||||
friend class GLMTester;
|
||||
friend class IDirect3D9;
|
||||
friend class IDirect3DDevice9;
|
||||
|
||||
CGLMBuffer ( GLMContext *ctx, EGLMBufferType type, uint size, uint options );
|
||||
~CGLMBuffer ( );
|
||||
|
||||
void SetModes ( bool asyncMap, bool explicitFlush, bool force = false );
|
||||
void FlushRange ( uint offset, uint size );
|
||||
|
||||
GLMContext *m_ctx; // link back to parent context
|
||||
EGLMBufferType m_type;
|
||||
uint m_size;
|
||||
GLenum m_buffGLTarget; // GL_ARRAY_BUFFER_ARB / GL_ELEMENT_BUFFER_ARB
|
||||
GLuint m_name; // name of this program in the context
|
||||
uint m_revision; // bump anytime the size changes or buffer is orphaned
|
||||
bool m_enableAsyncMap; // mirror of the buffer state
|
||||
bool m_enableExplicitFlush; // mirror of the buffer state
|
||||
|
||||
bool m_bound; // true if bound to context
|
||||
bool m_mapped; // is it currently mapped
|
||||
uint m_dirtyMinOffset; // when equal, range is empty
|
||||
uint m_dirtyMaxOffset;
|
||||
|
||||
float *m_lastMappedAddress;
|
||||
|
||||
// --------------------- pseudo-VBO support below here (explicitly for dynamic index buffers)
|
||||
bool m_pseudo; // true if the m_name is 0, and the backing is plain RAM
|
||||
|
||||
// in pseudo mode, there is just one RAM buffer that acts as the backing.
|
||||
// expectation is that this mode would only be used for dynamic indices.
|
||||
// since indices have to be consumed (copied to command stream) prior to return from a drawing call,
|
||||
// there's no need to do any fencing or multibuffering. orphaning in particular becomes a no-op.
|
||||
|
||||
char *m_pseudoBuf; // storage for pseudo buffer
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,352 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// cglmfbo.cpp
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "glmgr.h"
|
||||
#include "cglmfbo.h"
|
||||
// #include "../shaderapidx9/dxabstract.h"
|
||||
|
||||
|
||||
|
||||
CGLMFBO::CGLMFBO( GLMContext *ctx )
|
||||
{
|
||||
m_ctx = ctx;
|
||||
m_ctx->CheckCurrent();
|
||||
|
||||
glGenFramebuffersEXT( 1, &m_name );
|
||||
GLMCheckError();
|
||||
|
||||
memset( m_attach, 0, sizeof( m_attach ) );
|
||||
|
||||
m_sizeX = m_sizeY = 0;
|
||||
}
|
||||
|
||||
|
||||
CGLMFBO::~CGLMFBO( )
|
||||
{
|
||||
m_ctx->CheckCurrent();
|
||||
|
||||
// detach all known attached textures first... necessary ?
|
||||
for( int index = 0; index < kAttCount; index++)
|
||||
{
|
||||
if (m_attach[ index ].m_tex)
|
||||
{
|
||||
TexDetach( (EGLMFBOAttachment)index );
|
||||
GLMCheckError();
|
||||
}
|
||||
}
|
||||
|
||||
glDeleteFramebuffersEXT( 1, &m_name );
|
||||
GLMCheckError();
|
||||
|
||||
m_name = 0;
|
||||
m_ctx = NULL;
|
||||
}
|
||||
|
||||
// the tex attach path should also select a specific slice of the texture...
|
||||
// and we need a way to make renderbuffers..
|
||||
|
||||
static GLenum EncodeAttachmentFBO( EGLMFBOAttachment index )
|
||||
{
|
||||
if (index < kAttDepth)
|
||||
{
|
||||
return GL_COLOR_ATTACHMENT0_EXT + (int) index;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( index )
|
||||
{
|
||||
case kAttDepth:
|
||||
return GL_DEPTH_ATTACHMENT_EXT;
|
||||
break;
|
||||
|
||||
case kAttStencil:
|
||||
return GL_STENCIL_ATTACHMENT_EXT;
|
||||
break;
|
||||
|
||||
case kAttDepthStencil:
|
||||
return GL_DEPTH_STENCIL_ATTACHMENT_EXT;
|
||||
break;
|
||||
|
||||
default:
|
||||
GLMStop(); // bad news
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGLMFBO::TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint )
|
||||
{
|
||||
// force our parent context to be current
|
||||
m_ctx->MakeCurrent();
|
||||
|
||||
// bind to context (will cause FBO object creation on first use)
|
||||
m_ctx->BindFBOToCtx( this, fboBindPoint );
|
||||
|
||||
// it's either a plain 2D, a 2D face of a cube map, or a slice of a 3D.
|
||||
CGLMTex *tex = params->m_tex;
|
||||
|
||||
// always detach what is currently there, if anything
|
||||
this->TexDetach( attachIndex, fboBindPoint );
|
||||
|
||||
if (!tex)
|
||||
{
|
||||
// andif they pass NULL to us, then we are done.
|
||||
return;
|
||||
}
|
||||
|
||||
GLMTexLayout *layout = tex->m_layout;
|
||||
GLenum target = tex->m_layout->m_key.m_texGLTarget;
|
||||
|
||||
GLenum attachIndexGL = EncodeAttachmentFBO( attachIndex );
|
||||
|
||||
switch( target )
|
||||
{
|
||||
case GL_TEXTURE_2D:
|
||||
{
|
||||
// we will attach the underlying RBO on a multisampled tex, iff the tex hasone, **and** we're not being asked to attach it to the read buffer.
|
||||
// if we get a req to attach an MSAA tex to the read buffer, chances are it's BlitTex calling, andit has already resolved the tex, so in those
|
||||
// cases you really do want to attach the texture and not the RBO to the FBO in question.
|
||||
|
||||
bool useRBO = false; // initial state
|
||||
|
||||
if (layout->m_key.m_texFlags & kGLMTexMultisampled)
|
||||
{
|
||||
// it is an MSAA tex
|
||||
if (fboBindPoint == GL_READ_FRAMEBUFFER_EXT)
|
||||
{
|
||||
// I think you just want to read a resolved tex.
|
||||
// But I will check that it is resolved first..
|
||||
Assert( tex->m_rboDirty == false );
|
||||
}
|
||||
else
|
||||
{
|
||||
// you want to draw into it. You get the RBO bound instead of the tex.
|
||||
useRBO = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (useRBO)
|
||||
{
|
||||
// MSAA path - attach the RBO, not the texture, and mark the RBO dirty
|
||||
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
|
||||
{
|
||||
// you have to attach it both places...
|
||||
// http://www.opengl.org/wiki/GL_EXT_framebuffer_object
|
||||
|
||||
// bind the RBO to the GL_RENDERBUFFER_EXT target
|
||||
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, tex->m_rboName );
|
||||
GLMCheckError();
|
||||
|
||||
// attach the GL_RENDERBUFFER_EXT target to the depth and stencil attach points
|
||||
glFramebufferRenderbufferEXT( fboBindPoint, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, tex->m_rboName);
|
||||
GLMCheckError();
|
||||
|
||||
glFramebufferRenderbufferEXT( fboBindPoint, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, tex->m_rboName);
|
||||
GLMCheckError();
|
||||
|
||||
// no need to leave the RBO hanging on
|
||||
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
|
||||
GLMCheckError();
|
||||
}
|
||||
else
|
||||
{
|
||||
// color attachment (likely 0)
|
||||
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, tex->m_rboName );
|
||||
GLMCheckError();
|
||||
|
||||
glFramebufferRenderbufferEXT( fboBindPoint, attachIndexGL, GL_RENDERBUFFER_EXT, tex->m_rboName);
|
||||
GLMCheckError();
|
||||
|
||||
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
|
||||
GLMCheckError();
|
||||
}
|
||||
tex->m_rboDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// regular path - attaching a texture2d
|
||||
|
||||
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
|
||||
{
|
||||
// you have to attach it both places...
|
||||
// http://www.opengl.org/wiki/GL_EXT_framebuffer_object
|
||||
|
||||
glFramebufferTexture2DEXT( fboBindPoint, GL_DEPTH_ATTACHMENT_EXT, target, tex->m_texName, params->m_mip );
|
||||
GLMCheckError();
|
||||
|
||||
glFramebufferTexture2DEXT( fboBindPoint, GL_STENCIL_ATTACHMENT_EXT, target, tex->m_texName, params->m_mip );
|
||||
GLMCheckError();
|
||||
}
|
||||
else
|
||||
{
|
||||
glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip );
|
||||
GLMCheckError();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_3D:
|
||||
{
|
||||
glFramebufferTexture3DEXT( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip, params->m_zslice );
|
||||
GLMCheckError();
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
{
|
||||
// adjust target to steer to the proper face of the cube map
|
||||
target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + params->m_face;
|
||||
|
||||
glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip );
|
||||
GLMCheckError();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// log the attached tex
|
||||
m_attach[ attachIndex ] = *params;
|
||||
|
||||
// indicate that the tex has been bound to an RT
|
||||
tex->m_rtAttachCount++;
|
||||
}
|
||||
|
||||
void CGLMFBO::TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint )
|
||||
{
|
||||
// force our parent context to be current
|
||||
m_ctx->MakeCurrent();
|
||||
|
||||
// bind to context (will cause FBO object creation on first use)
|
||||
m_ctx->BindFBOToCtx( this, fboBindPoint );
|
||||
|
||||
if (m_attach[ attachIndex ].m_tex)
|
||||
{
|
||||
CGLMTex *tex = m_attach[ attachIndex ].m_tex;
|
||||
GLMTexLayout *layout = tex->m_layout;
|
||||
GLenum target = tex->m_layout->m_key.m_texGLTarget;
|
||||
|
||||
GLenum attachIndexGL = EncodeAttachmentFBO( attachIndex );
|
||||
|
||||
switch( target )
|
||||
{
|
||||
case GL_TEXTURE_2D:
|
||||
{
|
||||
if (layout->m_key.m_texFlags & kGLMTexMultisampled)
|
||||
{
|
||||
// MSAA path - detach the RBO, not the texture
|
||||
// (is this the right time to resolve? probably better to wait until someone tries to sample the texture)
|
||||
|
||||
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
|
||||
GLMCheckError();
|
||||
|
||||
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
|
||||
{
|
||||
// detach the GL_RENDERBUFFER_EXT target at depth and stencil attach points
|
||||
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
|
||||
GLMCheckError();
|
||||
|
||||
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
|
||||
GLMCheckError();
|
||||
}
|
||||
else
|
||||
{
|
||||
// color attachment (likely 0)
|
||||
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, attachIndexGL, GL_RENDERBUFFER_EXT, 0);
|
||||
GLMCheckError();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// plain tex detach
|
||||
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
|
||||
{
|
||||
// you have to detach it both places...
|
||||
// http://www.opengl.org/wiki/GL_EXT_framebuffer_object
|
||||
|
||||
glFramebufferTexture2DEXT( fboBindPoint, GL_DEPTH_ATTACHMENT_EXT, 0,0,0 );
|
||||
glFramebufferTexture2DEXT( fboBindPoint, GL_STENCIL_ATTACHMENT_EXT, 0,0,0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_3D:
|
||||
{
|
||||
glFramebufferTexture3DEXT( fboBindPoint, attachIndexGL, 0, 0, 0, 0 );
|
||||
GLMCheckError();
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
{
|
||||
glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, 0, 0, 0 );
|
||||
GLMCheckError();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// un-log the attached tex
|
||||
memset( &m_attach[ attachIndex ], 0, sizeof( m_attach[0] ) );
|
||||
|
||||
// drop the RT attach count
|
||||
tex->m_rtAttachCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debugger(); // odd, but not harmful - typ comes from D3D code passing NULL into SetRenderTarget
|
||||
}
|
||||
}
|
||||
|
||||
void CGLMFBO::TexScrub( CGLMTex *tex )
|
||||
{
|
||||
// see if it's attached anywhere
|
||||
for( int attachIndex = 0; attachIndex < kAttCount; attachIndex++ )
|
||||
{
|
||||
if (m_attach[ attachIndex ].m_tex == tex)
|
||||
{
|
||||
// blammo
|
||||
TexDetach( (EGLMFBOAttachment)attachIndex, GL_DRAW_FRAMEBUFFER_EXT );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CGLMFBO::IsReady( void )
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
// ensure our parent context is current
|
||||
m_ctx->CheckCurrent();
|
||||
|
||||
// bind to context (will cause FBO object creation on first use)
|
||||
m_ctx->BindFBOToCtx( this );
|
||||
|
||||
GLenum status;
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
switch(status)
|
||||
{
|
||||
case GL_FRAMEBUFFER_COMPLETE_EXT:
|
||||
result = true;
|
||||
break;
|
||||
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
|
||||
result = false;
|
||||
Debugger();
|
||||
/* choose different formats */
|
||||
break;
|
||||
|
||||
default:
|
||||
result = false;
|
||||
Debugger();
|
||||
/* programming error; will fail on all hardware */
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// cglmfbo.h
|
||||
// GLMgr FBO's (render targets)
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef CGLMFBO_H
|
||||
#define CGLMFBO_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cglmtex.h"
|
||||
|
||||
// good FBO references / recaps
|
||||
// http://www.songho.ca/opengl/gl_fbo.html
|
||||
// http://www.gamedev.net/reference/articles/article2331.asp
|
||||
|
||||
// ext links
|
||||
|
||||
// http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt
|
||||
// http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// tokens not in the SDK headers
|
||||
|
||||
#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT
|
||||
#define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9
|
||||
#endif
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// forward declarations
|
||||
|
||||
class GLMContext;
|
||||
|
||||
// implicitly 16 maximum color attachments possible
|
||||
enum EGLMFBOAttachment {
|
||||
kAttColor0, kAttColor1, kAttColor2, kAttColor3,
|
||||
kAttColor4, kAttColor5, kAttColor6, kAttColor7,
|
||||
kAttColor8, kAttColor9, kAttColor10, kAttColor11,
|
||||
kAttColor12, kAttColor13, kAttColor14, kAttColor15,
|
||||
kAttDepth, kAttStencil, kAttDepthStencil,
|
||||
kAttCount
|
||||
};
|
||||
|
||||
struct GLMFBOTexAttachParams
|
||||
{
|
||||
CGLMTex *m_tex;
|
||||
int m_face; // keep zero if not cube map
|
||||
int m_mip; // keep zero if notmip mapped
|
||||
int m_zslice; // keep zero if not a 3D tex
|
||||
};
|
||||
|
||||
class CGLMFBO
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
protected:
|
||||
friend class GLMContext; // only GLMContext can make CGLMFBO objects
|
||||
friend class GLMTester;
|
||||
friend class CGLMTex;
|
||||
|
||||
friend class IDirect3D9;
|
||||
friend class IDirect3DDevice9;
|
||||
|
||||
CGLMFBO( GLMContext *ctx );
|
||||
~CGLMFBO( );
|
||||
|
||||
void TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT );
|
||||
void TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT );
|
||||
// you can also pass GL_READ_FRAMEBUFFER_EXT or GL_DRAW_FRAMEBUFFER_EXT to selectively bind the receiving FBO to one or the other.
|
||||
|
||||
void TexScrub( CGLMTex *tex );
|
||||
// search and destroy any attachment for the named texture
|
||||
|
||||
bool IsReady( void ); // aka FBO completeness check - ready to draw
|
||||
|
||||
GLMContext *m_ctx; // link back to parent context
|
||||
|
||||
GLuint m_name; // name of this FBO in the context
|
||||
|
||||
GLMFBOTexAttachParams m_attach[ kAttCount ]; // indexed by EGLMFBOAttachment
|
||||
|
||||
int m_sizeX,m_sizeY;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,291 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// cglmprogram.h
|
||||
// GLMgr programs (ARBVP/ARBfp)
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef CGLMPROGRAM_H
|
||||
#define CGLMPROGRAM_H
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
// good ARB program references
|
||||
// http://petewarden.com/notes/archives/2005/05/fragment_progra_2.html
|
||||
// http://petewarden.com/notes/archives/2005/06/fragment_progra_3.html
|
||||
|
||||
// ext links
|
||||
|
||||
// http://www.opengl.org/registry/specs/ARB/vertex_program.txt
|
||||
// http://www.opengl.org/registry/specs/ARB/fragment_program.txt
|
||||
// http://www.opengl.org/registry/specs/EXT/gpu_program_parameters.txt
|
||||
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// tokens not in the SDK headers
|
||||
|
||||
//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT
|
||||
// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9
|
||||
//#endif
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// forward declarations
|
||||
|
||||
class GLMContext;
|
||||
class CGLMShaderPair;
|
||||
class CGLMShaderPairCache;
|
||||
|
||||
// CGLMProgram can contain two flavors of the same program, one in assembler, one in GLSL.
|
||||
// these flavors are pretty different in terms of the API's that are used to activate them -
|
||||
// for example, assembler programs can just get bound to the context, whereas GLSL programs
|
||||
// have to be linked. To some extent we try to hide that detail inside GLM.
|
||||
|
||||
// for now, make CGLMProgram a container, it does not set policy or hold a preference as to which
|
||||
// flavor you want to use. GLMContext has to handle that.
|
||||
|
||||
enum EGLMProgramType
|
||||
{
|
||||
kGLMVertexProgram,
|
||||
kGLMFragmentProgram,
|
||||
|
||||
kGLMNumProgramTypes
|
||||
};
|
||||
|
||||
enum EGLMProgramLang
|
||||
{
|
||||
kGLMARB,
|
||||
kGLMGLSL,
|
||||
|
||||
kGLMNumProgramLangs
|
||||
};
|
||||
|
||||
struct GLMShaderDesc
|
||||
{
|
||||
union
|
||||
{
|
||||
GLuint arb; // ARB program object name
|
||||
GLhandleARB glsl; // GLSL shader object handle (void*)
|
||||
} m_object;
|
||||
|
||||
// these can change if shader text is edited
|
||||
bool m_textPresent; // is this flavor(lang) of text present in the buffer?
|
||||
int m_textOffset; // where is it
|
||||
int m_textLength; // how big
|
||||
|
||||
bool m_compiled; // has this text been through a compile attempt
|
||||
bool m_valid; // and if so, was the compile successful
|
||||
|
||||
int m_slowMark; // has it been flagged during a non native draw batch before. increment every time it's slow.
|
||||
|
||||
int m_highWater; // vount of vec4's in the major uniform array ("vc" on vs, "pc" on ps)
|
||||
// written by dxabstract.... gross!
|
||||
};
|
||||
|
||||
GLenum GLMProgTypeToARBEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target
|
||||
GLenum GLMProgTypeToGLSLEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target
|
||||
|
||||
class CGLMProgram
|
||||
{
|
||||
public:
|
||||
friend class CGLMShaderPairCache;
|
||||
friend class CGLMShaderPair;
|
||||
friend class GLMContext; // only GLMContext can make CGLMProgram objects
|
||||
friend class GLMTester;
|
||||
friend class IDirect3D9;
|
||||
friend class IDirect3DDevice9;
|
||||
|
||||
//===============================
|
||||
|
||||
// constructor is very light, it just makes one empty program object per flavor.
|
||||
CGLMProgram( GLMContext *ctx, EGLMProgramType type );
|
||||
~CGLMProgram( );
|
||||
|
||||
void SetProgramText ( char *text ); // import text to GLM object - invalidate any prev compiled program
|
||||
|
||||
bool CompileActiveSources ( void ); // compile only the flavors that were provided.
|
||||
bool Compile ( EGLMProgramLang lang );
|
||||
bool CheckValidity ( EGLMProgramLang lang );
|
||||
|
||||
void LogSlow ( EGLMProgramLang lang ); // detailed spew when called for first time; one liner or perhaps silence after that
|
||||
|
||||
void GetLabelIndexCombo ( char *labelOut, int labelOutMaxChars, int *indexOut, int *comboOut );
|
||||
void GetComboIndexNameString ( char *stringOut, int stringOutMaxChars ); // mmmmmmmm-nnnnnnnn-filename
|
||||
|
||||
#if GLMDEBUG
|
||||
bool PollForChanges( void ); // check mirror for changes.
|
||||
void ReloadStringFromEditable( void ); // populate m_string from editable item (react to change)
|
||||
bool SyncWithEditable( void );
|
||||
#endif
|
||||
|
||||
//===============================
|
||||
|
||||
// common stuff
|
||||
|
||||
GLMContext *m_ctx; // link back to parent context
|
||||
|
||||
EGLMProgramType m_type; // vertex or pixel
|
||||
|
||||
uint m_serial; // serial number for hashing
|
||||
|
||||
char *m_text; // copy of text passed into constructor. Can change if editable shaders is enabled.
|
||||
// note - it can contain multiple flavors, so use CGLMTextSectioner to scan it and locate them
|
||||
#if GLMDEBUG
|
||||
CGLMEditableTextItem *m_editable; // editable text item for debugging
|
||||
#endif
|
||||
|
||||
GLMShaderDesc m_descs[ kGLMNumProgramLangs ];
|
||||
|
||||
uint m_samplerMask; // (1<<n) mask of sampler active locs, if this is a fragment shader (dxabstract sets this field)
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
||||
struct GLMShaderPairInfo
|
||||
{
|
||||
int m_status; // -1 means req'd index was out of bounds (loop stop..) 0 means not present. 1 means present/active.
|
||||
|
||||
char m_vsName[ 128 ];
|
||||
int m_vsStaticIndex;
|
||||
int m_vsDynamicIndex;
|
||||
|
||||
char m_psName[ 128 ];
|
||||
int m_psStaticIndex;
|
||||
int m_psDynamicIndex;
|
||||
};
|
||||
|
||||
|
||||
class CGLMShaderPair // a container for a linked GLSL shader pair, and metadata obtained post-link
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
friend class CGLMProgram;
|
||||
friend class GLMContext;
|
||||
friend class CGLMShaderPairCache;
|
||||
|
||||
//===============================
|
||||
|
||||
// constructor just sets up a GLSL program object and leaves it empty.
|
||||
CGLMShaderPair( GLMContext *ctx );
|
||||
~CGLMShaderPair( );
|
||||
|
||||
bool SetProgramPair ( CGLMProgram *vp, CGLMProgram *fp );
|
||||
// true result means successful link and query
|
||||
|
||||
bool RefreshProgramPair ( void );
|
||||
// re-link and re-query the uniforms
|
||||
|
||||
//===============================
|
||||
|
||||
// common stuff
|
||||
|
||||
GLMContext *m_ctx; // link back to parent context
|
||||
|
||||
CGLMProgram *m_vertexProg;
|
||||
CGLMProgram *m_fragmentProg;
|
||||
|
||||
GLhandleARB m_program; // linked program object
|
||||
|
||||
// need meta data for attribs / samplers / params
|
||||
// actually we only need it for samplers and params.
|
||||
// attributes are hardwired.
|
||||
|
||||
// vertex stage uniforms
|
||||
GLint m_locVertexParams; // "vc" per dx9asmtogl2 convention
|
||||
GLint m_locVertexInteger0; // "i0"
|
||||
GLint m_locVertexBool0; // "b0"
|
||||
GLint m_locVertexBool1; // "b1"
|
||||
GLint m_locVertexBool2; // "b2"
|
||||
GLint m_locVertexBool3; // "b3"
|
||||
|
||||
// fragment stage uniforms
|
||||
GLint m_locFragmentParams; // "pc" per dx9asmtogl2 convention
|
||||
GLint m_locFragmentFakeSRGBEnable; // "flSRGBWrite" - set to 1.0 to effect sRGB encoding on output
|
||||
float m_fakeSRGBEnableValue; // shadow to avoid redundant sets of the m_locFragmentFakeSRGBEnable uniform
|
||||
// init it to -1.0 at link or relink, so it will trip on any legit incoming value (0.0 or 1.0)
|
||||
|
||||
GLint m_locSamplers[ 16 ]; // "sampler0 ... sampler1..."
|
||||
|
||||
// other stuff
|
||||
bool m_valid; // true on successful link
|
||||
bool m_samplersFixed; // set on first draw (can't write the uniforms until the program is in use, and we don't want to mess with cur program inside cglmprogram)
|
||||
uint m_revision; // if this pair is relinked, bump this number.
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// N-row, M-way associative cache with LRU per row.
|
||||
// still needs some metric dump ability and some parameter tuning.
|
||||
// extra credit would be to make an auto-tuner.
|
||||
|
||||
struct CGLMPairCacheEntry
|
||||
{
|
||||
long long m_lastMark; // a mark of zero means an empty entry
|
||||
CGLMProgram *m_vertexProg;
|
||||
CGLMProgram *m_fragmentProg;
|
||||
uint m_extraKeyBits;
|
||||
CGLMShaderPair *m_pair;
|
||||
};
|
||||
|
||||
class CGLMShaderPairCache // cache for linked GLSL shader pairs
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
protected:
|
||||
friend class CGLMShaderPair;
|
||||
friend class CGLMProgram;
|
||||
friend class GLMContext;
|
||||
|
||||
//===============================
|
||||
|
||||
CGLMShaderPairCache( GLMContext *ctx );
|
||||
~CGLMShaderPairCache( );
|
||||
|
||||
CGLMShaderPair *SelectShaderPair ( CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits );
|
||||
void QueryShaderPair ( int index, GLMShaderPairInfo *infoOut );
|
||||
|
||||
// shoot down linked pairs that use the program in the arg
|
||||
// return true if any had to be skipped due to conflict with currently bound pair
|
||||
bool PurgePairsWithShader( CGLMProgram *prog );
|
||||
|
||||
// purge everything (when would GLM know how to do this ? at context destroy time, but any other times?)
|
||||
// return true if any had to be skipped due to conflict with currently bound pair
|
||||
bool Purge ( void );
|
||||
|
||||
// stats
|
||||
void DumpStats ( void );
|
||||
|
||||
//===============================
|
||||
|
||||
uint HashRowIndex ( CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits );
|
||||
CGLMPairCacheEntry* HashRowPtr ( uint hashRowIndex );
|
||||
void HashRowProbe ( CGLMPairCacheEntry *row, CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits, int *hitwayOut, int *emptywayOut, int *oldestwayOut );
|
||||
//===============================
|
||||
|
||||
// common stuff
|
||||
|
||||
GLMContext *m_ctx; // link back to parent context
|
||||
|
||||
long long m_mark;
|
||||
|
||||
uint m_rowsLg2;
|
||||
uint m_rows;
|
||||
|
||||
uint m_waysLg2;
|
||||
uint m_ways;
|
||||
|
||||
uint m_entryCount;
|
||||
|
||||
CGLMPairCacheEntry *m_entries; // array[ m_rows ][ m_ways ]
|
||||
|
||||
uint *m_evictions; // array[ m_rows ];
|
||||
uint *m_hits; // array[ m_rows ];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,413 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// cglmquery.cpp
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#include "glmgr.h"
|
||||
#include "cglmquery.h"
|
||||
#include "dxabstract.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
//===============================================================================
|
||||
|
||||
extern int gl_errorcheckall;
|
||||
extern int gl_errorcheckqueries;
|
||||
extern int gl_errorchecknone;
|
||||
|
||||
// how many microseconds to wait after a failed query-available test
|
||||
// presently on MTGL this doesn't happen, but it could change, keep this handy
|
||||
//ConVar gl_nullqueries( "gl_nullqueries", "0" );
|
||||
int gl_nullqueries = 0;
|
||||
|
||||
GLenum GetQueryError( void )
|
||||
{
|
||||
if ( ( GLMDEBUG || (gl_errorcheckall != 0) || (gl_errorcheckqueries != 0) ) && (gl_errorchecknone == 0) )
|
||||
{
|
||||
return glGetError();
|
||||
}
|
||||
else
|
||||
{
|
||||
return (GLenum) 0; // whistle past graveyard
|
||||
}
|
||||
}
|
||||
|
||||
//===============================================================================
|
||||
|
||||
CGLMQuery::CGLMQuery( GLMContext *ctx, GLMQueryParams *params )
|
||||
{
|
||||
// make sure context is current
|
||||
// get the type of query requested
|
||||
// generate name(s) needed
|
||||
// set initial state appropriately
|
||||
ctx->MakeCurrent();
|
||||
|
||||
m_ctx = ctx;
|
||||
m_params = *params;
|
||||
|
||||
m_name = 0;
|
||||
|
||||
m_started = m_stopped = m_done = false;
|
||||
|
||||
m_nullQuery = false;
|
||||
// assume value of convar at start time
|
||||
// does not change during individual query lifetime
|
||||
// started null = stays null
|
||||
// started live = stays live
|
||||
|
||||
switch(m_params.m_type)
|
||||
{
|
||||
case EOcclusion:
|
||||
{
|
||||
//make an occlusion query (and a fence to go with it)
|
||||
glGenQueriesARB( 1, &m_name );
|
||||
GLMPRINTF(("-A- CGLMQuery(OQ) created name %d", m_name));
|
||||
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::CGLMQuery (OQ) saw %s error (%d) from glGenQueriesARB", decodedStr, errorcode );
|
||||
m_name = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EFence:
|
||||
//make a fence - no aux fence needed
|
||||
glGenFencesAPPLE(1, &m_name );
|
||||
GLMPRINTF(("-A- CGLMQuery(fence) created name %d", m_name));
|
||||
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::CGLMQuery (fence) saw %s error (%d) from glGenFencesAPPLE", decodedStr, errorcode );
|
||||
m_name = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CGLMQuery::~CGLMQuery()
|
||||
{
|
||||
GLMPRINTF(("-A-> ~CGLMQuery"));
|
||||
|
||||
// make sure query has completed (might not be necessary)
|
||||
// delete the name(s)
|
||||
|
||||
m_ctx->MakeCurrent();
|
||||
|
||||
switch(m_params.m_type)
|
||||
{
|
||||
case EOcclusion:
|
||||
{
|
||||
// do a finish occlusion query ?
|
||||
GLMPRINTF(("-A- ~CGLMQuery(OQ) deleting name %d", m_name));
|
||||
glDeleteQueries(1, &m_name );
|
||||
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::~CGLMQuery (OQ) saw %s error (%d) from glDeleteQueries", decodedStr, errorcode );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EFence:
|
||||
{
|
||||
// do a finish fence ?
|
||||
GLMPRINTF(("-A- ~CGLMQuery(fence) deleting name %d", m_name));
|
||||
glDeleteFencesAPPLE(1, &m_name );
|
||||
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::~CGLMQuery (fence) saw %s error (%d) from glDeleteFencesAPPLE", decodedStr, errorcode );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
m_name = 0;
|
||||
|
||||
GLMPRINTF(("-A-< ~CGLMQuery"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CGLMQuery::Start( void ) // "start counting"
|
||||
{
|
||||
m_ctx->MakeCurrent();
|
||||
|
||||
// on occlusion query:
|
||||
// glBeginQueryARB on the OQ name. counting starts.
|
||||
|
||||
// on fence: glSetFence on m_name.
|
||||
|
||||
// note, fences finish themselves via command progress - OQ's do not.
|
||||
|
||||
Assert(!m_started);
|
||||
Assert(!m_stopped);
|
||||
Assert(!m_done);
|
||||
|
||||
m_nullQuery = (gl_nullqueries != 0); // latch value for remainder of query life
|
||||
|
||||
switch(m_params.m_type)
|
||||
{
|
||||
case EOcclusion:
|
||||
{
|
||||
if (m_nullQuery)
|
||||
{
|
||||
// do nothing..
|
||||
}
|
||||
else
|
||||
{
|
||||
glBeginQueryARB( GL_SAMPLES_PASSED_ARB, m_name );
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::Start(OQ) saw %s error (%d) from glBeginQueryARB (GL_SAMPLES_PASSED_ARB) name=%d", decodedStr, errorcode, m_name );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EFence:
|
||||
glSetFenceAPPLE( m_name );
|
||||
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::Start(fence) saw %s error (%d) from glSetFenceAPPLE name=%d", decodedStr, errorcode, m_name );
|
||||
}
|
||||
|
||||
m_stopped = true; // caller should not call Stop on a fence, it self-stops
|
||||
break;
|
||||
}
|
||||
|
||||
m_started = true;
|
||||
}
|
||||
|
||||
void CGLMQuery::Stop( void ) // "stop counting"
|
||||
{
|
||||
m_ctx->MakeCurrent();
|
||||
|
||||
Assert(m_started);
|
||||
Assert(!m_stopped); // this will assert if you try to call Stop on a fence that is started
|
||||
Assert(!m_done);
|
||||
|
||||
switch(m_params.m_type)
|
||||
{
|
||||
case EOcclusion:
|
||||
{
|
||||
if (m_nullQuery)
|
||||
{
|
||||
// do nothing..
|
||||
}
|
||||
else
|
||||
{
|
||||
glEndQueryARB( GL_SAMPLES_PASSED_ARB ); // we are only putting the request-to-stop-counting into the cmd stream.
|
||||
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::Stop(OQ) saw %s error (%d) from glEndQueryARB( GL_SAMPLES_PASSED_ARB ) name=%d", decodedStr, errorcode, m_name );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EFence:
|
||||
// nop - you don't "end" a fence, you just test it and/or finish it out in Complete
|
||||
break;
|
||||
}
|
||||
|
||||
m_stopped = true;
|
||||
}
|
||||
|
||||
bool CGLMQuery::IsDone( void )
|
||||
{
|
||||
m_ctx->MakeCurrent();
|
||||
|
||||
Assert(m_started);
|
||||
Assert(m_stopped);
|
||||
|
||||
if(!m_done) // you can ask more than once, but we only check until it comes back as done.
|
||||
{
|
||||
// on occlusion: glGetQueryObjectivARB - large cost on pre SLGU, cheap after
|
||||
// on fence: glTestFenceAPPLE on the fence
|
||||
switch(m_params.m_type)
|
||||
{
|
||||
case EOcclusion: // just test the fence that was set after the query begin
|
||||
{
|
||||
if (m_nullQuery)
|
||||
{
|
||||
// do almost nothing.. but claim work is complete
|
||||
m_done = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// prepare to pay a big price on drivers prior to 10.6.4+SLGU
|
||||
|
||||
GLint available = 0;
|
||||
glGetQueryObjectivARB(m_name, GL_QUERY_RESULT_AVAILABLE_ARB, &available );
|
||||
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::IsDone saw %s error (%d) from glGetQueryObjectivARB(a2) name=%d", decodedStr, errorcode, m_name );
|
||||
}
|
||||
|
||||
m_done = (available != 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EFence:
|
||||
{
|
||||
m_done = glTestFenceAPPLE( m_name );
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::IsDone saw %s error (%d) from glTestFenceAPPLE(b) name=%d", decodedStr, errorcode, m_name );
|
||||
}
|
||||
|
||||
if (m_done)
|
||||
{
|
||||
glFinishFenceAPPLE( m_name ); // no set fence goes un-finished
|
||||
|
||||
errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::IsDone saw %s error (%d) from glFinishFenceAPPLE(b) name=%d", decodedStr, errorcode, m_name );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return m_done;
|
||||
}
|
||||
|
||||
void CGLMQuery::Complete( uint *result )
|
||||
{
|
||||
m_ctx->MakeCurrent();
|
||||
|
||||
uint resultval = 0;
|
||||
GLint available = 0;
|
||||
bool bogus_available = false;
|
||||
|
||||
// blocking call if not done
|
||||
Assert(m_started);
|
||||
Assert(m_stopped);
|
||||
|
||||
switch(m_params.m_type)
|
||||
{
|
||||
case EOcclusion:
|
||||
{
|
||||
if (m_nullQuery)
|
||||
{
|
||||
m_done = true;
|
||||
resultval = 0; // we did say "null queries..."
|
||||
}
|
||||
else
|
||||
{
|
||||
// accept that the query is going to drain pipe in 10.6.4 and prior.
|
||||
// check the error on the spot.
|
||||
glGetQueryObjectivARB(m_name, GL_QUERY_RESULT_AVAILABLE_ARB, &available );
|
||||
GLenum errorcode = GetQueryError();
|
||||
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::Complete saw %s error (%d) from glGetQueryObjectivARB GL_QUERY_RESULT_AVAILABLE_ARB name=%d", decodedStr, errorcode, m_name );
|
||||
|
||||
resultval=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!available)
|
||||
{
|
||||
// this does happen with some very modest frequency.
|
||||
if (!m_ctx->Caps().m_hasPerfPackage1)
|
||||
{
|
||||
glFlush(); // ISTR some deadlock cases on pre-SLGU drivers if you didn't do this to kick the queue along..
|
||||
}
|
||||
}
|
||||
|
||||
glGetQueryObjectuivARB( m_name, GL_QUERY_RESULT_ARB, &resultval);
|
||||
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::Complete saw %s error (%d) from glGetQueryObjectivARB GL_QUERY_RESULT_ARB name=%d", decodedStr, errorcode, m_name );
|
||||
|
||||
resultval=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// resultval is legit
|
||||
}
|
||||
}
|
||||
m_done = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EFence:
|
||||
{
|
||||
if(!m_done)
|
||||
{
|
||||
glFinishFenceAPPLE( m_name );
|
||||
|
||||
GLenum errorcode = GetQueryError();
|
||||
if (errorcode)
|
||||
{
|
||||
char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
|
||||
printf( "\nCGLMQuery::Complete saw %s error (%d) from glFinishFenceAPPLE (EFence) name=%d", decodedStr, errorcode, m_name );
|
||||
}
|
||||
|
||||
m_done = true; // for clarity or if they try to Complete twice
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Assert( m_done );
|
||||
|
||||
// reset state for re-use - i.e. you have to call Complete if you want to re-use the object
|
||||
m_started = m_stopped = m_done = false;
|
||||
|
||||
if (result) // caller may pass NULL if not interested in result, for example to clear a fence
|
||||
{
|
||||
*result = resultval;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// accessors for the started/stopped state
|
||||
bool CGLMQuery::IsStarted ( void )
|
||||
{
|
||||
return m_started;
|
||||
}
|
||||
|
||||
bool CGLMQuery::IsStopped ( void )
|
||||
{
|
||||
return m_stopped;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// cglmquery.h
|
||||
// GLMgr queries
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef CGLMQUERY_H
|
||||
#define CGLMQUERY_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef OSX
|
||||
#include "glmgrbasics.h"
|
||||
#endif
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// forward declarations
|
||||
|
||||
class GLMContext;
|
||||
class CGLMQuery;
|
||||
|
||||
//===============================================================================
|
||||
|
||||
enum EGLMQueryType
|
||||
{
|
||||
EOcclusion,
|
||||
EFence,
|
||||
EGLMQueryCount
|
||||
};
|
||||
|
||||
struct GLMQueryParams
|
||||
{
|
||||
EGLMQueryType m_type;
|
||||
};
|
||||
|
||||
class CGLMQuery
|
||||
{
|
||||
// leave everything public til it's running
|
||||
public:
|
||||
friend class GLMContext; // only GLMContext can make CGLMTex objects
|
||||
friend class IDirect3DDevice9;
|
||||
friend class IDirect3DQuery9;
|
||||
|
||||
GLMContext *m_ctx; // link back to parent context
|
||||
GLMQueryParams m_params; // params created with
|
||||
|
||||
GLuint m_name; // name of the query object per se - could be fence, could be query object
|
||||
|
||||
bool m_started;
|
||||
bool m_stopped;
|
||||
bool m_done;
|
||||
|
||||
bool m_nullQuery; // was gl_nullqueries true at Start time - if so, continue to act like a null query through Stop/IsDone/Complete time
|
||||
// restated - only Start should examine the convar.
|
||||
|
||||
CGLMQuery( GLMContext *ctx, GLMQueryParams *params );
|
||||
~CGLMQuery( );
|
||||
|
||||
// for an occlusion query:
|
||||
// Start = BeginQuery query-start goes into stream
|
||||
// Stop = EndQuery query-end goes into stream - a fence is also set so we can probe for completion
|
||||
// IsDone = TestFence use the added fence to ask if query-end has passed (i.e. will Complete block?)
|
||||
// Complete = GetQueryObjectuivARB(uint id, enum pname, uint *params) - extract the sample count
|
||||
|
||||
// for a fence query:
|
||||
// Start = SetFence fence goes into command stream
|
||||
// Stop = NOP fences are self finishing - no need to call Stop on a fence
|
||||
// IsDone = TestFence ask if fence passed
|
||||
// Complete = FinishFence
|
||||
|
||||
void Start ( void );
|
||||
void Stop ( void );
|
||||
bool IsDone ( void );
|
||||
void Complete ( uint *result );
|
||||
|
||||
// accessors for the started/stopped state
|
||||
bool IsStarted ( void );
|
||||
bool IsStopped ( void );
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
+1804
File diff suppressed because it is too large
Load Diff
+291
@@ -0,0 +1,291 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// cglmtex.h
|
||||
// GLMgr textures
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef CGLMTEX_H
|
||||
#define CGLMTEX_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef OSX
|
||||
#include "glmgrbasics.h"
|
||||
#endif
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// forward declarations
|
||||
|
||||
class GLMContext;
|
||||
class GLMTester;
|
||||
class CGLMTexLayoutTable;
|
||||
class CGLMTex;
|
||||
class CGLMFBO;
|
||||
|
||||
class IDirect3DSurface9;
|
||||
|
||||
//===============================================================================
|
||||
|
||||
struct GLMTexFormatDesc
|
||||
{
|
||||
char *m_formatSummary; // for debug visibility
|
||||
|
||||
D3DFORMAT m_d3dFormat; // what D3D knows it as; see public/bitmap/imageformat.h
|
||||
|
||||
GLenum m_glIntFormat; // GL internal format
|
||||
GLenum m_glIntFormatSRGB; // internal format if SRGB flavor
|
||||
GLenum m_glDataFormat; // GL data format
|
||||
GLenum m_glDataType; // GL data type
|
||||
|
||||
int m_chunkSize; // 1 or 4 - 4 is used for compressed textures
|
||||
int m_bytesPerSquareChunk; // how many bytes for the smallest quantum (m_chunkSize x m_chunkSize)
|
||||
// this description lets us calculate size cleanly without conditional logic for compression
|
||||
};
|
||||
const GLMTexFormatDesc *GetFormatDesc( D3DFORMAT format );
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// utility function for generating slabs of texels. mostly for test.
|
||||
typedef struct
|
||||
{
|
||||
// in
|
||||
D3DFORMAT m_format;
|
||||
void *m_dest; // dest address
|
||||
int m_chunkCount; // square chunk count (single texels or compressed blocks)
|
||||
int m_byteCountLimit; // caller expectation of max number of bytes to write out
|
||||
float r,g,b,a; // color desired
|
||||
|
||||
// out
|
||||
int m_bytesWritten;
|
||||
} GLMGenTexelParams;
|
||||
|
||||
// return true if successful
|
||||
bool GLMGenTexels( GLMGenTexelParams *params );
|
||||
|
||||
|
||||
//===============================================================================
|
||||
|
||||
struct GLMTexLayoutSlice
|
||||
{
|
||||
int m_xSize,m_ySize,m_zSize; //texel dimensions of this slice
|
||||
int m_storageOffset; //where in the storage slab does this slice live
|
||||
int m_storageSize; //how much storage does this slice occupy
|
||||
};
|
||||
|
||||
enum EGLMTexFlags
|
||||
{
|
||||
kGLMTexMipped = 0x01,
|
||||
kGLMTexMippedAuto = 0x02,
|
||||
kGLMTexRenderable = 0x04,
|
||||
kGLMTexIsStencil = 0x08,
|
||||
kGLMTexIsDepth = 0x10,
|
||||
kGLMTexSRGB = 0x20,
|
||||
kGLMTexMultisampled = 0x40, // has an RBO backing it. Cannot combine with Mipped, MippedAuto. One slice maximum, only targeting GL_TEXTURE_2D.
|
||||
// actually not 100% positive on the mipmapping, the RBO itself can't be mipped, but the resulting texture could
|
||||
// have mipmaps generated.
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
||||
struct GLMTexLayoutKey
|
||||
{
|
||||
// input values: held const, these are the hash key for the form map
|
||||
GLenum m_texGLTarget; // flavor of texture: GL_TEXTURE_2D, GL_TEXTURE_3D, GLTEXTURE_CUBE_MAP
|
||||
D3DFORMAT m_texFormat; // D3D texel format
|
||||
unsigned long m_texFlags; // mipped, autogen mips, render target, ... ?
|
||||
unsigned long m_texSamples; // zero for a plain tex, 2/4/6/8 for "MSAA tex" (RBO backed)
|
||||
int m_xSize,m_ySize,m_zSize; // size of base mip
|
||||
};
|
||||
|
||||
struct LessThan_GLMTexLayoutKey
|
||||
{
|
||||
bool operator()(const GLMTexLayoutKey &a, const GLMTexLayoutKey &b)
|
||||
{
|
||||
#define DO_LESS(fff) if (a.fff != b.fff) { return (a.fff< b.fff); }
|
||||
|
||||
DO_LESS(m_texGLTarget);
|
||||
DO_LESS(m_texFormat);
|
||||
DO_LESS(m_texFlags);
|
||||
DO_LESS(m_xSize);
|
||||
DO_LESS(m_ySize)
|
||||
DO_LESS(m_zSize);
|
||||
|
||||
#undef DO_LESS
|
||||
|
||||
return false; // they are equal
|
||||
}
|
||||
};
|
||||
|
||||
#define GLM_TEX_MAX_MIPS 14
|
||||
#define GLM_TEX_MAX_FACES 6
|
||||
#define GLM_TEX_MAX_SLICES (GLM_TEX_MAX_MIPS * GLM_TEX_MAX_FACES)
|
||||
|
||||
struct GLMTexLayout
|
||||
{
|
||||
char *m_layoutSummary; // for debug visibility
|
||||
|
||||
// const inputs used for hashing
|
||||
GLMTexLayoutKey m_key;
|
||||
|
||||
// refcount
|
||||
int m_refCount;
|
||||
|
||||
// derived values:
|
||||
GLMTexFormatDesc *m_format; // format specific info
|
||||
int m_mipCount; // derived by starying at base size and working down towards 1x1
|
||||
int m_faceCount; // 1 for 2d/3d, 6 for cubemap
|
||||
int m_sliceCount; // product of faces and mips
|
||||
int m_storageTotalSize; // size of storage slab required
|
||||
|
||||
// slice array
|
||||
GLMTexLayoutSlice m_slices[0]; // dynamically allocated 2-d array [faces][mips]
|
||||
};
|
||||
|
||||
typedef std::map< GLMTexLayoutKey, GLMTexLayout*, LessThan_GLMTexLayoutKey > GLMTexLayoutKeyMap;
|
||||
class CGLMTexLayoutTable
|
||||
{
|
||||
public:
|
||||
CGLMTexLayoutTable();
|
||||
|
||||
GLMTexLayout *NewLayoutRef( GLMTexLayoutKey *key ); // pass in a pointer to layout key - receive ptr to completed layout
|
||||
void DelLayoutRef( GLMTexLayout *layout ); // pass in pointer to completed layout. refcount is dropped.
|
||||
|
||||
void DumpStats( void );
|
||||
protected:
|
||||
GLMTexLayoutKeyMap m_layoutMap;
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// a sampler specifies desired state for drawing on a given sampler index
|
||||
// this is the combination of a texture choice and a set of sampler parameters
|
||||
// see http://msdn.microsoft.com/en-us/library/bb172602(VS.85).aspx
|
||||
|
||||
|
||||
struct GLMTexSamplingParams
|
||||
{
|
||||
GLenum m_addressModes[3]; // S, T, R
|
||||
GLfloat m_borderColor[4]; // R,G,B,A
|
||||
|
||||
GLenum m_magFilter;
|
||||
GLenum m_minFilter;
|
||||
|
||||
GLfloat m_mipmapBias;
|
||||
GLint m_minMipLevel;
|
||||
GLint m_maxMipLevel;
|
||||
GLint m_maxAniso;
|
||||
GLenum m_compareMode; // only used for depth and stencil type textures
|
||||
bool m_srgb; // srgb texture read...
|
||||
};
|
||||
|
||||
struct GLMTexLockParams
|
||||
{
|
||||
// input params which identify the slice of interest
|
||||
CGLMTex *m_tex;
|
||||
int m_face;
|
||||
int m_mip;
|
||||
|
||||
// identifies the region of the slice
|
||||
GLMRegion m_region;
|
||||
|
||||
// tells GLM to force re-read of the texels back from GL
|
||||
// i.e. "I know I stepped on those texels with a draw or blit - the GLM copy is stale"
|
||||
bool m_readback;
|
||||
};
|
||||
|
||||
struct GLMTexLockDesc
|
||||
{
|
||||
GLMTexLockParams m_req; // form of the lock request
|
||||
|
||||
bool m_active; // set true at lock time. cleared at unlock time.
|
||||
|
||||
int m_sliceIndex; // which slice in the layout
|
||||
int m_sliceBaseOffset; // where is that in the texture data
|
||||
int m_sliceRegionOffset; // offset to the start (lowest address corner) of the region requested
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
||||
#define GLM_SAMPLER_COUNT 16
|
||||
|
||||
typedef unsigned short CTexBindMask; // 16 bits, who needs bitvec...
|
||||
|
||||
enum EGLMTexSliceFlag
|
||||
{
|
||||
kSliceValid = 0x01, // slice has been teximage'd in whole at least once - set to 0 initially
|
||||
kSliceStorageValid = 0x02, // if backing store is available, this slice's data is a valid copy - set to 0 initially
|
||||
kSliceLocked = 0x04, // are one or more locks outstanding on this slice
|
||||
kSliceFullyDirty = 0x08, // does the slice need to be fully downloaded at unlock time (disregard dirty rects)
|
||||
};
|
||||
|
||||
class CGLMTex
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
void Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut, int *zStrideOut );
|
||||
void Unlock( GLMTexLockParams *params );
|
||||
|
||||
protected:
|
||||
friend class GLMContext; // only GLMContext can make CGLMTex objects
|
||||
friend class GLMTester;
|
||||
friend class CGLMFBO;
|
||||
|
||||
friend class IDirect3DDevice9;
|
||||
friend class IDirect3DBaseTexture9;
|
||||
friend class IDirect3DTexture9;
|
||||
friend class IDirect3DSurface9;
|
||||
friend class IDirect3DCubeTexture9;
|
||||
friend class IDirect3DVolumeTexture9;
|
||||
|
||||
CGLMTex( GLMContext *ctx, GLMTexLayout *layout, GLMTexSamplingParams *sampling, char *debugLabel = NULL );
|
||||
~CGLMTex( );
|
||||
|
||||
int CalcSliceIndex( int face, int mip );
|
||||
void CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z, int *offsetOut, int *yStrideOut, int *zStrideOut );
|
||||
|
||||
void ApplySamplingParams( GLMTexSamplingParams *params, bool noCheck=FALSE );
|
||||
|
||||
void ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice=true );
|
||||
void WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice=true, bool noDataWrite=false );
|
||||
// last param lets us send NULL data ptr (only legal with uncompressed formats, beware)
|
||||
// this helps out ResetSRGB.
|
||||
|
||||
void ResetSRGB( bool srgb, bool noDataWrite );
|
||||
// re-specify texture format to match desired sRGB form
|
||||
// noWrite means send NULL for texel source addresses instead of actual data - ideal for RT's
|
||||
|
||||
GLMTexLayout *m_layout; // layout of texture (shared across all tex with same layout)
|
||||
int m_minActiveMip;//index of lowest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL.
|
||||
int m_maxActiveMip;//index of highest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL.
|
||||
|
||||
GLMTexSamplingParams m_sampling; // mirror of sampling params currently embodied in the texture
|
||||
// (consult this at draw time, in order to know if changes need to be made)
|
||||
|
||||
GLMContext *m_ctx; // link back to parent context
|
||||
|
||||
GLuint m_texName; // name of this texture in the context
|
||||
bool m_texClientStorage; // was CS selecetd for texture
|
||||
bool m_texPreloaded; // has it been kicked into VRAM with GLMContext::PreloadTex yet
|
||||
|
||||
GLuint m_rboName; // name of MSAA RBO backing the tex if MSAA enabled (or zero)
|
||||
bool m_rboDirty; // has RBO been drawn on - i.e. needs to be blitted back to texture if texture is going to be sampled from
|
||||
|
||||
CTexBindMask m_bindPoints; // true for each place in the parent ctx where currently
|
||||
// bound (indexed via EGLMTexCtxBindingIndex)
|
||||
|
||||
int m_rtAttachCount; // how many RT's have this texture attached somewhere
|
||||
|
||||
char *m_backing; // backing storage if available
|
||||
|
||||
int m_lockCount; // lock reqs are stored in the GLMContext for tracking
|
||||
|
||||
std::vector<unsigned char> m_sliceFlags;
|
||||
|
||||
char *m_debugLabel; // strdup() of debugLabel passed in, or NULL
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,233 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// DX9AsmToGL2.h
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef DX9_ASM_TO_GL_2_H
|
||||
#define DX9_ASM_TO_GL_2_H
|
||||
|
||||
#include "glmgr.h"
|
||||
|
||||
//==============================================================================
|
||||
|
||||
|
||||
#define DISASM_OK 0
|
||||
#define DISASM_ERROR 1
|
||||
|
||||
#define MAX_SHADER_CONSTANTS 512
|
||||
|
||||
#define MAX_DECLARED_OUTPUTS 32
|
||||
|
||||
#define HEXCODE_HEADER "// Hex: "
|
||||
|
||||
// Option bits
|
||||
#define D3DToGL_OptionUseEnvParams 0x001
|
||||
#define D3DToGL_OptionDoFixupZ 0x002 // Add instructions to put Z in the right interval for GL
|
||||
#define D3DToGL_OptionDoFixupY 0x004 // Add instructions to flip the Y over for GL
|
||||
#define D3DToGL_OptionDoUserClipPlanes 0x008 // ARB mode: Include OPTION vertex_program_2 and append DP4's to write into oCLP[0] and oCLP[1]
|
||||
// GLSL mode: generate code to write gl_ClipVertex
|
||||
#define D3DToGL_OptionGLSL 0x010 // Output GLSL, rather than ASM
|
||||
#define D3DToGL_AddHexComments 0x020 // Include hex comments in the code for debugging
|
||||
#define D3DToGL_PutHexCommentsAfterLines 0x040 // If D3DToGL_AddHexComments is set, this puts the codes to the right, rather than on separate lines
|
||||
#define D3DToGL_GeneratingDebugText 0x080 // This tells it that we're just getting info for debugging so go easy on asserts and errors
|
||||
#define D3DToGL_OptionAllowStaticControlFlow 0x100
|
||||
#define D3DToGL_OptionUseBindableUniforms 0x200 // add "bindable" in front of "vc" / "pc" constant arrays (GLSL only)
|
||||
#define D3DToGL_OptionSRGBWriteSuffix 0x400 // Tack sRGB conversion suffix on to pixel shaders
|
||||
#define D3DToGL_OptionSpew 0x80000000
|
||||
|
||||
// Code for which component of the "dummy" address register is needed by an instruction
|
||||
#define ARL_DEST_NONE -1
|
||||
#define ARL_DEST_X 0
|
||||
#define ARL_DEST_Y 1
|
||||
#define ARL_DEST_Z 2
|
||||
#define ARL_DEST_W 3
|
||||
|
||||
class D3DToGL
|
||||
{
|
||||
private:
|
||||
// Pointers for dwToken stream management
|
||||
uint32* m_pdwBaseToken;
|
||||
uint32* m_pdwNextToken;
|
||||
|
||||
// Vertex shader or pixel shader, and version (necessary because some opcodes alias)
|
||||
bool m_bVertexShader;
|
||||
uint32 m_dwMinorVersion;
|
||||
uint32 m_dwMajorVersion;
|
||||
|
||||
// Option flags
|
||||
bool m_bUseEnvParams; // set D3DToGL_OptionUseEnvParams in 'options' to use
|
||||
bool m_bDoFixupZ; // set D3DToGL_OptionDoFixupZ
|
||||
bool m_bDoFixupY; // set D3DToGL_OptionDoFixupZ
|
||||
bool m_bDoUserClipPlanes; // set D3DToGL_OptionDoUserClipPlanes
|
||||
bool m_bSpew; // set D3DToGL_OptionSpew
|
||||
bool m_bUseBindableUniforms; // set D3DToGL_OptionUseBindableUniforms
|
||||
bool m_bGenerateSRGBWriteSuffix; // set D3DToGL_OptionSRGBWriteSuffix
|
||||
|
||||
// Default: false
|
||||
// If you set this to true, it'll convert to GLSL instead of GL ASM.
|
||||
bool m_bGLSL; // set D3DToGL_OptionGLSL
|
||||
|
||||
// Default: false
|
||||
bool m_bAllowStaticControlFlow; // set D3DToGL_OptionAllowStaticControlFlow
|
||||
|
||||
// Counter for dealing with nested loops
|
||||
int m_nLoopDepth;
|
||||
|
||||
// Add "// Hex: 0xFFEEF00"-type statements after each instruction is parsed.
|
||||
bool m_bAddHexCodeComments; // set D3DToGL_AddHexComments
|
||||
|
||||
// Only applicable if m_bAddHexCodeComments is true.
|
||||
// If this is true, then it puts the hex code comments to the right of the instructions in a comment
|
||||
// rather than preceding the instructions.
|
||||
// Defaults to FALSE.
|
||||
bool m_bPutHexCodesAfterLines; // set D3DToGL_PutHexCommentsAtEnd
|
||||
|
||||
// This tells it that we're just getting info for debugging so go easy on asserts and errors.
|
||||
// Defaults to FALSE.
|
||||
bool m_bGeneratingDebugText;
|
||||
|
||||
// Various scratch temps needed to handle mis-matches in instruction sets between D3D and OpenGL
|
||||
bool m_bNeedsD2AddTemp;
|
||||
bool m_bNeedsNRMTemp;
|
||||
bool m_bDeclareAddressReg;
|
||||
bool m_bNeedsLerpTemp;
|
||||
bool m_bNeedsSinCosDeclarations;
|
||||
|
||||
// Keep track of which vs outputs are used so we can declare them
|
||||
bool m_bDeclareVSOPos;
|
||||
bool m_bDeclareVSOFog;
|
||||
uint32 m_dwTexCoordOutMask;
|
||||
|
||||
// Mask of varyings which need centroid decoration
|
||||
uint32 m_nCentroidMask;
|
||||
|
||||
// Keep track of which temps are used so they can be declared
|
||||
uint32 m_dwTempUsageMask;
|
||||
bool m_bOutputColorRegister[2];
|
||||
bool m_bOutputDepthRegister;
|
||||
|
||||
// Declaration of integer and bool constants
|
||||
uint32 m_dwConstIntUsageMask;
|
||||
uint32 m_dwConstBoolUsageMask;
|
||||
|
||||
// Did we use atomic_temp_var?
|
||||
bool m_bUsedAtomicTempVar;
|
||||
|
||||
// Track constants so we know how to declare them
|
||||
bool m_bConstantRegisterDefined[MAX_SHADER_CONSTANTS];
|
||||
|
||||
// Track sampler types when declared so we can properly decorate TEX instructions
|
||||
uint32 m_dwSamplerTypes[32];
|
||||
|
||||
// Track sampler usage
|
||||
uint32 m_dwSamplerUsageMask;
|
||||
|
||||
// Track shadow sampler usage
|
||||
int m_nShadowDepthSampler;
|
||||
bool m_bDeclareShadowOption;
|
||||
|
||||
// Track attribute references
|
||||
// init to 0xFFFFFFFF (unhit)
|
||||
// index by (dwRegToken & D3DSP_REGNUM_MASK) in VS DCL insns
|
||||
// fill with (usage<<4) | (usage index).
|
||||
uint32 m_dwAttribMap[16];
|
||||
|
||||
// Register high water mark
|
||||
uint32 m_nHighestRegister;
|
||||
|
||||
// GLSL does indentation for readability
|
||||
int m_NumIndentTabs;
|
||||
|
||||
// Output buffers.
|
||||
CUtlBuffer *m_pBufHeaderCode;
|
||||
CUtlBuffer *m_pBufAttribCode;
|
||||
CUtlBuffer *m_pBufParamCode;
|
||||
CUtlBuffer *m_pBufALUCode;
|
||||
|
||||
char *m_pFinalAssignmentsCode;
|
||||
int m_nFinalAssignmentsBufSize;
|
||||
|
||||
// Recorded positions for debugging.
|
||||
uint32* m_pRecordedInputTokenStart;
|
||||
int m_nRecordedParamCodeStrlen;
|
||||
int m_nRecordedALUCodeStrlen;
|
||||
int m_nRecordedAttribCodeStrlen;
|
||||
|
||||
// In GLSL mode, these store the semantic attached to each oN register.
|
||||
// They are the values that you pass to GetUsageIndexAndString.
|
||||
uint32 m_DeclaredOutputs[MAX_DECLARED_OUTPUTS];
|
||||
|
||||
// Have they used the tangent input semantic (i.e. is g_pTangentAttributeName declared)?
|
||||
bool m_bTangentInputUsed;
|
||||
|
||||
|
||||
private:
|
||||
// Utilities to aid in decoding token stream
|
||||
uint32 GetNextToken( void );
|
||||
void SkipTokens( uint32 numToSkip );
|
||||
uint32 Opcode( uint32 dwToken );
|
||||
uint32 OpcodeSpecificData( uint32 dwToken );
|
||||
uint32 TextureType ( uint32 dwToken );
|
||||
uint32 GetRegType( uint32 dwRegToken );
|
||||
|
||||
// Write to the different buffers.
|
||||
void StrcatToHeaderCode( const char *pBuf );
|
||||
void StrcatToALUCode( const char *pBuf );
|
||||
void StrcatToParamCode( const char *pBuf );
|
||||
void StrcatToAttribCode( const char *pBuf );
|
||||
|
||||
// This helps write the token hex codes into the output stream for debugging.
|
||||
void AddTokenHexCodeToBuffer( char *pBuffer, int nSize, int nLastStrlen );
|
||||
void RecordInputAndOutputPositions();
|
||||
void AddTokenHexCode();
|
||||
|
||||
// Utilities for decoding tokens in to strings according to ASM syntax
|
||||
void PrintOpcode( uint32 inst, char* buff, int nBufLen );
|
||||
|
||||
// fSemanticFlags is SEMANTIC_INPUT or SEMANTIC_OUTPUT.
|
||||
void PrintUsageAndIndexToString( uint32 dwToken, char* strUsageUsageIndexName, int nBufLen, int fSemanticFlags );
|
||||
CUtlString GetUsageAndIndexString( uint32 dwToken, int fSemanticFlags );
|
||||
CUtlString GetParameterString( uint32 dwToken, uint32 dwSourceOrDest, bool bForceScalarSource, int *pARLDestReg );
|
||||
const char* GetGLSLOperatorString( uint32 inst );
|
||||
|
||||
void PrintParameterToString ( uint32 dwToken, uint32 dwSourceOrDest, char *pRegisterName, int nBufLen, bool bForceScalarSource, int *pARLDestReg );
|
||||
|
||||
void InsertMoveFromAddressRegister( CUtlBuffer *pCode, int nARLComp0, int nARLComp1, int nARLComp2 = ARL_DEST_NONE );
|
||||
void InsertMoveInstruction( CUtlBuffer *pCode, int nARLComponent );
|
||||
void FlagIndirectRegister( uint32 dwToken, int *pARLDestReg );
|
||||
|
||||
// Utilities for decoding tokens in to strings according to GLSL syntax
|
||||
bool OpenIntrinsic( uint32 inst, char* buff, int nBufLen, uint32 destDimension, uint32 nArgumentDimension );
|
||||
void PrintIndentation( char *pBuf, int nBufLen );
|
||||
|
||||
uint32 MaintainAttributeMap( uint32 dwToken, uint32 dwRegToken );
|
||||
|
||||
CUtlString FixGLSLSwizzle( const char *pDestRegisterName, const char *pSrcRegisterName );
|
||||
void WriteGLSLCmp( const char *pDestReg, const char *pSrc0Reg, const char *pSrc1Reg, const char *pSrc2Reg );
|
||||
void WriteGLSLSamplerDefinitions();
|
||||
void WriteGLSLOutputVariableAssignments();
|
||||
void NoteTangentInputUsed();
|
||||
|
||||
void Handle_DCL();
|
||||
void Handle_DEF();
|
||||
void Handle_MAD( uint32 nInstruction );
|
||||
void Handle_DP2ADD();
|
||||
void Handle_SINCOS();
|
||||
void Handle_LRP( uint32 nInstruction );
|
||||
void Handle_TEX( uint32 dwToken, bool bIsTexLDL );
|
||||
void Handle_TexLDD( uint32 nInstruction );
|
||||
void Handle_TexCoord();
|
||||
void Handle_UnaryOp( uint32 nInstruction );
|
||||
void HandleBinaryOp_GLSL( uint32 nInstruction );
|
||||
void HandleBinaryOp_ASM( uint32 nInstruction );
|
||||
void Handle_CMP();
|
||||
void Handle_NRM();
|
||||
void Handle_DeclarativeNonDclOp( uint32 nInstruction );
|
||||
|
||||
public:
|
||||
D3DToGL();
|
||||
|
||||
int TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bool *bVertexShader, uint32 options, int32 nShadowDepthSampler, uint32 nCentroidMask, char *debugLabel );
|
||||
};
|
||||
|
||||
|
||||
#endif // DX9_ASM_TO_GL_2_H
|
||||
File diff suppressed because it is too large
Load Diff
+2420
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
||||
#ifndef GLMDEBUG_H
|
||||
#define GLMDEBUG_H
|
||||
|
||||
// include this anywhere you need to be able to compile-out code related specifically to GLM debugging.
|
||||
|
||||
// we expect DEBUG to be driven by the build system so you can include this header anywhere.
|
||||
// when we come out, GLMDEBUG will be defined to a value - 0, 1, or 2
|
||||
// 0 means no GLM debugging is possible
|
||||
// 1 means it's possible and resulted from being a debug build
|
||||
// 2 means it's possible and resulted from being manually forced on for a release build
|
||||
|
||||
#ifdef POSIX
|
||||
#ifndef GLMDEBUG
|
||||
#ifdef DEBUG
|
||||
#define GLMDEBUG 1 // normally 1 here, testing
|
||||
#else
|
||||
// #define GLMDEBUG 2 // don't check this in enabled..
|
||||
#endif
|
||||
|
||||
#ifndef GLMDEBUG
|
||||
#define GLMDEBUG 0
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#ifndef GLMDEBUG
|
||||
#define GLMDEBUG 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// helpful macro if you are in a position to call GLM functions directly (i.e. you live in materialsystem / shaderapidx9)
|
||||
#if GLMDEBUG
|
||||
#define GLMPRINTF(args) GLMPrintf args
|
||||
#define GLMPRINTSTR(args) GLMPrintStr args
|
||||
#define GLMPRINTTEXT(args) GLMPrintText args
|
||||
#define GLMBEGINPIXEVENT(args) GLMBeginPIXEvent args
|
||||
#define GLMENDPIXEVENT(args) GLMEndPIXEvent args
|
||||
#else
|
||||
#define GLMPRINTF(args)
|
||||
#define GLMPRINTSTR(args)
|
||||
#define GLMPRINTTEXT(args)
|
||||
#define GLMBEGINPIXEVENT(args)
|
||||
#define GLMENDPIXEVENT(args)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,275 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// glmdisplay.h
|
||||
// display related stuff - used by both GLMgr and the CocoaMgr
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef GLMDISPLAY_H
|
||||
#define GLMDISPLAY_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glext.h>
|
||||
#include <OpenGL/CGLTypes.h>
|
||||
#include <OpenGL/CGLRenderers.h>
|
||||
#include <OpenGL/CGLCurrent.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#include "glmgrbasics.h"
|
||||
|
||||
typedef void _PseudoNSGLContext; // aka NSOpenGLContext
|
||||
typedef _PseudoNSGLContext *PseudoNSGLContextPtr;
|
||||
|
||||
struct GLMDisplayModeInfoFields
|
||||
{
|
||||
uint m_modePixelWidth;
|
||||
uint m_modePixelHeight;
|
||||
uint m_modeRefreshHz;
|
||||
// are we even going to talk about bit depth... not yet
|
||||
};
|
||||
|
||||
struct GLMDisplayInfoFields
|
||||
{
|
||||
CGDirectDisplayID m_cgDisplayID;
|
||||
CGOpenGLDisplayMask m_glDisplayMask; // result of CGDisplayIDToOpenGLDisplayMask on the cg_displayID.
|
||||
|
||||
uint m_displayPixelWidth;
|
||||
uint m_displayPixelHeight;
|
||||
};
|
||||
|
||||
struct GLMRendererInfoFields
|
||||
{
|
||||
/*properties of interest and their desired values.
|
||||
|
||||
kCGLRPFullScreen = 54, true
|
||||
kCGLRPAccelerated = 73, true
|
||||
kCGLRPWindow = 80, true
|
||||
|
||||
kCGLRPRendererID = 70, informational
|
||||
kCGLRPDisplayMask = 84, informational
|
||||
kCGLRPBufferModes = 100, informational
|
||||
kCGLRPColorModes = 103, informational
|
||||
kCGLRPAccumModes = 104, informational
|
||||
kCGLRPDepthModes = 105, informational
|
||||
kCGLRPStencilModes = 106, informational
|
||||
kCGLRPMaxAuxBuffers = 107, informational
|
||||
kCGLRPMaxSampleBuffers = 108, informational
|
||||
kCGLRPMaxSamples = 109, informational
|
||||
kCGLRPSampleModes = 110, informational
|
||||
kCGLRPSampleAlpha = 111, informational
|
||||
kCGLRPVideoMemory = 120, informational
|
||||
kCGLRPTextureMemory = 121, informational
|
||||
kCGLRPRendererCount = 128 number of renderers in the CGLRendererInfoObj under examination
|
||||
|
||||
kCGLRPOffScreen = 53, D/C
|
||||
kCGLRPRobust = 75, FALSE or D/C - aka we're asking for no-fallback
|
||||
kCGLRPBackingStore = 76, D/C
|
||||
kCGLRPMPSafe = 78, D/C
|
||||
kCGLRPMultiScreen = 81, D/C
|
||||
kCGLRPCompliant = 83, D/C
|
||||
*/
|
||||
|
||||
|
||||
//--------------------------- info we have from CGL renderer queries, IOKit, Gestalt
|
||||
//--------------------------- these are set up in the displayDB by CocoaMgr
|
||||
GLint m_fullscreen;
|
||||
GLint m_accelerated;
|
||||
GLint m_windowed;
|
||||
|
||||
GLint m_rendererID;
|
||||
GLint m_displayMask;
|
||||
GLint m_bufferModes;
|
||||
GLint m_colorModes;
|
||||
GLint m_accumModes;
|
||||
GLint m_depthModes;
|
||||
GLint m_stencilModes;
|
||||
|
||||
GLint m_maxAuxBuffers;
|
||||
GLint m_maxSampleBuffers;
|
||||
GLint m_maxSamples;
|
||||
GLint m_sampleModes;
|
||||
GLint m_sampleAlpha;
|
||||
|
||||
GLint m_vidMemory;
|
||||
GLint m_texMemory;
|
||||
|
||||
uint m_pciVendorID;
|
||||
uint m_pciDeviceID;
|
||||
char m_pciModelString[64];
|
||||
char m_driverInfoString[64];
|
||||
|
||||
//--------------------------- OS version related - set up by CocoaMgr
|
||||
|
||||
// OS version found
|
||||
uint m_osComboVersion; // 0x00XXYYZZ : XX major, YY minor, ZZ minor minor : 10.6.3 --> 0x000A0603. 10.5.8 --> 0x000A0508.
|
||||
|
||||
//--------------------------- shorthands - also set up by CocoaMgr - driven by vendorid / deviceid
|
||||
|
||||
bool m_ati;
|
||||
bool m_atiR5xx;
|
||||
bool m_atiR6xx;
|
||||
bool m_atiR7xx;
|
||||
bool m_atiR8xx;
|
||||
bool m_atiNewer;
|
||||
|
||||
bool m_intel;
|
||||
bool m_intel95x;
|
||||
bool m_intel3100;
|
||||
bool m_intelNewer;
|
||||
|
||||
bool m_nv;
|
||||
bool m_nvG7x;
|
||||
bool m_nvG8x;
|
||||
bool m_nvNewer;
|
||||
|
||||
//--------------------------- context query results - left blank in the display DB - but valid in a GLMContext (call ctx->Caps() to get a const ref)
|
||||
|
||||
// booleans
|
||||
bool m_hasGammaWrites; // aka glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT) / glEnable(GL_FRAMEBUFFER_SRGB_EXT)
|
||||
bool m_hasMixedAttachmentSizes; // aka ARB_fbo in 10.6.3 - test for min OS vers, then exported ext string
|
||||
bool m_hasBGRA; // aka GL_BGRA vertex attribs in 10.6.3 - - test for min OS vers, then exported ext string
|
||||
bool m_hasNewFullscreenMode; // aka 10.6.x "big window" fullscreen mode
|
||||
bool m_hasNativeClipVertexMode; // aka GLSL gl_ClipVertex does not fall back to SW- OS version and folklore-based
|
||||
bool m_hasOcclusionQuery; // occlusion query: do you speak it ?!
|
||||
bool m_hasFramebufferBlit; // framebuffer blit: know what I'm sayin?!
|
||||
bool m_hasPerfPackage1; // means new MTGL, fast OQ, fast uniform upload, NV can resolve flipped (late summer 2010 post 10.6.4 update)
|
||||
|
||||
// counts
|
||||
int m_maxAniso; // aniso limit - context query
|
||||
|
||||
// other exts
|
||||
bool m_hasBindableUniforms;
|
||||
bool m_hasUniformBuffers;
|
||||
|
||||
// runtime options that aren't negotiable once set
|
||||
bool m_hasDualShaders; // must supply CLI arg "-glmdualshaders" or we go GLSL only
|
||||
|
||||
//--------------------------- " can'ts " - specific problems that need to be worked around
|
||||
|
||||
bool m_cantBlitReliably; // Intel chipsets have problems blitting sRGB sometimes
|
||||
bool m_cantAttachSRGB; // NV G8x on 10.5.8 can't have srgb tex on FBO color - separate issue from hasGammaWrites
|
||||
bool m_cantResolveFlipped; // happens on NV in 10.6.4 and prior - console variable "gl_can_resolve_flipped" can overrule
|
||||
bool m_cantResolveScaled; // happens everywhere per GL spec but may be relaxed some day - console variable "gl_can_resolve_scaled" can overrule
|
||||
bool m_costlyGammaFlips; // this means that sRGB sampling state affects shader code gen, resulting in state-dependent code regen
|
||||
|
||||
|
||||
//--------------------------- " bads " - known bad drivers
|
||||
bool m_badDriver1064NV; // this is the bad NVIDIA driver on 10.6.4 - stutter, tex corruption, black screen issues
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// this stuff is all sitting in glmgrcocoa.mm since it needs to make ObjC calls.
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// modes, displays, and renderers
|
||||
// think of renderers as being at the top of a tree.
|
||||
// each renderer has displays hanging off of it.
|
||||
// each display has modes hanging off of it.
|
||||
// the tree is populated on demand and then queried as needed.
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// GLMDisplayModeInfoFields is in glmdisplay.h
|
||||
|
||||
class GLMDisplayMode
|
||||
{
|
||||
public:
|
||||
GLMDisplayModeInfoFields m_info;
|
||||
|
||||
GLMDisplayMode( uint width, uint height, uint refreshHz );
|
||||
~GLMDisplayMode( void );
|
||||
|
||||
void Dump( int which );
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// GLMDisplayInfoFields is in glmdisplay.h
|
||||
|
||||
class GLMDisplayInfo
|
||||
{
|
||||
public:
|
||||
GLMDisplayInfoFields m_info;
|
||||
std::vector< GLMDisplayMode* > *m_modes; // starts out NULL, set by PopulateModes
|
||||
|
||||
GLMDisplayInfo( CGDirectDisplayID displayID, CGOpenGLDisplayMask displayMask );
|
||||
~GLMDisplayInfo( void );
|
||||
|
||||
void PopulateModes( void );
|
||||
|
||||
void Dump( int which );
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// GLMRendererInfoFields is in glmdisplay.h
|
||||
|
||||
class GLMRendererInfo
|
||||
{
|
||||
public:
|
||||
GLMRendererInfoFields m_info;
|
||||
std::vector< GLMDisplayInfo* > *m_displays; // starts out NULL, set by PopulateDisplays
|
||||
|
||||
GLMRendererInfo ( GLMRendererInfoFields *info );
|
||||
~GLMRendererInfo ( void );
|
||||
|
||||
void PopulateDisplays( void );
|
||||
void Dump( int which );
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// this is just a tuple describing fake adapters which are really renderer/display pairings.
|
||||
// dxabstract bridges the gap between the d3d adapter-centric world and the GL renderer+display world.
|
||||
// this makes it straightforward to handle cases like two video cards with two displays on one, and one on the other -
|
||||
// you get three fake adapters which represent each useful screen.
|
||||
|
||||
// the constraint that dxa will have to follow though, is that if the user wants to change their
|
||||
// display selection for full screen, they would only be able to pick on that has the same underlying renderer.
|
||||
// can't change fakeAdapter from one to another with different GL renderer under it. Screen hop but no card hop.
|
||||
|
||||
struct GLMFakeAdapter
|
||||
{
|
||||
int m_rendererIndex;
|
||||
int m_displayIndex;
|
||||
};
|
||||
|
||||
class GLMDisplayDB
|
||||
{
|
||||
public:
|
||||
std::vector< GLMRendererInfo* > *m_renderers; // starts out NULL, set by PopulateRenderers
|
||||
|
||||
std::vector< GLMFakeAdapter > m_fakeAdapters;
|
||||
|
||||
GLMDisplayDB ( void );
|
||||
~GLMDisplayDB ( void );
|
||||
|
||||
virtual void PopulateRenderers( void );
|
||||
virtual void PopulateFakeAdapters( uint realRendererIndex ); // fake adapters = one real adapter times however many displays are on it
|
||||
virtual void Populate( void );
|
||||
|
||||
// The info-get functions return false on success.
|
||||
virtual int GetFakeAdapterCount( void );
|
||||
virtual bool GetFakeAdapterInfo( int fakeAdapterIndex, int *rendererOut, int *displayOut, GLMRendererInfoFields *rendererInfoOut, GLMDisplayInfoFields *displayInfoOut );
|
||||
|
||||
virtual int GetRendererCount( void );
|
||||
virtual bool GetRendererInfo( int rendererIndex, GLMRendererInfoFields *infoOut );
|
||||
|
||||
virtual int GetDisplayCount( int rendererIndex );
|
||||
virtual bool GetDisplayInfo( int rendererIndex, int displayIndex, GLMDisplayInfoFields *infoOut );
|
||||
|
||||
virtual int GetModeCount( int rendererIndex, int displayIndex );
|
||||
virtual bool GetModeInfo( int rendererIndex, int displayIndex, int modeIndex, GLMDisplayModeInfoFields *infoOut );
|
||||
|
||||
virtual void Dump( void );
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+7069
File diff suppressed because it is too large
Load Diff
+1032
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,502 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// glmgrbasics.h
|
||||
// types, common headers, forward declarations, utilities
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#ifndef GLMBASICS_H
|
||||
#define GLMBASICS_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glext.h>
|
||||
#include <OpenGL/CGLTypes.h>
|
||||
#include <OpenGL/CGLRenderers.h>
|
||||
#include <OpenGL/CGLCurrent.h>
|
||||
#include <OpenGL/CGLProfiler.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#include "imageformat.h"
|
||||
#include "glmdebug.h"
|
||||
|
||||
#ifndef Assert(x)
|
||||
#define Assert(x)
|
||||
#endif
|
||||
|
||||
//===============================================================================
|
||||
|
||||
// some portability shims to eliminate dependencies on partcular segments of Valve code
|
||||
|
||||
class CUtlBuffer
|
||||
{
|
||||
public:
|
||||
enum BufferFlags_t
|
||||
{
|
||||
TEXT_BUFFER = 0x1, // Describes how get + put work (as strings, or binary)
|
||||
//EXTERNAL_GROWABLE = 0x2, // This is used w/ external buffers and causes the utlbuf to switch to reallocatable memory if an overflow happens when Putting.
|
||||
//CONTAINS_CRLF = 0x4, // For text buffers only, does this contain \n or \n\r?
|
||||
//READ_ONLY = 0x8, // For external buffers; prevents null termination from happening.
|
||||
//AUTO_TABS_DISABLED = 0x10, // Used to disable/enable push/pop tabs
|
||||
};
|
||||
|
||||
CUtlBuffer( int growSize = 0, int initSize = 0, int nFlags = 0 )
|
||||
{
|
||||
// grow size and init flags are ignored.
|
||||
m_buf.reserve( initSize );
|
||||
};
|
||||
|
||||
CUtlBuffer( const void* pBuffer, int size, int nFlags = 0 )
|
||||
{
|
||||
m_buf.reserve ( size );
|
||||
memcpy( &m_buf[0], pBuffer, size );
|
||||
}
|
||||
|
||||
// This one isn't actually defined so that we catch contructors that are trying to pass a bool in as the third param.
|
||||
CUtlBuffer( const void *pBuffer, int size, bool crap );
|
||||
|
||||
~CUtlBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
char* Base( void )
|
||||
{
|
||||
return &m_buf[0];
|
||||
}
|
||||
|
||||
uint32 Size( void )
|
||||
{
|
||||
return m_buf.size();
|
||||
}
|
||||
|
||||
void EnsureCapacity( int num )
|
||||
{
|
||||
m_buf.resize( num );
|
||||
}
|
||||
|
||||
void AppendString( const char* pString )
|
||||
{
|
||||
int appendlen = strlen( pString ); // count of characters, null terminator not included
|
||||
if (Size())
|
||||
{
|
||||
// append to non empty string
|
||||
EnsureCapacity( Size() + appendlen + 1);
|
||||
//printf("\n **(a) appending \n---\n%s\n---\n to \n---\n%s\n---\n", pString, Base() );
|
||||
strcat( Base(), pString ); // gets NULL terminated
|
||||
}
|
||||
else
|
||||
{
|
||||
EnsureCapacity( Size() + appendlen + 1);
|
||||
//printf("\n **(b) appending \n---\n%s\n---\n to \n---\n%s\n---\n", pString, Base() );
|
||||
strcpy( Base(), pString );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
CUtlBuffer();
|
||||
|
||||
std::vector<char> m_buf;
|
||||
};
|
||||
|
||||
class CUtlString
|
||||
{
|
||||
public:
|
||||
CUtlString()
|
||||
{
|
||||
m_str = "";
|
||||
}
|
||||
|
||||
CUtlString( const char *str )
|
||||
{
|
||||
m_str = std::string( str );
|
||||
}
|
||||
|
||||
~CUtlString( )
|
||||
{
|
||||
}
|
||||
|
||||
const char* String( void )
|
||||
{
|
||||
return m_str.c_str();
|
||||
}
|
||||
|
||||
operator const char * () { return m_str.c_str(); } //conversion operator
|
||||
|
||||
private:
|
||||
|
||||
std::string m_str;
|
||||
};
|
||||
|
||||
#undef ARRAYSIZE
|
||||
#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0]))
|
||||
|
||||
#define strcat_s(dst,lim,src) strcat(dst,src )
|
||||
|
||||
#define V_strcat(dst,lim,src) strcat(dst,src)
|
||||
#define V_vsnprintf(a,b,c,d) vsprintf(a,c,d) // double check this
|
||||
#define V_snprintf snprintf
|
||||
#define V_strncpy strncpy
|
||||
#define V_strncat strncat
|
||||
#define V_strcmp strcmp
|
||||
#define V_strlen strlen
|
||||
#define V_strstr strstr
|
||||
#define __cdecl
|
||||
|
||||
#define Q_memset(dst,count,val) memset(dst,count,val)
|
||||
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
|
||||
int V_stricmp(const char *s1, const char *s2 );
|
||||
char const* V_stristr( char const* pStr, char const* pSearch );
|
||||
|
||||
//===============================================================================
|
||||
// types
|
||||
|
||||
// 3-d integer box (used for texture lock/unlock etc)
|
||||
struct GLMRegion
|
||||
{
|
||||
int xmin,xmax;
|
||||
int ymin,ymax;
|
||||
int zmin,zmax;
|
||||
};
|
||||
|
||||
struct GLMRect // follows GL convention - if coming from the D3D rect you will need to fiddle the Y's
|
||||
{
|
||||
int xmin; // left
|
||||
int ymin; // bottom
|
||||
int xmax; // right
|
||||
int ymax; // top
|
||||
};
|
||||
|
||||
// macros
|
||||
|
||||
//#define GLMassert(x) assert(x)
|
||||
|
||||
// forward decls
|
||||
class GLMgr; // singleton
|
||||
class GLMContext; // GL context
|
||||
class CGLMContextTester; // testing class
|
||||
class CGLMTex;
|
||||
class CGLMFBO;
|
||||
class CGLMProgram;
|
||||
class CGLMBuffer;
|
||||
|
||||
|
||||
// utilities
|
||||
|
||||
typedef enum
|
||||
{
|
||||
// D3D codes
|
||||
eD3D_DEVTYPE,
|
||||
eD3D_FORMAT,
|
||||
eD3D_RTYPE,
|
||||
eD3D_USAGE,
|
||||
eD3D_RSTATE, // render state
|
||||
eD3D_SIO, // D3D shader bytecode
|
||||
eD3D_VTXDECLUSAGE,
|
||||
|
||||
// CGL codes
|
||||
eCGL_RENDID,
|
||||
|
||||
// OpenGL error codes
|
||||
eGL_ERROR,
|
||||
|
||||
// OpenGL enums
|
||||
eGL_ENUM,
|
||||
eGL_RENDERER
|
||||
|
||||
} GLMThing_t;
|
||||
|
||||
char* GLMDecode( GLMThing_t type, unsigned long value ); // decode a numeric const
|
||||
char* GLMDecodeMask( GLMThing_t type, unsigned long value ); // decode a bitmask
|
||||
|
||||
void GLMStop( void ); // aka Debugger()
|
||||
void GLMCheckError( bool noStop = false, bool noLog= false );
|
||||
void GLMEnableTrace( bool on );
|
||||
|
||||
//===============================================================================
|
||||
// debug channels
|
||||
|
||||
enum EGLMDebugChannel
|
||||
{
|
||||
ePrintf,
|
||||
eDebugger,
|
||||
eGLProfiler
|
||||
};
|
||||
|
||||
#if GLMDEBUG
|
||||
// make all these prototypes disappear in non GLMDEBUG
|
||||
void GLMDebugInitialize( bool forceReinit=false );
|
||||
|
||||
bool GLMDetectOGLP( void );
|
||||
bool GLMDetectGDB( void );
|
||||
uint GLMDetectAvailableChannels( void );
|
||||
|
||||
uint GLMDebugChannelMask( uint *newValue = NULL );
|
||||
// note that GDB and OGLP can both come and go during run - forceCheck will allow that to be detected.
|
||||
// mask returned is in form of 1<<n, n from EGLMDebugChannel
|
||||
#endif
|
||||
|
||||
//===============================================================================
|
||||
// debug message flavors
|
||||
|
||||
enum EGLMDebugFlavor
|
||||
{
|
||||
eAllFlavors, // 0
|
||||
eDebugDump, // 1 debug dump flavor -D-
|
||||
eTenure, // 2 code tenures > <
|
||||
eComment, // 3 one off messages ---
|
||||
eMatrixData, // 4 matrix data -M-
|
||||
eShaderData, // 5 shader data (params) -S-
|
||||
eFrameBufData, // 6 FBO data (attachments) -F-
|
||||
eDXStuff, // 7 dxabstract spew -X-
|
||||
eAllocations, // 8 tracking allocs and frees -A-
|
||||
eSlowness, // 9 slow things happening (srgb flips..) -Z-
|
||||
eDefaultFlavor, // not specified (no marker)
|
||||
eFlavorCount
|
||||
};
|
||||
uint GLMDebugFlavorMask( uint *newValue = NULL );
|
||||
|
||||
//===============================================================================
|
||||
// output functions
|
||||
|
||||
// make all these prototypes disappear in non GLMDEBUG
|
||||
#if GLMDEBUG
|
||||
// these are unconditional outputs, they don't interrogate the string
|
||||
void GLMStringOut( const char *string );
|
||||
void GLMStringOutIndented( const char *string, int indentColumns );
|
||||
|
||||
// these will look at the string to guess its flavor: <, >, ---, -M-, -S-
|
||||
void GLMPrintfVA( const char *fmt, va_list vargs );
|
||||
void GLMPrintf( const char *fmt, ... );
|
||||
|
||||
// these take an explicit flavor with a default value
|
||||
void GLMPrintStr( const char *str, EGLMDebugFlavor flavor = eDefaultFlavor );
|
||||
|
||||
#define GLMPRINTTEXT_NUMBEREDLINES 0x80000000
|
||||
void GLMPrintText( const char *str, EGLMDebugFlavor flavor = eDefaultFlavor, uint options=0 ); // indent each newline
|
||||
|
||||
int GLMIncIndent( int indentDelta );
|
||||
int GLMGetIndent( void );
|
||||
void GLMSetIndent( int indent );
|
||||
|
||||
#endif
|
||||
|
||||
// expose these in release now
|
||||
// Mimic PIX events so we can decorate debug spew
|
||||
void GLMBeginPIXEvent( const char *str );
|
||||
void GLMEndPIXEvent( void );
|
||||
|
||||
//===============================================================================
|
||||
// other stuff
|
||||
|
||||
#if GLMDEBUG
|
||||
inline void GLMDebugger( void )
|
||||
{
|
||||
if (GLMDebugChannelMask() & (1<<eDebugger))
|
||||
{
|
||||
asm {int 3 };
|
||||
}
|
||||
|
||||
if (GLMDebugChannelMask() & (1<<eGLProfiler))
|
||||
{
|
||||
// we call an obscure GL function which we know has been breakpointed in the OGLP function list
|
||||
static short nada[] = {0xFFFF,0xFFFF,0xFFFF,0xFFFF};
|
||||
glColor4sv( nada );
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define GLMDebugger()
|
||||
#endif
|
||||
|
||||
// helpers for CGLSetOption - no op if no profiler
|
||||
void GLMProfilerClearTrace( void );
|
||||
void GLMProfilerEnableTrace( bool enable );
|
||||
|
||||
// helpers for CGLSetParameter - no op if no profiler
|
||||
void GLMProfilerDumpState( void );
|
||||
|
||||
|
||||
//===============================================================================
|
||||
// classes
|
||||
|
||||
// helper class making function tracking easier to wire up
|
||||
#if GLMDEBUG
|
||||
class GLMFuncLogger
|
||||
{
|
||||
public:
|
||||
|
||||
// simple function log
|
||||
GLMFuncLogger( const char *funcName )
|
||||
{
|
||||
m_funcName = funcName;
|
||||
m_earlyOut = false;
|
||||
|
||||
GLMPrintf( ">%s", m_funcName );
|
||||
};
|
||||
|
||||
// more advanced version lets you pass args (i.e. called parameters or anything else of interest)
|
||||
// no macro for this one, since no easy way to pass through the args as well as the funcname
|
||||
GLMFuncLogger( const char *funcName, char *fmt, ... )
|
||||
{
|
||||
m_funcName = funcName;
|
||||
m_earlyOut = false;
|
||||
|
||||
// this acts like GLMPrintf here
|
||||
// all the indent policy is down in GLMPrintfVA
|
||||
// which means we need to inject a ">" at the front of the format string to make this work... sigh.
|
||||
|
||||
char modifiedFmt[2000];
|
||||
modifiedFmt[0] = '>';
|
||||
strcpy( modifiedFmt+1, fmt );
|
||||
|
||||
va_list vargs;
|
||||
va_start(vargs, fmt);
|
||||
GLMPrintfVA( modifiedFmt, vargs );
|
||||
va_end( vargs );
|
||||
}
|
||||
|
||||
~GLMFuncLogger( )
|
||||
{
|
||||
if (m_earlyOut)
|
||||
{
|
||||
GLMPrintf( "<%s (early out)", m_funcName );
|
||||
}
|
||||
else
|
||||
{
|
||||
GLMPrintf( "<%s", m_funcName );
|
||||
}
|
||||
};
|
||||
|
||||
void EarlyOut( void )
|
||||
{
|
||||
m_earlyOut = true;
|
||||
};
|
||||
|
||||
const char *m_funcName; // set at construction time
|
||||
bool m_earlyOut;
|
||||
};
|
||||
|
||||
// handy macro to go with the function tracking class
|
||||
#define GLM_FUNC GLMFuncLogger _logger_ ( __FUNCTION__ )
|
||||
#else
|
||||
#define GLM_FUNC
|
||||
#endif
|
||||
|
||||
|
||||
// class to keep an in-memory mirror of a file which may be getting edited during run
|
||||
class CGLMFileMirror
|
||||
{
|
||||
public:
|
||||
CGLMFileMirror( char *fullpath ); // just associates mirror with file. if file exists it will be read.
|
||||
//if non existent it will be created with size zero
|
||||
~CGLMFileMirror( );
|
||||
|
||||
bool HasData( void ); // see if data avail
|
||||
void GetData( char **dataPtr, uint *dataSizePtr ); // read it out
|
||||
void SetData( char *data, uint dataSize ); // put data in (and write it to disk)
|
||||
bool PollForChanges( void ); // check disk copy. If different, read it back in and return true.
|
||||
|
||||
void UpdateStatInfo( void ); // make sure stat info is current for our file
|
||||
void ReadFile( void );
|
||||
void WriteFile( void );
|
||||
|
||||
void OpenInEditor( bool foreground=false ); // pass TRUE if you would like the editor to pop to foreground
|
||||
|
||||
/// how about a "wait for change" method..
|
||||
|
||||
char *m_path; // fullpath to file
|
||||
bool m_exists;
|
||||
struct stat m_stat; // stat results for the file (last time checked)
|
||||
|
||||
char *m_data; // content of file
|
||||
uint m_size; // length of content
|
||||
|
||||
};
|
||||
|
||||
// class based on the file mirror, that makes it easy to edit them outside the app.
|
||||
|
||||
// it receives an initial block of text from the engine, and hashes it. ("orig")
|
||||
// it munges it by duplicating all the text after the "!!" line, and appending it in commented form. ("munged")
|
||||
// a mirror file is activated, using a filename based on the hash from the orig text.
|
||||
// if there is already content on disk matching that filename, use that content *unless* the 'blitz' parameter is set.
|
||||
// (i.e. engine is instructing this subsystem to wipe out any old/modified variants of the text)
|
||||
|
||||
#ifndef MD5_DIGEST_LENGTH
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
#endif
|
||||
|
||||
class CGLMEditableTextItem
|
||||
{
|
||||
public:
|
||||
CGLMEditableTextItem( char *text, uint size, bool forceOverwrite, char *prefix, char *suffix = NULL ); // create a text blob from text source, optional filename suffix
|
||||
~CGLMEditableTextItem( );
|
||||
|
||||
bool HasData( void );
|
||||
bool PollForChanges( void ); // return true if stale i.e. you need to get a new edition
|
||||
void GetCurrentText( char **textOut, uint *sizeOut ); // query for read access to the active blob (could be the original, could be external edited copy)
|
||||
void OpenInEditor( bool foreground=false ); // call user attention to this text
|
||||
|
||||
// internal methods
|
||||
void GenHashOfOrigText( void );
|
||||
void GenBaseNameAndFullPath( char *prefix, char *suffix );
|
||||
void GenMungedText( bool fromMirror );
|
||||
|
||||
// members
|
||||
// orig
|
||||
uint m_origSize;
|
||||
char *m_origText; // what was submitted
|
||||
unsigned char m_origDigest[MD5_DIGEST_LENGTH]; // digest of what was submitted
|
||||
|
||||
// munged
|
||||
uint m_mungedSize;
|
||||
char *m_mungedText; // re-processed edition, initial content submission to the file mirror
|
||||
|
||||
// mirror
|
||||
char *m_mirrorBaseName; // generated from the hash of the orig text, plus the label / prefix
|
||||
char *m_mirrorFullPath; // base name
|
||||
CGLMFileMirror *m_mirror; // file mirror itself. holds "official" copy for GetCurrentText to return.
|
||||
};
|
||||
|
||||
|
||||
// debug font
|
||||
extern unsigned char g_glmDebugFontMap[16384];
|
||||
|
||||
// class for cracking multi-part text blobs
|
||||
// sections are demarcated by beginning-of-line markers submitted in a table by the caller
|
||||
|
||||
struct GLMTextSection
|
||||
{
|
||||
int m_markerIndex; // based on table of markers passed in to constructor
|
||||
uint m_textOffset; // where is the text - offset
|
||||
int m_textLength; // how big is the section
|
||||
};
|
||||
|
||||
class CGLMTextSectioner
|
||||
{
|
||||
public:
|
||||
CGLMTextSectioner( char *text, int textSize, char **markers ); // constructor finds all the sections
|
||||
~CGLMTextSectioner( );
|
||||
|
||||
int Count( void ); // how many sections found
|
||||
void GetSection( int index, uint *offsetOut, uint *lengthOut, int *markerIndexOut );
|
||||
// find section, size, what marker
|
||||
// note that more than one section can be marked similarly.
|
||||
// so policy isn't made here, you walk the sections and decide what to do if there are dupes.
|
||||
|
||||
//members
|
||||
|
||||
//section table
|
||||
std::vector< GLMTextSection > m_sectionTable;
|
||||
};
|
||||
|
||||
#endif
|
||||
+1577
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,104 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// glmgrext.h
|
||||
// helper file for extension testing and runtime importing of entry points
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glext.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "glmgr.h"
|
||||
|
||||
PFNglColorMaskIndexedEXT pfnglColorMaskIndexedEXT;
|
||||
PFNglEnableIndexedEXT pfnglEnableIndexedEXT;
|
||||
PFNglDisableIndexedEXT pfnglDisableIndexedEXT;
|
||||
PFNglGetFramebufferAttachmentParameteriv pfnglGetFramebufferAttachmentParameteriv;
|
||||
PFNglUniformBufferEXT pfnglUniformBufferEXT;
|
||||
|
||||
void * NSGLGetProcAddress (const char *name)
|
||||
{
|
||||
NSSymbol symbol;
|
||||
char *symbolName = (char *)malloc (strlen (name) + 2);
|
||||
strcpy(symbolName + 1, name);
|
||||
symbolName[0] = '_';
|
||||
symbol = NULL;
|
||||
if (NSIsSymbolNameDefined (symbolName))
|
||||
symbol = NSLookupAndBindSymbol (symbolName);
|
||||
free (symbolName);
|
||||
return symbol ? NSAddressOfSymbol (symbol) : NULL;
|
||||
}
|
||||
|
||||
|
||||
void GLMSetupExtensions( void )
|
||||
{
|
||||
pfnglColorMaskIndexedEXT = (PFNglColorMaskIndexedEXT) NSGLGetProcAddress( "glColorMaskIndexedEXT" );
|
||||
pfnglEnableIndexedEXT = (PFNglEnableIndexedEXT) NSGLGetProcAddress( "glEnableIndexedEXT" );
|
||||
pfnglDisableIndexedEXT = (PFNglDisableIndexedEXT) NSGLGetProcAddress( "glDisableIndexedEXT" );
|
||||
|
||||
pfnglGetFramebufferAttachmentParameteriv = (PFNglGetFramebufferAttachmentParameteriv) NSGLGetProcAddress( "glGetFramebufferAttachmentParameteriv" );
|
||||
|
||||
pfnglUniformBufferEXT = (PFNglUniformBufferEXT) NSGLGetProcAddress( "glUniformBufferEXT" );
|
||||
}
|
||||
|
||||
/*
|
||||
#define INSTANTIATE_GL_IMPORTS
|
||||
#include "glmgr.h" // will include glmgrext.h
|
||||
#undef INSTANTIATE_GL_IMPORTS
|
||||
|
||||
|
||||
// helper class for looking up function names
|
||||
// see http://andrewtolbert.com/svn/personal/OpenGLSuperBible/shared/gltools.cpp
|
||||
// also http://developer.apple.com/mac/library/DOCUMENTATION/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_entrypts/opengl_entrypts.html
|
||||
|
||||
class CFunctionImporter
|
||||
{
|
||||
public:
|
||||
CFBundleRef m_bundle;
|
||||
|
||||
CFunctionImporter( CFStringRef bundleID ) // for example CFSTR("com.apple.OpenGL")
|
||||
{
|
||||
m_bundle = CFBundleGetBundleWithIdentifier( bundleID );
|
||||
if ( m_bundle )
|
||||
CFRetain( m_bundle );
|
||||
}
|
||||
|
||||
~CFunctionImporter()
|
||||
{
|
||||
if( m_bundle )
|
||||
{
|
||||
CFRelease(m_bundle);
|
||||
m_bundle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void *FindFunctionByName(CFStringRef name) // ex CFSTR("glColorMaskedIndexedEXT")
|
||||
{
|
||||
void *result = NULL;
|
||||
if (m_bundle)
|
||||
{
|
||||
result = CFBundleGetFunctionPointerForName(m_bundle, name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void GLMSetupExtensions( void )
|
||||
{
|
||||
CFunctionImporter importer( CFSTR("com.apple.OpenGL") );
|
||||
|
||||
#define DO_IMPORT(name) name = (name##FuncPtr)importer.FindFunctionByName( CFSTR(#name) );
|
||||
|
||||
#ifndef GL_EXT_draw_buffers2
|
||||
// FIXME we're not checking for the extension string yet, we're just grabbing func ptrs
|
||||
DO_IMPORT(glColorMaskIndexedEXT);
|
||||
DO_IMPORT(glEnableIndexedEXT);
|
||||
DO_IMPORT(glDisableIndexedEXT);
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,101 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
//
|
||||
// glmgrext.h
|
||||
// helper file for extension testing and runtime importing of entry points
|
||||
//
|
||||
//===============================================================================
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glext.h>
|
||||
|
||||
// #define symbol INSTANTIATE_GL_IMPORTS controls whether the following macro "GL_IMPORT" writes externs or writes decls
|
||||
// normally only glmgr.cpp sets that symbol and includes this file
|
||||
|
||||
// to simplify usage, a function ptr type must exist for every entry point, following the name##FuncPtr convention.
|
||||
|
||||
#ifdef INSTANTIATE_GL_IMPORTS
|
||||
#define GL_IMPORT( name ) name##FuncPtr name = 0
|
||||
#else
|
||||
#define GL_IMPORT( name ) extern name##FuncPtr name;
|
||||
#endif
|
||||
|
||||
|
||||
// before declaring each import, check to see if the EXT symbol is in effect,
|
||||
// and if so, don't do it!
|
||||
|
||||
#ifndef GL_EXT_draw_buffers2
|
||||
typedef void (* glColorMaskIndexedEXTFuncPtr) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
|
||||
typedef void (* glEnableIndexedEXTFuncPtr) (GLenum target, GLuint index);
|
||||
typedef void (* glDisableIndexedEXTFuncPtr) (GLenum target, GLuint index);
|
||||
|
||||
GL_IMPORT(glColorMaskIndexedEXT);
|
||||
GL_IMPORT(glEnableIndexedEXT);
|
||||
GL_IMPORT(glDisableIndexedEXT);
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_framebuffer_sRGB
|
||||
#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
|
||||
#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
|
||||
#endif
|
||||
|
||||
#ifndef ARB_texture_rg
|
||||
#define GL_COMPRESSED_RED 0x8225
|
||||
#define GL_COMPRESSED_RG 0x8226
|
||||
#define GL_RG 0x8227
|
||||
#define GL_RG_INTEGER 0x8228
|
||||
#define GL_R8 0x8229
|
||||
#define GL_R16 0x822A
|
||||
#define GL_RG8 0x822B
|
||||
#define GL_RG16 0x822C
|
||||
#define GL_R16F 0x822D
|
||||
#define GL_R32F 0x822E
|
||||
#define GL_RG16F 0x822F
|
||||
#define GL_RG32F 0x8230
|
||||
#define GL_R8I 0x8231
|
||||
#define GL_R8UI 0x8232
|
||||
#define GL_R16I 0x8233
|
||||
#define GL_R16UI 0x8234
|
||||
#define GL_R32I 0x8235
|
||||
#define GL_R32UI 0x8236
|
||||
#define GL_RG8I 0x8237
|
||||
#define GL_RG8UI 0x8238
|
||||
#define GL_RG16I 0x8239
|
||||
#define GL_RG16UI 0x823A
|
||||
#define GL_RG32I 0x823B
|
||||
#define GL_RG32UI 0x823C
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_bindable_uniform
|
||||
#define GL_UNIFORM_BUFFER_EXT 0x8DEE
|
||||
#endif
|
||||
|
||||
// unpublished extension enums (thus the "X")
|
||||
|
||||
// from EXT_framebuffer_multisample_blit_scaled..
|
||||
#define XGL_SCALED_RESOLVE_FASTEST_EXT 0x90BA
|
||||
#define XGL_SCALED_RESOLVE_NICEST_EXT 0x90BB
|
||||
|
||||
|
||||
void * NSGLGetProcAddress (const char *name);
|
||||
|
||||
// call this to find all the entry points.
|
||||
void GLMSetupExtensions( void );
|
||||
|
||||
|
||||
|
||||
typedef void (*PFNglColorMaskIndexedEXT)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
|
||||
typedef void (*PFNglEnableIndexedEXT)(GLenum target, GLuint index);
|
||||
typedef void (*PFNglDisableIndexedEXT)(GLenum target, GLuint index);
|
||||
typedef void (*PFNglUniformBufferEXT)(GLuint program, GLint location, GLuint buffer);
|
||||
|
||||
extern PFNglColorMaskIndexedEXT pfnglColorMaskIndexedEXT;
|
||||
extern PFNglEnableIndexedEXT pfnglEnableIndexedEXT;
|
||||
extern PFNglDisableIndexedEXT pfnglDisableIndexedEXT;
|
||||
extern PFNglUniformBufferEXT pfnglUniformBufferEXT;
|
||||
|
||||
|
||||
typedef void (*PFNglGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint *params);
|
||||
extern PFNglGetFramebufferAttachmentParameteriv pfnglGetFramebufferAttachmentParameteriv;
|
||||
|
||||
@@ -0,0 +1,523 @@
|
||||
//===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef IMAGEFORMAT_H
|
||||
#define IMAGEFORMAT_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
enum NormalDecodeMode_t
|
||||
{
|
||||
NORMAL_DECODE_NONE = 0,
|
||||
NORMAL_DECODE_ATI2N = 1,
|
||||
NORMAL_DECODE_ATI2N_ALPHA = 2
|
||||
};
|
||||
|
||||
// Forward declaration
|
||||
#ifdef _WIN32
|
||||
typedef enum _D3DFORMAT D3DFORMAT;
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The various image format types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// don't bitch that inline functions aren't used!!!!
|
||||
#pragma warning(disable : 4514)
|
||||
|
||||
enum ImageFormat
|
||||
{
|
||||
IMAGE_FORMAT_UNKNOWN = -1,
|
||||
IMAGE_FORMAT_RGBA8888 = 0,
|
||||
IMAGE_FORMAT_ABGR8888,
|
||||
IMAGE_FORMAT_RGB888,
|
||||
IMAGE_FORMAT_BGR888,
|
||||
IMAGE_FORMAT_RGB565,
|
||||
IMAGE_FORMAT_I8,
|
||||
IMAGE_FORMAT_IA88,
|
||||
IMAGE_FORMAT_P8,
|
||||
IMAGE_FORMAT_A8,
|
||||
IMAGE_FORMAT_RGB888_BLUESCREEN,
|
||||
IMAGE_FORMAT_BGR888_BLUESCREEN,
|
||||
IMAGE_FORMAT_ARGB8888,
|
||||
IMAGE_FORMAT_BGRA8888,
|
||||
IMAGE_FORMAT_DXT1,
|
||||
IMAGE_FORMAT_DXT3,
|
||||
IMAGE_FORMAT_DXT5,
|
||||
IMAGE_FORMAT_BGRX8888,
|
||||
IMAGE_FORMAT_BGR565,
|
||||
IMAGE_FORMAT_BGRX5551,
|
||||
IMAGE_FORMAT_BGRA4444,
|
||||
IMAGE_FORMAT_DXT1_ONEBITALPHA,
|
||||
IMAGE_FORMAT_BGRA5551,
|
||||
IMAGE_FORMAT_UV88,
|
||||
IMAGE_FORMAT_UVWQ8888,
|
||||
IMAGE_FORMAT_RGBA16161616F,
|
||||
IMAGE_FORMAT_RGBA16161616,
|
||||
IMAGE_FORMAT_UVLX8888,
|
||||
IMAGE_FORMAT_R32F, // Single-channel 32-bit floating point
|
||||
IMAGE_FORMAT_RGB323232F,
|
||||
IMAGE_FORMAT_RGBA32323232F,
|
||||
|
||||
// Depth-stencil texture formats for shadow depth mapping
|
||||
IMAGE_FORMAT_NV_DST16, //
|
||||
IMAGE_FORMAT_NV_DST24, //
|
||||
IMAGE_FORMAT_NV_INTZ, // Vendor-specific depth-stencil texture
|
||||
IMAGE_FORMAT_NV_RAWZ, // formats for shadow depth mapping
|
||||
IMAGE_FORMAT_ATI_DST16, //
|
||||
IMAGE_FORMAT_ATI_DST24, //
|
||||
IMAGE_FORMAT_NV_NULL, // Dummy format which takes no video memory
|
||||
|
||||
// Compressed normal map formats
|
||||
IMAGE_FORMAT_ATI2N, // One-surface ATI2N / DXN format
|
||||
IMAGE_FORMAT_ATI1N, // Two-surface ATI1N format
|
||||
|
||||
#if defined( _X360 )
|
||||
// Depth-stencil texture formats
|
||||
IMAGE_FORMAT_X360_DST16,
|
||||
IMAGE_FORMAT_X360_DST24,
|
||||
IMAGE_FORMAT_X360_DST24F,
|
||||
// supporting these specific formats as non-tiled for procedural cpu access
|
||||
IMAGE_FORMAT_LINEAR_BGRX8888,
|
||||
IMAGE_FORMAT_LINEAR_RGBA8888,
|
||||
IMAGE_FORMAT_LINEAR_ABGR8888,
|
||||
IMAGE_FORMAT_LINEAR_ARGB8888,
|
||||
IMAGE_FORMAT_LINEAR_BGRA8888,
|
||||
IMAGE_FORMAT_LINEAR_RGB888,
|
||||
IMAGE_FORMAT_LINEAR_BGR888,
|
||||
IMAGE_FORMAT_LINEAR_BGRX5551,
|
||||
IMAGE_FORMAT_LINEAR_I8,
|
||||
IMAGE_FORMAT_LINEAR_RGBA16161616,
|
||||
|
||||
IMAGE_FORMAT_LE_BGRX8888,
|
||||
IMAGE_FORMAT_LE_BGRA8888,
|
||||
#endif
|
||||
|
||||
NUM_IMAGE_FORMATS
|
||||
};
|
||||
|
||||
#if defined( POSIX ) || defined( DX_TO_GL_ABSTRACTION )
|
||||
typedef enum _D3DFORMAT
|
||||
{
|
||||
D3DFMT_INDEX16,
|
||||
D3DFMT_D16,
|
||||
D3DFMT_D24S8,
|
||||
D3DFMT_A8R8G8B8,
|
||||
D3DFMT_A4R4G4B4,
|
||||
D3DFMT_X8R8G8B8,
|
||||
D3DFMT_R5G6R5,
|
||||
D3DFMT_X1R5G5B5,
|
||||
D3DFMT_A1R5G5B5,
|
||||
D3DFMT_L8,
|
||||
D3DFMT_A8L8,
|
||||
D3DFMT_A,
|
||||
D3DFMT_DXT1,
|
||||
D3DFMT_DXT3,
|
||||
D3DFMT_DXT5,
|
||||
D3DFMT_V8U8,
|
||||
D3DFMT_Q8W8V8U8,
|
||||
D3DFMT_X8L8V8U8,
|
||||
D3DFMT_A16B16G16R16F,
|
||||
D3DFMT_A16B16G16R16,
|
||||
D3DFMT_R32F,
|
||||
D3DFMT_A32B32G32R32F,
|
||||
D3DFMT_R8G8B8,
|
||||
D3DFMT_D24X4S4,
|
||||
D3DFMT_A8,
|
||||
D3DFMT_R5G6B5,
|
||||
D3DFMT_D15S1,
|
||||
D3DFMT_D24X8,
|
||||
D3DFMT_VERTEXDATA,
|
||||
D3DFMT_INDEX32,
|
||||
|
||||
// adding fake D3D format names for the vendor specific ones (eases debugging/logging)
|
||||
|
||||
// NV shadow depth tex
|
||||
D3DFMT_NV_INTZ = 0x5a544e49, // MAKEFOURCC('I','N','T','Z')
|
||||
D3DFMT_NV_RAWZ = 0x5a574152, // MAKEFOURCC('R','A','W','Z')
|
||||
|
||||
// NV null tex
|
||||
D3DFMT_NV_NULL = 0x4c4c554e, // MAKEFOURCC('N','U','L','L')
|
||||
|
||||
// ATI shadow depth tex
|
||||
D3DFMT_ATI_D16 = 0x36314644, // MAKEFOURCC('D','F','1','6')
|
||||
D3DFMT_ATI_D24S8 = 0x34324644, // MAKEFOURCC('D','F','2','4')
|
||||
|
||||
// ATI 1N and 2N compressed tex
|
||||
D3DFMT_ATI_2N = 0x32495441, // MAKEFOURCC('A', 'T', 'I', '2')
|
||||
D3DFMT_ATI_1N = 0x31495441, // MAKEFOURCC('A', 'T', 'I', '1')
|
||||
|
||||
D3DFMT_UNKNOWN
|
||||
} D3DFORMAT;
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Color structures
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct BGRA8888_t
|
||||
{
|
||||
unsigned char b; // change the order of names to change the
|
||||
unsigned char g; // order of the output ARGB or BGRA, etc...
|
||||
unsigned char r; // Last one is MSB, 1st is LSB.
|
||||
unsigned char a;
|
||||
inline BGRA8888_t& operator=( const BGRA8888_t& in )
|
||||
{
|
||||
*( unsigned int * )this = *( unsigned int * )∈
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct RGBA8888_t
|
||||
{
|
||||
unsigned char r; // change the order of names to change the
|
||||
unsigned char g; // order of the output ARGB or BGRA, etc...
|
||||
unsigned char b; // Last one is MSB, 1st is LSB.
|
||||
unsigned char a;
|
||||
inline RGBA8888_t& operator=( const BGRA8888_t& in )
|
||||
{
|
||||
r = in.r;
|
||||
g = in.g;
|
||||
b = in.b;
|
||||
a = in.a;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct RGB888_t
|
||||
{
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
inline RGB888_t& operator=( const BGRA8888_t& in )
|
||||
{
|
||||
r = in.r;
|
||||
g = in.g;
|
||||
b = in.b;
|
||||
return *this;
|
||||
}
|
||||
inline bool operator==( const RGB888_t& in ) const
|
||||
{
|
||||
return ( r == in.r ) && ( g == in.g ) && ( b == in.b );
|
||||
}
|
||||
inline bool operator!=( const RGB888_t& in ) const
|
||||
{
|
||||
return ( r != in.r ) || ( g != in.g ) || ( b != in.b );
|
||||
}
|
||||
};
|
||||
|
||||
struct BGR888_t
|
||||
{
|
||||
unsigned char b;
|
||||
unsigned char g;
|
||||
unsigned char r;
|
||||
inline BGR888_t& operator=( const BGRA8888_t& in )
|
||||
{
|
||||
r = in.r;
|
||||
g = in.g;
|
||||
b = in.b;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
// 360 uses this structure for x86 dxt decoding
|
||||
#if defined( _X360 )
|
||||
#pragma bitfield_order( push, lsb_to_msb )
|
||||
#endif
|
||||
struct BGR565_t
|
||||
{
|
||||
unsigned short b : 5; // order of names changes
|
||||
unsigned short g : 6; // byte order of output to 32 bit
|
||||
unsigned short r : 5;
|
||||
inline BGR565_t& operator=( const BGRA8888_t& in )
|
||||
{
|
||||
r = in.r >> 3;
|
||||
g = in.g >> 2;
|
||||
b = in.b >> 3;
|
||||
return *this;
|
||||
}
|
||||
inline BGR565_t &Set( int red, int green, int blue )
|
||||
{
|
||||
r = red >> 3;
|
||||
g = green >> 2;
|
||||
b = blue >> 3;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
#if defined( _X360 )
|
||||
#pragma bitfield_order( pop )
|
||||
#endif
|
||||
|
||||
struct BGRA5551_t
|
||||
{
|
||||
unsigned short b : 5; // order of names changes
|
||||
unsigned short g : 5; // byte order of output to 32 bit
|
||||
unsigned short r : 5;
|
||||
unsigned short a : 1;
|
||||
inline BGRA5551_t& operator=( const BGRA8888_t& in )
|
||||
{
|
||||
r = in.r >> 3;
|
||||
g = in.g >> 3;
|
||||
b = in.b >> 3;
|
||||
a = in.a >> 7;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct BGRA4444_t
|
||||
{
|
||||
unsigned short b : 4; // order of names changes
|
||||
unsigned short g : 4; // byte order of output to 32 bit
|
||||
unsigned short r : 4;
|
||||
unsigned short a : 4;
|
||||
inline BGRA4444_t& operator=( const BGRA8888_t& in )
|
||||
{
|
||||
r = in.r >> 4;
|
||||
g = in.g >> 4;
|
||||
b = in.b >> 4;
|
||||
a = in.a >> 4;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct RGBX5551_t
|
||||
{
|
||||
unsigned short r : 5;
|
||||
unsigned short g : 5;
|
||||
unsigned short b : 5;
|
||||
unsigned short x : 1;
|
||||
inline RGBX5551_t& operator=( const BGRA8888_t& in )
|
||||
{
|
||||
r = in.r >> 3;
|
||||
g = in.g >> 3;
|
||||
b = in.b >> 3;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// some important constants
|
||||
//-----------------------------------------------------------------------------
|
||||
#define ARTWORK_GAMMA ( 2.2f )
|
||||
#define IMAGE_MAX_DIM ( 2048 )
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// information about each image format
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ImageFormatInfo_t
|
||||
{
|
||||
char* m_pName;
|
||||
int m_NumBytes;
|
||||
int m_NumRedBits;
|
||||
int m_NumGreeBits;
|
||||
int m_NumBlueBits;
|
||||
int m_NumAlphaBits;
|
||||
bool m_IsCompressed:1;
|
||||
bool m_IsFloat:1;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Various methods related to pixelmaps and color formats
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace ImageLoader
|
||||
{
|
||||
|
||||
bool GetInfo( const char *fileName, int *width, int *height, enum ImageFormat *imageFormat, float *sourceGamma );
|
||||
int GetMemRequired( int width, int height, int depth, ImageFormat imageFormat, bool mipmap );
|
||||
int GetMipMapLevelByteOffset( int width, int height, enum ImageFormat imageFormat, int skipMipLevels, int nDepth = 1 );
|
||||
void GetMipMapLevelDimensions( int *width, int *height, int skipMipLevels );
|
||||
int GetNumMipMapLevels( int width, int height, int depth = 1 );
|
||||
bool Load( unsigned char *imageData, const char *fileName, int width, int height, enum ImageFormat imageFormat, float targetGamma, bool mipmap );
|
||||
bool Load( unsigned char *imageData, FILE *fp, int width, int height,
|
||||
enum ImageFormat imageFormat, float targetGamma, bool mipmap );
|
||||
|
||||
// convert from any image format to any other image format.
|
||||
// return false if the conversion cannot be performed.
|
||||
// Strides denote the number of bytes per each line,
|
||||
// by default assumes width * # of bytes per pixel
|
||||
bool ConvertImageFormat( const unsigned char *src, enum ImageFormat srcImageFormat,
|
||||
unsigned char *dst, enum ImageFormat dstImageFormat,
|
||||
int width, int height, int srcStride = 0, int dstStride = 0 );
|
||||
|
||||
// must be used in conjunction with ConvertImageFormat() to pre-swap and post-swap
|
||||
void PreConvertSwapImageData( unsigned char *pImageData, int nImageSize, ImageFormat imageFormat, int width = 0, int stride = 0 );
|
||||
void PostConvertSwapImageData( unsigned char *pImageData, int nImageSize, ImageFormat imageFormat, int width = 0, int stride = 0 );
|
||||
void ByteSwapImageData( unsigned char *pImageData, int nImageSize, ImageFormat imageFormat, int width = 0, int stride = 0 );
|
||||
bool IsFormatValidForConversion( ImageFormat fmt );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// convert back and forth from D3D format to ImageFormat, regardless of
|
||||
// whether it's supported or not
|
||||
//-----------------------------------------------------------------------------
|
||||
ImageFormat D3DFormatToImageFormat( D3DFORMAT format );
|
||||
D3DFORMAT ImageFormatToD3DFormat( ImageFormat format );
|
||||
|
||||
// Flags for ResampleRGBA8888
|
||||
enum
|
||||
{
|
||||
RESAMPLE_NORMALMAP = 0x1,
|
||||
RESAMPLE_ALPHATEST = 0x2,
|
||||
RESAMPLE_NICE_FILTER = 0x4,
|
||||
RESAMPLE_CLAMPS = 0x8,
|
||||
RESAMPLE_CLAMPT = 0x10,
|
||||
RESAMPLE_CLAMPU = 0x20,
|
||||
};
|
||||
|
||||
struct ResampleInfo_t
|
||||
{
|
||||
|
||||
ResampleInfo_t() : m_nFlags(0), m_flAlphaThreshhold(0.4f), m_flAlphaHiFreqThreshhold(0.4f), m_nSrcDepth(1), m_nDestDepth(1)
|
||||
{
|
||||
m_flColorScale[0] = 1.0f, m_flColorScale[1] = 1.0f, m_flColorScale[2] = 1.0f, m_flColorScale[3] = 1.0f;
|
||||
m_flColorGoal[0] = 0.0f, m_flColorGoal[1] = 0.0f, m_flColorGoal[2] = 0.0f, m_flColorGoal[3] = 0.0f;
|
||||
}
|
||||
|
||||
unsigned char *m_pSrc;
|
||||
unsigned char *m_pDest;
|
||||
|
||||
int m_nSrcWidth;
|
||||
int m_nSrcHeight;
|
||||
int m_nSrcDepth;
|
||||
|
||||
int m_nDestWidth;
|
||||
int m_nDestHeight;
|
||||
int m_nDestDepth;
|
||||
|
||||
float m_flSrcGamma;
|
||||
float m_flDestGamma;
|
||||
|
||||
float m_flColorScale[4]; // Color scale factors RGBA
|
||||
float m_flColorGoal[4]; // Color goal values RGBA DestColor = ColorGoal + scale * (SrcColor - ColorGoal)
|
||||
|
||||
float m_flAlphaThreshhold;
|
||||
float m_flAlphaHiFreqThreshhold;
|
||||
|
||||
int m_nFlags;
|
||||
};
|
||||
|
||||
bool ResampleRGBA8888( const ResampleInfo_t &info );
|
||||
bool ResampleRGBA16161616( const ResampleInfo_t &info );
|
||||
bool ResampleRGB323232F( const ResampleInfo_t &info );
|
||||
|
||||
void ConvertNormalMapRGBA8888ToDUDVMapUVLX8888( const unsigned char *src, int width, int height, unsigned char *dst_ );
|
||||
void ConvertNormalMapRGBA8888ToDUDVMapUVWQ8888( const unsigned char *src, int width, int height, unsigned char *dst_ );
|
||||
void ConvertNormalMapRGBA8888ToDUDVMapUV88( const unsigned char *src, int width, int height, unsigned char *dst_ );
|
||||
void ConvertNormalMapARGB8888ToDXT5GA( const unsigned char *src, unsigned char *dst, int width, int height );
|
||||
|
||||
void ConvertIA88ImageToNormalMapRGBA8888( const unsigned char *src, int width,
|
||||
int height, unsigned char *dst,
|
||||
float bumpScale );
|
||||
|
||||
void NormalizeNormalMapRGBA8888( unsigned char *src, int numTexels );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gamma correction
|
||||
//-----------------------------------------------------------------------------
|
||||
void GammaCorrectRGBA8888( unsigned char *src, unsigned char* dst,
|
||||
int width, int height, int depth, float srcGamma, float dstGamma );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Makes a gamma table
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConstructGammaTable( unsigned char* pTable, float srcGamma, float dstGamma );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gamma corrects using a previously constructed gamma table
|
||||
//-----------------------------------------------------------------------------
|
||||
void GammaCorrectRGBA8888( unsigned char* pSrc, unsigned char* pDst,
|
||||
int width, int height, int depth, unsigned char* pGammaTable );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Generates a number of mipmap levels
|
||||
//-----------------------------------------------------------------------------
|
||||
void GenerateMipmapLevels( unsigned char* pSrc, unsigned char* pDst, int width,
|
||||
int height, int depth, ImageFormat imageFormat, float srcGamma, float dstGamma,
|
||||
int numLevels = 0 );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// operations on square images (src and dst can be the same)
|
||||
//-----------------------------------------------------------------------------
|
||||
bool RotateImageLeft( const unsigned char *src, unsigned char *dst,
|
||||
int widthHeight, ImageFormat imageFormat );
|
||||
bool RotateImage180( const unsigned char *src, unsigned char *dst,
|
||||
int widthHeight, ImageFormat imageFormat );
|
||||
bool FlipImageVertically( void *pSrc, void *pDst, int nWidth, int nHeight, ImageFormat imageFormat, int nDstStride = 0 );
|
||||
bool FlipImageHorizontally( void *pSrc, void *pDst, int nWidth, int nHeight, ImageFormat imageFormat, int nDstStride = 0 );
|
||||
bool SwapAxes( unsigned char *src,
|
||||
int widthHeight, ImageFormat imageFormat );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns info about each image format
|
||||
//-----------------------------------------------------------------------------
|
||||
ImageFormatInfo_t const& ImageFormatInfo( ImageFormat fmt );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets the name of the image format
|
||||
//-----------------------------------------------------------------------------
|
||||
inline char const* GetName( ImageFormat fmt )
|
||||
{
|
||||
return ImageFormatInfo(fmt).m_pName;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets the size of the image format in bytes
|
||||
//-----------------------------------------------------------------------------
|
||||
inline int SizeInBytes( ImageFormat fmt )
|
||||
{
|
||||
return ImageFormatInfo(fmt).m_NumBytes;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Does the image format support transparency?
|
||||
//-----------------------------------------------------------------------------
|
||||
inline bool IsTransparent( ImageFormat fmt )
|
||||
{
|
||||
return ImageFormatInfo(fmt).m_NumAlphaBits > 0;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Is the image format compressed?
|
||||
//-----------------------------------------------------------------------------
|
||||
inline bool IsCompressed( ImageFormat fmt )
|
||||
{
|
||||
return ImageFormatInfo(fmt).m_IsCompressed;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Is any channel > 8 bits?
|
||||
//-----------------------------------------------------------------------------
|
||||
inline bool HasChannelLargerThan8Bits( ImageFormat fmt )
|
||||
{
|
||||
ImageFormatInfo_t info = ImageFormatInfo(fmt);
|
||||
return ( info.m_NumRedBits > 8 || info.m_NumGreeBits > 8 || info.m_NumBlueBits > 8 || info.m_NumAlphaBits > 8 );
|
||||
}
|
||||
|
||||
inline bool IsFloatFormat( ImageFormat fmt )
|
||||
{
|
||||
return ( fmt == IMAGE_FORMAT_RGBA16161616F ) ||
|
||||
( fmt == IMAGE_FORMAT_R32F ) ||
|
||||
( fmt == IMAGE_FORMAT_RGB323232F ) ||
|
||||
( fmt == IMAGE_FORMAT_RGBA32323232F );
|
||||
}
|
||||
|
||||
} // end namespace ImageLoader
|
||||
|
||||
|
||||
#endif // IMAGEFORMAT_H
|
||||
+1253
File diff suppressed because it is too large
Load Diff
+4439
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,20 @@ public:
|
||||
// This function will return false for users who have a retail or other type of license
|
||||
// Before using, please ask your Valve technical contact how to package and secure your free weekened
|
||||
virtual bool BIsSubscribedFromFreeWeekend() = 0;
|
||||
// Returns the number of DLC pieces for the running app
|
||||
virtual int GetDLCCount() = 0;
|
||||
|
||||
// Returns metadata for DLC by index, of range [0, GetDLCCount()]
|
||||
virtual bool BGetDLCDataByIndex( int iDLC, AppId_t *pAppID, bool *pbAvailable, char *pchName, int cchNameBufferSize ) = 0;
|
||||
|
||||
// Install/Uninstall control for optional DLC
|
||||
virtual void InstallDLC( AppId_t nAppID ) = 0;
|
||||
virtual void UninstallDLC( AppId_t nAppID ) = 0;
|
||||
|
||||
#ifdef _PS3
|
||||
// Result returned in a RegisterActivationCodeResponse_t callresult
|
||||
virtual SteamAPICall_t RegisterActivationCode( const char *pchActivationCode ) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define STEAMAPPS_INTERFACE_VERSION "STEAMAPPS_INTERFACE_VERSION004"
|
||||
|
||||
@@ -42,6 +42,7 @@ class ISteamApps;
|
||||
class ISteamNetworking;
|
||||
class ISteamRemoteStorage;
|
||||
class ISteamGameServerStats;
|
||||
class ISteamPS3OverlayRender;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Interface to creating a new steam instance, or to
|
||||
@@ -133,6 +134,10 @@ public:
|
||||
// Trigger global shutdown for the DLL
|
||||
virtual bool BShutdownIfAllPipesClosed() = 0;
|
||||
|
||||
#ifdef _PS3
|
||||
virtual ISteamPS3OverlayRender *GetISteamPS3OverlayRender() = 0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#define STEAMCLIENT_INTERFACE_VERSION "SteamClient010"
|
||||
|
||||
@@ -93,7 +93,10 @@ enum EUserRestriction
|
||||
{
|
||||
k_nUserRestrictionNone = 0, // no known chat/content restriction
|
||||
k_nUserRestrictionUnknown = 1, // we don't know yet (user offline)
|
||||
k_nUserRestrictionChat = 2, // user is not allowed to send/recv text/voice chat
|
||||
k_nUserRestrictionAnyChat = 2, // user is not allowed to (or can't) send/recv any chat
|
||||
k_nUserRestrictionVoiceChat = 4, // user is not allowed to (or can't) send/recv voice chat
|
||||
k_nUserRestrictionGroupChat = 8, // user is not allowed to (or can't) send/recv group chat
|
||||
k_nUserRestrictionRating = 16, // user is too young according to rating in current region
|
||||
};
|
||||
|
||||
|
||||
@@ -101,6 +104,12 @@ enum EUserRestriction
|
||||
// size limit on chat room or member metadata
|
||||
const uint32 k_cubChatMetadataMax = 8192;
|
||||
|
||||
// size limits on Rich Presence data
|
||||
enum { k_cchMaxRichPresenceKeys = 20 };
|
||||
enum { k_cchMaxRichPresenceKeyLength = 64 };
|
||||
enum { k_cchMaxRichPresenceValueLength = 256 };
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: interface to accessing information about individual users,
|
||||
// that can be a friend, in a group, on a game server or in a lobby with the local user
|
||||
@@ -236,9 +245,39 @@ public:
|
||||
// the user can't see custom avatars. But the user can be online and send/recv game invites.
|
||||
// a chat restricted user can't add friends or join any groups.
|
||||
virtual uint32 GetUserRestrictions() = 0;
|
||||
|
||||
// Rich Presence data is automatically shared between friends who are in the same game
|
||||
// Each user has a set of Key/Value pairs
|
||||
// Up to 20 different keys can be set
|
||||
// There are two magic keys:
|
||||
// "status" - a UTF-8 string that will show up in the 'view game info' dialog in the Steam friends list
|
||||
// "connect" - a UTF-8 string that contains the command-line for how a friend can connect to a game
|
||||
// GetFriendRichPresence() returns an empty string "" if no value is set
|
||||
// SetRichPresence() to a NULL or an empty string deletes the key
|
||||
// You can iterate the current set of keys for a friend with GetFriendRichPresenceKeyCount()
|
||||
// and GetFriendRichPresenceKeyByIndex() (typically only used for debugging)
|
||||
virtual bool SetRichPresence( const char *pchKey, const char *pchValue ) = 0;
|
||||
virtual void ClearRichPresence() = 0;
|
||||
virtual const char *GetFriendRichPresence( CSteamID steamIDFriend, const char *pchKey ) = 0;
|
||||
virtual int GetFriendRichPresenceKeyCount( CSteamID steamIDFriend ) = 0;
|
||||
virtual const char *GetFriendRichPresenceKeyByIndex( CSteamID steamIDFriend, int iKey ) = 0;
|
||||
|
||||
// rich invite support
|
||||
// if the target accepts the invite, the pchConnectString gets added to the command-line for launching the game
|
||||
// if the game is already running, a GameRichPresenceJoinRequested_t callback is posted containing the connect string
|
||||
// invites can only be sent to friends
|
||||
virtual bool InviteUserToGame( CSteamID steamIDFriend, const char *pchConnectString ) = 0;
|
||||
|
||||
// recently-played-with friends iteration
|
||||
// this iterates the entire list of users recently played with, across games
|
||||
// GetFriendCoplayTime() returns as a unix time
|
||||
virtual int GetCoplayFriendCount() = 0;
|
||||
virtual CSteamID GetCoplayFriend( int iCoplayFriend ) = 0;
|
||||
virtual int GetFriendCoplayTime( CSteamID steamIDFriend ) = 0;
|
||||
virtual AppId_t GetFriendCoplayGame( CSteamID steamIDFriend ) = 0;
|
||||
};
|
||||
|
||||
#define STEAMFRIENDS_INTERFACE_VERSION "SteamFriends008"
|
||||
#define STEAMFRIENDS_INTERFACE_VERSION "SteamFriends009"
|
||||
|
||||
// callbacks
|
||||
#pragma pack( push, 8 )
|
||||
@@ -333,6 +372,26 @@ struct ClanOfficerListResponse_t
|
||||
uint8 m_bSuccess;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: callback indicating updated data about friends rich presence information
|
||||
//-----------------------------------------------------------------------------
|
||||
struct FriendRichPresenceUpdate_t
|
||||
{
|
||||
enum { k_iCallback = k_iSteamFriendsCallbacks + 36 };
|
||||
CSteamID m_steamIDFriend; // friend who's rich presence has changed
|
||||
AppId_t m_nAppID; // the appID of the game (should always be the current game)
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called when the user tries to join a game from their friends list
|
||||
// rich presence will have been set with the "connect" key which is set here
|
||||
//-----------------------------------------------------------------------------
|
||||
struct GameRichPresenceJoinRequested_t
|
||||
{
|
||||
enum { k_iCallback = k_iSteamFriendsCallbacks + 37 };
|
||||
CSteamID m_steamIDFriend; // the friend they did the join via (will be invalid if not directly via a friend)
|
||||
char m_rgchConnect[k_cchMaxRichPresenceValueLength];
|
||||
};
|
||||
|
||||
#pragma pack( pop )
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
//====== Copyright © 1996-2009, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose: interface to http client
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ISTEAMHTTP_H
|
||||
#define ISTEAMHTTP_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "isteamclient.h"
|
||||
#include "steamhttpenums.h"
|
||||
|
||||
// Handle to a depot build
|
||||
typedef uint32 HTTPRequestHandle;
|
||||
#define INVALID_HTTPREQUEST_HANDLE 0
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: interface to building depots
|
||||
//-----------------------------------------------------------------------------
|
||||
class ISteamHTTP
|
||||
{
|
||||
public:
|
||||
|
||||
// Initializes a new HTTP request, returning a handle to use in further operations on it. Requires
|
||||
// the method (GET or POST) and the absolute URL for the request. Only http requests (ie, not https) are
|
||||
// currently supported, so this string must start with http:// or https:// and should look like http://store.steampowered.com/app/250/
|
||||
// or such.
|
||||
virtual HTTPRequestHandle CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod, const char *pchAbsoluteURL ) = 0;
|
||||
|
||||
// Set a context value for the request, which will be returned in the HTTPRequestCompleted_t callback after
|
||||
// sending the request. This is just so the caller can easily keep track of which callbacks go with which request data.
|
||||
virtual bool SetHTTPRequestContextValue( HTTPRequestHandle hRequest, uint64 ulContextValue ) = 0;
|
||||
|
||||
// Set a timeout in seconds for the HTTP request, must be called prior to sending the request. Default
|
||||
// timeout is 60 seconds if you don't call this. Returns false if the handle is invalid, or the request
|
||||
// has already been sent.
|
||||
virtual bool SetHTTPRequestNetworkActivityTimeout( HTTPRequestHandle hRequest, uint32 unTimeoutSeconds ) = 0;
|
||||
|
||||
// Set a request header value for the request, must be called prior to sending the request. Will
|
||||
// return false if the handle is invalid or the request is already sent.
|
||||
virtual bool SetHTTPRequestHeaderValue( HTTPRequestHandle hRequest, const char *pchHeaderName, const char *pchHeaderValue ) = 0;
|
||||
|
||||
// Set a GET or POST parameter value on the request, which is set will depend on the EHTTPMethod specified
|
||||
// when creating the request. Must be called prior to sending the request. Will return false if the
|
||||
// handle is invalid or the request is already sent.
|
||||
virtual bool SetHTTPRequestGetOrPostParameter( HTTPRequestHandle hRequest, const char *pchParamName, const char *pchParamValue ) = 0;
|
||||
|
||||
// Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on
|
||||
// asyncronous response via callback.
|
||||
//
|
||||
// Note: If the user is in offline mode in Steam, then this will add a only-if-cached cache-control
|
||||
// header and only do a local cache lookup rather than sending any actual remote request.
|
||||
virtual bool SendHTTPRequest( HTTPRequestHandle hRequest, SteamAPICall_t *pCallHandle ) = 0;
|
||||
|
||||
// Defers a request you have sent, the actual HTTP client code may have many requests queued, and this will move
|
||||
// the specified request to the tail of the queue. Returns false on invalid handle, or if the request is not yet sent.
|
||||
virtual bool DeferHTTPRequest( HTTPRequestHandle hRequest ) = 0;
|
||||
|
||||
// Prioritizes a request you have sent, the actual HTTP client code may have many requests queued, and this will move
|
||||
// the specified request to the head of the queue. Returns false on invalid handle, or if the request is not yet sent.
|
||||
virtual bool PrioritizeHTTPRequest( HTTPRequestHandle hRequest ) = 0;
|
||||
|
||||
// Checks if a response header is present in a HTTP response given a handle from HTTPRequestCompleted_t, also
|
||||
// returns the size of the header value if present so the caller and allocate a correctly sized buffer for
|
||||
// GetHTTPResponseHeaderValue.
|
||||
virtual bool GetHTTPResponseHeaderSize( HTTPRequestHandle hRequest, const char *pchHeaderName, uint32 *unResponseHeaderSize ) = 0;
|
||||
|
||||
// Gets header values from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the
|
||||
// header is not present or if your buffer is too small to contain it's value. You should first call
|
||||
// BGetHTTPResponseHeaderSize to check for the presence of the header and to find out the size buffer needed.
|
||||
virtual bool GetHTTPResponseHeaderValue( HTTPRequestHandle hRequest, const char *pchHeaderName, uint8 *pHeaderValueBuffer, uint32 unBufferSize ) = 0;
|
||||
|
||||
// Gets the size of the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the
|
||||
// handle is invalid.
|
||||
virtual bool GetHTTPResponseBodySize( HTTPRequestHandle hRequest, uint32 *unBodySize ) = 0;
|
||||
|
||||
// Gets the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the
|
||||
// handle is invalid or if the provided buffer is not the correct size. Use BGetHTTPResponseBodySize first to find out
|
||||
// the correct buffer size to use.
|
||||
virtual bool GetHTTPResponseBodyData( HTTPRequestHandle hRequest, uint8 *pBodyDataBuffer, uint32 unBufferSize ) = 0;
|
||||
|
||||
// Releases an HTTP response handle, should always be called to free resources after receiving a HTTPRequestCompleted_t
|
||||
// callback and finishing using the response.
|
||||
virtual bool ReleaseHTTPRequest( HTTPRequestHandle hRequest ) = 0;
|
||||
};
|
||||
|
||||
#define STEAMHTTP_INTERFACE_VERSION "STEAMHTTP_INTERFACE_VERSION001"
|
||||
|
||||
|
||||
struct HTTPRequestCompleted_t
|
||||
{
|
||||
enum { k_iCallback = k_iClientHTTPCallbacks + 1 };
|
||||
|
||||
// Handle value for the request that has completed.
|
||||
HTTPRequestHandle m_hRequest;
|
||||
|
||||
// Context value that the user defined on the request that this callback is associated with, 0 if
|
||||
// no context value was set.
|
||||
uint64 m_ulContextValue;
|
||||
|
||||
// This will be true if we actually got any sort of response from the server (even an error).
|
||||
// It will be false if we failed due to an internal error or client side network failure.
|
||||
bool m_bRequestSuccessful;
|
||||
|
||||
// Will be the HTTP status code value returned by the server, k_EHTTPStatusCode200OK is the normal
|
||||
// OK response, if you get something else you probably need to treat it as a failure.
|
||||
EHTTPStatusCode m_eStatusCode;
|
||||
};
|
||||
|
||||
|
||||
#endif // ISTEAMHTTP_H
|
||||
@@ -239,6 +239,13 @@ public:
|
||||
// you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby
|
||||
// after completion, the local user will no longer be the owner
|
||||
virtual bool SetLobbyOwner( CSteamID steamIDLobby, CSteamID steamIDNewOwner ) = 0;
|
||||
|
||||
#ifdef _PS3
|
||||
// changes who the lobby owner is
|
||||
// you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby
|
||||
// after completion, the local user will no longer be the owner
|
||||
virtual void CheckForPSNGameBootInvite( unsigned int iGameBootAttributes ) = 0;
|
||||
#endif
|
||||
};
|
||||
#define STEAMMATCHMAKING_INTERFACE_VERSION "SteamMatchMaking008"
|
||||
|
||||
@@ -502,6 +509,7 @@ struct LobbyInvite_t
|
||||
|
||||
uint64 m_ulSteamIDUser; // Steam ID of the person making the invite
|
||||
uint64 m_ulSteamIDLobby; // Steam ID of the Lobby
|
||||
uint64 m_ulGameID; // GameID of the Lobby
|
||||
};
|
||||
|
||||
|
||||
@@ -631,6 +639,21 @@ struct LobbyCreated_t
|
||||
|
||||
// used by now obsolete RequestFriendsLobbiesResponse_t
|
||||
// enum { k_iCallback = k_iSteamMatchmakingCallbacks + 14 };
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Result of CheckForPSNGameBootInvite
|
||||
// m_eResult == k_EResultOK on success
|
||||
// at this point, the local user may not have finishing joining this lobby;
|
||||
// game code should wait until the subsequent LobbyEnter_t callback is received
|
||||
//-----------------------------------------------------------------------------
|
||||
struct PSNGameBootInviteResult_t
|
||||
{
|
||||
enum { k_iCallback = k_iSteamMatchmakingCallbacks + 15 };
|
||||
|
||||
bool m_bGameBootInviteExists;
|
||||
CSteamID m_steamIDLobby; // Should be valid if m_bGameBootInviteExists == true
|
||||
};
|
||||
#pragma pack( pop )
|
||||
|
||||
|
||||
|
||||
@@ -129,19 +129,20 @@ public:
|
||||
// the first packet send may be delayed as the NAT-traversal code runs
|
||||
// if we can't get through to the user, an error will be posted via the callback P2PSessionConnectFail_t
|
||||
// see EP2PSend enum above for the descriptions of the different ways of sending packets
|
||||
// nVirtualPort is a routing number you can use to help route message to different systems - you'll have to call ReadP2PPacket()
|
||||
// with the same nVirtualPort number in order to retrieve the data on the other end
|
||||
// using different virtual ports to talk to the same user will still use the same underlying p2p connection, saving on resources
|
||||
virtual bool SendP2PPacket( CSteamID steamIDRemote, const void *pubData, uint32 cubData, EP2PSend eP2PSendType, int nVirtualPort = 0 ) = 0;
|
||||
//
|
||||
// nChannel is a routing number you can use to help route message to different systems - you'll have to call ReadP2PPacket()
|
||||
// with the same channel number in order to retrieve the data on the other end
|
||||
// using different channels to talk to the same user will still use the same underlying p2p connection, saving on resources
|
||||
virtual bool SendP2PPacket( CSteamID steamIDRemote, const void *pubData, uint32 cubData, EP2PSend eP2PSendType, int nChannel = 0 ) = 0;
|
||||
|
||||
// returns true if any data is available for read, and the amount of data that will need to be read
|
||||
virtual bool IsP2PPacketAvailable( uint32 *pcubMsgSize, int nVirtualPort = 0 ) = 0;
|
||||
virtual bool IsP2PPacketAvailable( uint32 *pcubMsgSize, int nChannel = 0 ) = 0;
|
||||
|
||||
// reads in a packet that has been sent from another user via SendP2PPacket()
|
||||
// returns the size of the message and the steamID of the user who sent it in the last two parameters
|
||||
// if the buffer passed in is too small, the message will be truncated
|
||||
// this call is not blocking, and will return false if no data is available
|
||||
virtual bool ReadP2PPacket( void *pubDest, uint32 cubDest, uint32 *pcubMsgSize, CSteamID *psteamIDRemote, int nVirtualPort = 0 ) = 0;
|
||||
virtual bool ReadP2PPacket( void *pubDest, uint32 cubDest, uint32 *pcubMsgSize, CSteamID *psteamIDRemote, int nChannel = 0 ) = 0;
|
||||
|
||||
// AcceptP2PSessionWithUser() should only be called in response to a P2PSessionRequest_t callback
|
||||
// P2PSessionRequest_t will be posted if another user tries to send you a packet that you haven't talked to yet
|
||||
@@ -155,11 +156,23 @@ public:
|
||||
// if the remote user tries to send data to you again, another P2PSessionRequest_t callback will be posted
|
||||
virtual bool CloseP2PSessionWithUser( CSteamID steamIDRemote ) = 0;
|
||||
|
||||
// call CloseP2PChannelWithUser() when you're done talking to a user on a specific channel. Once all channels
|
||||
// open channels to a user have been closed, the open session to the user will be closed and new data from this
|
||||
// user will trigger a P2PSessionRequest_t callback
|
||||
virtual bool CloseP2PChannelWithUser( CSteamID steamIDRemote, int nChannel ) = 0;
|
||||
|
||||
// fills out P2PSessionState_t structure with details about the underlying connection to the user
|
||||
// should only needed for debugging purposes
|
||||
// returns false if no connection exists to the specified user
|
||||
virtual bool GetP2PSessionState( CSteamID steamIDRemote, P2PSessionState_t *pConnectionState ) = 0;
|
||||
|
||||
// Allow P2P connections to fall back to being relayed through the Steam servers if a direct connection
|
||||
// or NAT-traversal cannot be established. Only applies to connections created after setting this value,
|
||||
// or to existing connections that need to automatically reconnect after this value is set.
|
||||
//
|
||||
// P2P packet relay is allowed by default
|
||||
virtual bool AllowP2PPacketRelay( bool bAllow ) = 0;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LISTEN / CONNECT style interface functions
|
||||
@@ -240,7 +253,7 @@ public:
|
||||
// max packet size, in bytes
|
||||
virtual int GetMaxPacketSize( SNetSocket_t hSocket ) = 0;
|
||||
};
|
||||
#define STEAMNETWORKING_INTERFACE_VERSION "SteamNetworking004"
|
||||
#define STEAMNETWORKING_INTERFACE_VERSION "SteamNetworking005"
|
||||
|
||||
// callbacks
|
||||
#pragma pack( push, 8 )
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
//====== Copyright © 1996-2010, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose: interface the game must provide Steam with on PS3 in order for the
|
||||
// Steam overlay to render.
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ISTEAMPS3OVERLAYRENDERER_H
|
||||
#define ISTEAMPS3OVERLAYRENDERER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "cell/pad.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Enum for supported gradient directions
|
||||
//-----------------------------------------------------------------------------
|
||||
enum EOverlayGradientDirection
|
||||
{
|
||||
k_EOverlayGradientHorizontal = 1,
|
||||
k_EOverlayGradientVertical = 2,
|
||||
k_EOverlayGradientNone = 3,
|
||||
};
|
||||
|
||||
// Helpers for fetching individual color components from ARGB packed DWORD colors Steam PS3 overlay renderer uses.
|
||||
#define STEAM_COLOR_RED( color ) \
|
||||
(int)(((color)>>16)&0xff)
|
||||
|
||||
#define STEAM_COLOR_GREEN( color ) \
|
||||
(int)(((color)>>8)&0xff)
|
||||
|
||||
#define STEAM_COLOR_BLUE( color ) \
|
||||
(int)((color)&0xff)
|
||||
|
||||
#define STEAM_COLOR_ALPHA( color ) \
|
||||
(int)(((color)>>24)&0xff)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Interface the game must expose to Steam for rendering
|
||||
//-----------------------------------------------------------------------------
|
||||
class ISteamPS3OverlayRenderHost
|
||||
{
|
||||
public:
|
||||
|
||||
// Interface for game engine to implement which Steam requires to render.
|
||||
|
||||
// Draw a textured rect. This may use only part of the texture and will pass texture coords, it will also possibly request a gradient and will specify colors for vertexes.
|
||||
virtual void DrawTexturedRect( int x0, int y0, int x1, int y1, float u0, float v0, float u1, float v1, int32 iTextureID, DWORD colorStart, DWORD colorEnd, EOverlayGradientDirection eDirection ) = 0;
|
||||
|
||||
// Load a RGBA texture for Steam, or update a previously loaded one. Updates may be partial. You must not evict or remove this texture once Steam has uploaded it.
|
||||
virtual void LoadOrUpdateTexture( int32 iTextureID, bool bIsFullTexture, int x0, int y0, uint32 uWidth, uint32 uHeight, int32 iBytes, char *pData ) = 0;
|
||||
|
||||
// Delete a texture Steam previously uploaded
|
||||
virtual void DeleteTexture( int32 iTextureID ) = 0;
|
||||
|
||||
// Delete all previously uploaded textures
|
||||
virtual void DeleteAllTextures() = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Interface Steam exposes for the game to tell it when to render, etc.
|
||||
//-----------------------------------------------------------------------------
|
||||
class ISteamPS3OverlayRender
|
||||
{
|
||||
public:
|
||||
|
||||
// Call once at startup to initialize the Steam overlay and pass it your host interface ptr
|
||||
virtual bool BHostInitialize( uint32 unScreenWidth, uint32 unScreenHeight, uint32 unRefreshRate, ISteamPS3OverlayRenderHost *pRenderHost, void *CellFontLib ) = 0;
|
||||
|
||||
// Call this once a frame when you are ready for the Steam overlay to render (ie, right before flipping buffers, after all your rendering)
|
||||
virtual void Render() = 0;
|
||||
|
||||
// Call this everytime you read input on PS3.
|
||||
//
|
||||
// If this returns true, then the overlay is active and has consumed the input, your game
|
||||
// should then ignore all the input until BHandleCellPadData once again returns false, which
|
||||
// will mean the overlay is deactivated.
|
||||
virtual bool BHandleCellPadData( const CellPadData &padData ) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // ISTEAMPS3OVERLAYRENDERER_H
|
||||
@@ -25,10 +25,12 @@ enum EResolveConflict
|
||||
|
||||
enum ERemoteStoragePlatform
|
||||
{
|
||||
k_ERemoteStoragePlatformNone = 0,
|
||||
k_ERemoteStoragePlatformWindows = (1 << 0),
|
||||
k_ERemoteStoragePlatformOSX = (1 << 1 ),
|
||||
k_ERemoteStoragePlatformPS3 = (1 << 2),
|
||||
k_ERemoteStoragePlatformNone = 0,
|
||||
k_ERemoteStoragePlatformWindows = (1 << 0),
|
||||
k_ERemoteStoragePlatformOSX = (1 << 1 ),
|
||||
k_ERemoteStoragePlatformPS3 = (1 << 2),
|
||||
k_ERemoteStoragePlatformReserved1 = (1 << 3),
|
||||
k_ERemoteStoragePlatformReserved2 = (1 << 4),
|
||||
|
||||
k_ERemoteStoragePlatformAll = 0xffffffff
|
||||
};
|
||||
|
||||
@@ -89,7 +89,8 @@ public:
|
||||
// This provides both the compressed and uncompressed data. Please note that the uncompressed
|
||||
// data is not the raw feed from the microphone: data may only be available if audible
|
||||
// levels of speech are detected.
|
||||
virtual EVoiceResult GetAvailableVoice(uint32 *pcbCompressed, uint32 *pcbUncompressed) = 0;
|
||||
// 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)
|
||||
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.
|
||||
@@ -101,14 +102,17 @@ public:
|
||||
// You must grab both compressed and uncompressed here at the same time, if you want both.
|
||||
// Matching data that is not read during this call will be thrown away.
|
||||
// GetAvailableVoice() can be used to determine how much data is actually available.
|
||||
virtual EVoiceResult GetVoice( bool bWantCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, bool bWantUncompressed, void *pUncompressedDestBuffer, uint32 cbUncompressedDestBufferSize, uint32 *nUncompressBytesWritten ) = 0;
|
||||
virtual EVoiceResult GetVoice( bool bWantCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, bool bWantUncompressed, void *pUncompressedDestBuffer, uint32 cbUncompressedDestBufferSize, uint32 *nUncompressBytesWritten, uint32 nUncompressedVoiceDesiredSampleRate ) = 0;
|
||||
|
||||
// Decompresses a chunk of compressed data produced by GetVoice().
|
||||
// nBytesWritten is set to the number of bytes written to pDestBuffer unless the return value is k_EVoiceResultBufferTooSmall.
|
||||
// In that case, nBytesWritten is set to the size of the buffer required to decompress the given
|
||||
// data. The suggested buffer size for the destination buffer is 22 kilobytes.
|
||||
// The output format of the data is 16-bit signed at 11025 samples per second.
|
||||
virtual EVoiceResult DecompressVoice( const void *pCompressed, uint32 cbCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten ) = 0;
|
||||
// The output format of the data is 16-bit signed at the requested samples per second.
|
||||
virtual EVoiceResult DecompressVoice( const void *pCompressed, uint32 cbCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, uint32 nDesiredSampleRate ) = 0;
|
||||
|
||||
// This returns the frequency of the voice data as it's stored internally; calling DecompressVoice() with this size will yield the best results
|
||||
virtual uint32 GetVoiceOptimalSampleRate() = 0;
|
||||
|
||||
// Retrieve ticket to be sent to the entity who wishes to authenticate you.
|
||||
// pcbTicket retrieves the length of the actual ticket.
|
||||
@@ -176,11 +180,15 @@ public:
|
||||
// PARAMS: bInteractive - If set tells Steam to go ahead and show the PS3 NetStart dialog if needed to
|
||||
// prompt the user for network setup/PSN logon before initiating the Steam side of the logon.
|
||||
virtual void LogOnAndCreateNewSteamAccountIfNeeded( bool bInteractive ) = 0;
|
||||
|
||||
// Returns a special SteamID that represents the user's PSN information. Can be used to query the user's PSN avatar,
|
||||
// online name, etc. through the standard Steamworks interfaces.
|
||||
virtual CSteamID GetConsoleSteamID() = 0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#define STEAMUSER_INTERFACE_VERSION "SteamUser014"
|
||||
#define STEAMUSER_INTERFACE_VERSION "SteamUser016"
|
||||
|
||||
|
||||
// callbacks
|
||||
|
||||
@@ -116,11 +116,11 @@ public:
|
||||
// Achievement / GroupAchievement metadata
|
||||
|
||||
// Gets the icon of the achievement, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set.
|
||||
// A return value of 0 may indicate we are still fetching data, and you can wait for the UserAchievementIconReady_t callback
|
||||
// which will notify you when the bits are actually read. If the callback still returns zero, then there is no image set
|
||||
// and there never will be.
|
||||
// A return value of 0 may indicate we are still fetching data, and you can wait for the UserAchievementIconFetched_t callback
|
||||
// which will notify you when the bits are ready. If the callback still returns zero, then there is no image set for the
|
||||
// specified achievement.
|
||||
virtual int GetAchievementIcon( const char *pchName ) = 0;
|
||||
// Get general attributes (display name / text, etc) for an Achievement
|
||||
// Get general attributes (display name, desc, etc) for an Achievement
|
||||
virtual const char *GetAchievementDisplayAttribute( const char *pchName, const char *pchKey ) = 0;
|
||||
|
||||
// Achievement progress - triggers an AchievementProgress callback, that is all.
|
||||
@@ -211,6 +211,26 @@ public:
|
||||
// Retrieves the number of players currently playing your game (online + offline)
|
||||
// This call is asynchronous, with the result returned in NumberOfCurrentPlayers_t
|
||||
virtual SteamAPICall_t GetNumberOfCurrentPlayers() = 0;
|
||||
|
||||
#ifdef _PS3
|
||||
// Call to kick off installation of the PS3 trophies. This call is asynchronous, and the results will be returned in a PS3TrophiesInstalled_t
|
||||
// callback.
|
||||
virtual bool InstallPS3Trophies() = 0;
|
||||
|
||||
// Returns the amount of space required at boot to install trophies. This value can be used when comparing the amount of space needed
|
||||
// by the game to the available space value passed to the game at boot. The value is set during InstallPS3Trophies().
|
||||
virtual uint64 GetTrophySpaceRequiredBeforeInstall() = 0;
|
||||
|
||||
// On PS3, user stats & achievement progress through Steam must be stored with the user's saved game data.
|
||||
// At startup, before calling RequestCurrentStats(), you must pass the user's stats data to Steam via this method.
|
||||
// If you do not have any user data, call this function with pvData = NULL and cubData = 0
|
||||
virtual bool SetUserStatsData( const void *pvData, uint32 cubData ) = 0;
|
||||
|
||||
// Call to get the user's current stats data. You should retrieve this data after receiving successful UserStatsReceived_t & UserStatsStored_t
|
||||
// callbacks, and store the data with the user's save game data. You can call this method with pvData = NULL and cubData = 0 to get the required
|
||||
// buffer size.
|
||||
virtual bool GetUserStatsData( void *pvData, uint32 cubData, uint32 *pcubWritten ) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define STEAMUSERSTATS_INTERFACE_VERSION "STEAMUSERSTATS_INTERFACE_VERSION009"
|
||||
@@ -347,6 +367,19 @@ struct LeaderboardUGCSet_t
|
||||
SteamLeaderboard_t m_hSteamLeaderboard; // the leaderboard handle that was
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: callback indicating that PS3 trophies have been installed
|
||||
//-----------------------------------------------------------------------------
|
||||
struct PS3TrophiesInstalled_t
|
||||
{
|
||||
enum { k_iCallback = k_iSteamUserStatsCallbacks + 12 };
|
||||
uint64 m_nGameID; // Game these stats are for
|
||||
EResult m_eResult; // The result of the operation
|
||||
uint64 m_ulRequiredDiskSpace; // If m_eResult is k_EResultDiskFull, will contain the amount of space needed to install trophies
|
||||
|
||||
};
|
||||
|
||||
#pragma pack( pop )
|
||||
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ public:
|
||||
#ifdef _PS3
|
||||
virtual void PostPS3SysutilCallback( uint64_t status, uint64_t param, void* userdata ) = 0;
|
||||
virtual bool BIsReadyToShutdown() = 0;
|
||||
virtual bool BIsPSNOnline() = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -208,6 +209,42 @@ struct NetStartDialogUnloaded_t
|
||||
enum { k_iCallback = k_iSteamUtilsCallbacks + 7 };
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// callback for system menu closing on PS3 - should trigger resyncronizing friends list, etc.
|
||||
//-----------------------------------------------------------------------------
|
||||
struct PS3SystemMenuClosed_t
|
||||
{
|
||||
enum { k_iCallback = k_iSteamUtilsCallbacks + 8 };
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// callback for NP message being selected by user on PS3 - should trigger handling of message if it's a lobby invite, etc.
|
||||
//-----------------------------------------------------------------------------
|
||||
struct PS3NPMessageSelected_t
|
||||
{
|
||||
enum { k_iCallback = k_iSteamUtilsCallbacks + 9 };
|
||||
uint32 dataid;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// callback for when the PS3 keyboard dialog closes
|
||||
//-----------------------------------------------------------------------------
|
||||
struct PS3KeyboardDialogFinished_t
|
||||
{
|
||||
enum { k_iCallback = k_iSteamUtilsCallbacks + 10 };
|
||||
};
|
||||
|
||||
// k_iSteamUtilsCallbacks + 11 is taken
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// callback for PSN status changing on PS3
|
||||
//-----------------------------------------------------------------------------
|
||||
struct PS3PSNStatusChange_t
|
||||
{
|
||||
enum { k_iCallback = k_iSteamUtilsCallbacks + 12 };
|
||||
bool m_bPSNOnline;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#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.
@@ -27,7 +27,9 @@ struct MatchMakingKeyValuePair_t
|
||||
MatchMakingKeyValuePair_t( const char *pchKey, const char *pchValue )
|
||||
{
|
||||
strncpy( m_szKey, pchKey, sizeof(m_szKey) ); // this is a public header, use basic c library string funcs only!
|
||||
m_szKey[ sizeof( m_szKey ) - 1 ] = '\0';
|
||||
strncpy( m_szValue, pchValue, sizeof(m_szValue) );
|
||||
m_szValue[ sizeof( m_szValue ) - 1 ] = '\0';
|
||||
}
|
||||
char m_szKey[ 256 ];
|
||||
char m_szValue[ 256 ];
|
||||
@@ -224,6 +226,7 @@ inline const char* gameserveritem_t::GetName() const
|
||||
inline void gameserveritem_t::SetName( const char *pName )
|
||||
{
|
||||
strncpy( m_szServerName, pName, sizeof( m_szServerName ) );
|
||||
m_szServerName[ sizeof( m_szServerName ) - 1 ] = '\0';
|
||||
}
|
||||
|
||||
|
||||
|
||||
+17
-37
@@ -20,6 +20,10 @@
|
||||
#include "isteamnetworking.h"
|
||||
#include "isteamremotestorage.h"
|
||||
|
||||
#if defined( _PS3 )
|
||||
#include "steamps3params.h"
|
||||
#endif
|
||||
|
||||
// Steam API export macro
|
||||
#if defined( _WIN32 ) && !defined( _X360 )
|
||||
#if defined( STEAM_API_EXPORTS )
|
||||
@@ -85,43 +89,6 @@ S_API void SteamAPI_SetBreakpadAppID( uint32 unAppID );
|
||||
// interface pointers, configured by SteamAPI_Init()
|
||||
S_API ISteamClient *SteamClient();
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------//
|
||||
// PlayStation 3 initialization parameters
|
||||
//
|
||||
// The following structure must be passed to when loading steam_api_ps3.prx
|
||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------//
|
||||
#define STEAM_PS3_PATH_MAX 1055
|
||||
#define STEAM_PS3_SERVICE_ID_MAX 32
|
||||
struct SteamPS3Params_t
|
||||
{
|
||||
void *pReserved;
|
||||
AppId_t m_nAppId;
|
||||
|
||||
char m_rgchInstallationPath[ STEAM_PS3_PATH_MAX ];
|
||||
char m_rgchSystemCache[ STEAM_PS3_PATH_MAX ]; // temp working cache, not persistent
|
||||
char m_rgchGameData[ STEAM_PS3_PATH_MAX ]; // persistent game data path for storing user data
|
||||
char m_rgchNpServiceID[ STEAM_PS3_SERVICE_ID_MAX ];
|
||||
|
||||
// Should be SYS_TTYP3 through SYS_TTYP10, if it's 0 then Steam won't spawn a
|
||||
// thread to read console input at all. Using this let's you use Steam console commands
|
||||
// like: profile_on, profile_off, profile_dump, mem_stats, mem_validate.
|
||||
unsigned int m_cSteamInputTTY;
|
||||
|
||||
struct Ps3netInit_t
|
||||
{
|
||||
bool m_bNeedInit;
|
||||
bool m_bNeedInitEx;
|
||||
void *m_pMemory;
|
||||
int m_nMemorySize;
|
||||
int m_flags;
|
||||
} m_sysNetInitInfo;
|
||||
|
||||
struct Ps3jpgInit_t
|
||||
{
|
||||
bool m_bNeedInit;
|
||||
} m_sysJpgInitInfo;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// VERSION_SAFE_STEAM_API_INTERFACES is usually not necessary, but it provides safety against releasing
|
||||
@@ -152,6 +119,9 @@ S_API ISteamApps *SteamApps();
|
||||
S_API ISteamNetworking *SteamNetworking();
|
||||
S_API ISteamMatchmakingServers *SteamMatchmakingServers();
|
||||
S_API ISteamRemoteStorage *SteamRemoteStorage();
|
||||
#ifdef _PS3
|
||||
S_API ISteamPS3OverlayRender * SteamPS3OverlayRender();
|
||||
#endif
|
||||
#endif // VERSION_SAFE_STEAM_API_INTERFACES
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------//
|
||||
@@ -425,6 +395,9 @@ public:
|
||||
ISteamMatchmakingServers* SteamMatchmakingServers() { return m_pSteamMatchmakingServers; }
|
||||
ISteamNetworking* SteamNetworking() { return m_pSteamNetworking; }
|
||||
ISteamRemoteStorage* SteamRemoteStorage() { return m_pSteamRemoteStorage; }
|
||||
#ifdef _PS3
|
||||
ISteamPS3OverlayRender* SteamPS3OverlayRender() { return m_pSteamPS3OverlayRender; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
ISteamUser *m_pSteamUser;
|
||||
@@ -436,6 +409,9 @@ private:
|
||||
ISteamMatchmakingServers *m_pSteamMatchmakingServers;
|
||||
ISteamNetworking *m_pSteamNetworking;
|
||||
ISteamRemoteStorage *m_pSteamRemoteStorage;
|
||||
#ifdef _PS3
|
||||
ISteamPS3OverlayRender *m_pSteamPS3OverlayRender;
|
||||
#endif
|
||||
};
|
||||
|
||||
inline CSteamAPIContext::CSteamAPIContext()
|
||||
@@ -501,6 +477,10 @@ inline bool CSteamAPIContext::Init()
|
||||
if ( !m_pSteamRemoteStorage )
|
||||
return false;
|
||||
|
||||
#ifdef _PS3
|
||||
m_pSteamPS3OverlayRender = SteamClient()->GetISteamPS3OverlayRender();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,14 @@ enum EResult
|
||||
k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid
|
||||
k_EResultPSNAccountAlreadyLinked = 59, // PSN account is already linked to some other account, must explicitly request to replace/delete the link first
|
||||
k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict between the local and remote files
|
||||
k_EResultIllegalPassword = 61, // The requested new password is not legal
|
||||
k_EResultSameAsPreviousValue = 62, // new value is the same as the old one ( secret question and answer )
|
||||
k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor authentication failure
|
||||
k_EResultCannotUseOldPassword = 64, // The requested new password is not legal
|
||||
k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid
|
||||
k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent
|
||||
k_EResultHardwareNotCapableOfIPT = 67, //
|
||||
k_EResultIPTInitError = 68, //
|
||||
};
|
||||
|
||||
// Error codes for use with the voice functions
|
||||
@@ -97,6 +105,7 @@ enum EVoiceResult
|
||||
k_EVoiceResultBufferTooSmall = 4,
|
||||
k_EVoiceResultDataCorrupted = 5,
|
||||
k_EVoiceResultRestricted = 6,
|
||||
k_EVoiceResultUnsupportedCodec = 7,
|
||||
|
||||
};
|
||||
|
||||
@@ -183,7 +192,7 @@ enum EAccountType
|
||||
k_EAccountTypeContentServer = 6, // content server
|
||||
k_EAccountTypeClan = 7,
|
||||
k_EAccountTypeChat = 8,
|
||||
// k_EAccountTypeP2PSuperSeeder = 9, // unused
|
||||
k_EAccountTypeConsoleUser = 9, // Fake SteamID for local PSN account on PS3 or Live account on 360, etc.
|
||||
k_EAccountTypeAnonUser = 10,
|
||||
|
||||
// Max of 16 items in this field
|
||||
@@ -258,8 +267,11 @@ enum EStatusDepotVersion
|
||||
typedef void (*PFNLegacyKeyRegistration)( const char *pchCDKey, const char *pchInstallPath );
|
||||
typedef bool (*PFNLegacyKeyInstalled)();
|
||||
|
||||
const int k_unSteamAccountIDMask = 0xFFFFFFFF;
|
||||
const int k_unSteamAccountInstanceMask = 0x000FFFFF;
|
||||
const unsigned int k_unSteamAccountIDMask = 0xFFFFFFFF;
|
||||
const unsigned int k_unSteamAccountInstanceMask = 0x000FFFFF;
|
||||
// we allow 2 simultaneous user account instances right now, 1= desktop, 2 = console, 0 = all
|
||||
const unsigned int k_unSteamUserDesktopInstance = 1;
|
||||
const unsigned int k_unSteamUserConsoleInstance = 2;
|
||||
|
||||
// Special flags for Chat accounts - they go in the top 8 bits
|
||||
// of the steam ID's "instance", leaving 12 for the actual instances
|
||||
@@ -345,7 +357,7 @@ public:
|
||||
CSteamID( uint32 unAccountID, unsigned int unAccountInstance, EUniverse eUniverse, EAccountType eAccountType )
|
||||
{
|
||||
#if defined(_SERVER) && defined(Assert)
|
||||
Assert( ! ( ( k_EAccountTypeIndividual == eAccountType ) && ( 1 != unAccountInstance ) ) ); // enforce that for individual accounts, instance is always 1
|
||||
Assert( ! ( ( k_EAccountTypeIndividual == eAccountType ) && ( unAccountInstance > k_unSteamUserConsoleInstance ) ) ); // enforce that for individual accounts, instance is always 1
|
||||
#endif // _SERVER
|
||||
InstancedSet( unAccountID, unAccountInstance, eUniverse, eAccountType );
|
||||
}
|
||||
@@ -381,7 +393,8 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
m_steamid.m_comp.m_unAccountInstance = 1;
|
||||
// by default we pick the desktop instance
|
||||
m_steamid.m_comp.m_unAccountInstance = k_unSteamUserDesktopInstance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,8 +420,8 @@ public:
|
||||
//-----------------------------------------------------------------------------
|
||||
void FullSet( uint64 ulIdentifier, EUniverse eUniverse, EAccountType eAccountType )
|
||||
{
|
||||
m_steamid.m_comp.m_unAccountID = ( ulIdentifier & 0xFFFFFFFF ); // account ID is low 32 bits
|
||||
m_steamid.m_comp.m_unAccountInstance = ( ( ulIdentifier >> 32 ) & 0xFFFFF ); // account instance is next 20 bits
|
||||
m_steamid.m_comp.m_unAccountID = ( ulIdentifier & k_unSteamAccountIDMask ); // account ID is low 32 bits
|
||||
m_steamid.m_comp.m_unAccountInstance = ( ( ulIdentifier >> 32 ) & k_unSteamAccountInstanceMask ); // account instance is next 20 bits
|
||||
m_steamid.m_comp.m_EUniverse = eUniverse;
|
||||
m_steamid.m_comp.m_EAccountType = eAccountType;
|
||||
}
|
||||
@@ -436,7 +449,7 @@ public:
|
||||
pTSteamGlobalUserID->m_SteamLocalUserID.Split.High32bits;
|
||||
m_steamid.m_comp.m_EUniverse = eUniverse; // set the universe
|
||||
m_steamid.m_comp.m_EAccountType = k_EAccountTypeIndividual; // Steam 2 accounts always map to account type of individual
|
||||
m_steamid.m_comp.m_unAccountInstance = 1; // individual accounts always have an account instance ID of 1
|
||||
m_steamid.m_comp.m_unAccountInstance = k_unSteamUserDesktopInstance; // Steam2 only knew desktop instances
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -558,7 +571,7 @@ public:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool BIndividualAccount() const
|
||||
{
|
||||
return m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual;
|
||||
return m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual || m_steamid.m_comp.m_EAccountType == k_EAccountTypeConsoleUser;
|
||||
}
|
||||
|
||||
|
||||
@@ -578,9 +591,19 @@ public:
|
||||
return m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonUser;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Is this a faked up Steam ID for a PSN friend account?
|
||||
//-----------------------------------------------------------------------------
|
||||
bool BConsoleUserAccount() const
|
||||
{
|
||||
return m_steamid.m_comp.m_EAccountType == k_EAccountTypeConsoleUser;
|
||||
}
|
||||
|
||||
// simple accessors
|
||||
void SetAccountID( uint32 unAccountID ) { m_steamid.m_comp.m_unAccountID = unAccountID; }
|
||||
void SetAccountInstance( uint32 unInstance ){ m_steamid.m_comp.m_unAccountInstance = unInstance; }
|
||||
void ClearIndividualInstance() { if ( BIndividualAccount() ) m_steamid.m_comp.m_unAccountInstance = 0; }
|
||||
bool HasNoIndividualInstance() const { return BIndividualAccount() && (m_steamid.m_comp.m_unAccountInstance==0); }
|
||||
uint32 GetAccountID() const { return m_steamid.m_comp.m_unAccountID; }
|
||||
uint32 GetUnAccountInstance() const { return m_steamid.m_comp.m_unAccountInstance; }
|
||||
EAccountType GetEAccountType() const { return ( EAccountType ) m_steamid.m_comp.m_EAccountType; }
|
||||
@@ -620,11 +643,11 @@ private:
|
||||
#ifdef VALVE_BIG_ENDIAN
|
||||
EUniverse m_EUniverse : 8; // universe this account belongs to
|
||||
unsigned int m_EAccountType : 4; // type of account - can't show as EAccountType, due to signed / unsigned difference
|
||||
unsigned int m_unAccountInstance : 20; // dynamic instance ID (used for multiseat type accounts only)
|
||||
unsigned int m_unAccountInstance : 20; // dynamic instance ID
|
||||
uint32 m_unAccountID : 32; // unique account identifier
|
||||
#else
|
||||
uint32 m_unAccountID : 32; // unique account identifier
|
||||
unsigned int m_unAccountInstance : 20; // dynamic instance ID (used for multiseat type accounts only)
|
||||
unsigned int m_unAccountInstance : 20; // dynamic instance ID
|
||||
unsigned int m_EAccountType : 4; // type of account - can't show as EAccountType, due to signed / unsigned difference
|
||||
EUniverse m_EUniverse : 8; // universe this account belongs to
|
||||
#endif
|
||||
@@ -644,7 +667,7 @@ inline bool CSteamID::IsValid() const
|
||||
|
||||
if ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual )
|
||||
{
|
||||
if ( m_steamid.m_comp.m_unAccountID == 0 || m_steamid.m_comp.m_unAccountInstance != 1 )
|
||||
if ( m_steamid.m_comp.m_unAccountID == 0 || m_steamid.m_comp.m_unAccountInstance > k_unSteamUserConsoleInstance )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
//====== Copyright © 1996-2010, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose: HTTP related enums, stuff that is shared by both clients and servers, and our
|
||||
// UI projects goes here.
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef STEAMHTTPENUMS_H
|
||||
#define STEAMHTTPENUMS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// HTTP related types
|
||||
|
||||
// This enum is used in client API methods, do not re-number existing values.
|
||||
enum EHTTPMethod
|
||||
{
|
||||
k_EHTTPMethodInvalid = 0,
|
||||
k_EHTTPMethodGET,
|
||||
k_EHTTPMethodHEAD,
|
||||
k_EHTTPMethodPOST,
|
||||
|
||||
// The remaining HTTP methods are not yet supported, per rfc2616 section 5.1.1 only GET and HEAD are required for
|
||||
// a compliant general purpose server. We'll likely add more as we find uses for them.
|
||||
|
||||
// k_EHTTPMethodOPTIONS,
|
||||
// k_EHTTPMethodPUT,
|
||||
// k_EHTTPMethodDELETE,
|
||||
// k_EHTTPMethodTRACE,
|
||||
// k_EHTTPMethodCONNECT
|
||||
};
|
||||
|
||||
|
||||
// HTTP Status codes that the server can send in response to a request, see rfc2616 section 10.3 for descriptions
|
||||
// of each of these.
|
||||
enum EHTTPStatusCode
|
||||
{
|
||||
// Invalid status code (this isn't defined in HTTP, used to indicate unset in our code)
|
||||
k_EHTTPStatusCodeInvalid = 0,
|
||||
|
||||
// Informational codes
|
||||
k_EHTTPStatusCode100Continue = 100,
|
||||
k_EHTTPStatusCode101SwitchingProtocols = 101,
|
||||
|
||||
// Success codes
|
||||
k_EHTTPStatusCode200OK = 200,
|
||||
k_EHTTPStatusCode201Created = 201,
|
||||
k_EHTTPStatusCode202Accepted = 202,
|
||||
k_EHTTPStatusCode203NonAuthoritative = 203,
|
||||
k_EHTTPStatusCode204NoContent = 204,
|
||||
k_EHTTPStatusCode205ResetContent = 205,
|
||||
k_EHTTPStatusCode206PartialContent = 206,
|
||||
|
||||
// Redirection codes
|
||||
k_EHTTPStatusCode300MultipleChoices = 300,
|
||||
k_EHTTPStatusCode301MovedPermanently = 301,
|
||||
k_EHTTPStatusCode302Found = 302,
|
||||
k_EHTTPStatusCode303SeeOther = 303,
|
||||
k_EHTTPStatusCode304NotModified = 304,
|
||||
k_EHTTPStatusCode305UseProxy = 305,
|
||||
//k_EHTTPStatusCode306Unused = 306, (used in old HTTP spec, now unused in 1.1)
|
||||
k_EHTTPStatusCode307TemporaryRedirect = 307,
|
||||
|
||||
// Error codes
|
||||
k_EHTTPStatusCode400BadRequest = 400,
|
||||
k_EHTTPStatusCode401Unauthorized = 401,
|
||||
k_EHTTPStatusCode402PaymentRequired = 402, // This is reserved for future HTTP specs, not really supported by clients
|
||||
k_EHTTPStatusCode403Forbidden = 403,
|
||||
k_EHTTPStatusCode404NotFound = 404,
|
||||
k_EHTTPStatusCode405MethodNotAllowed = 405,
|
||||
k_EHTTPStatusCode406NotAcceptable = 406,
|
||||
k_EHTTPStatusCode407ProxyAuthRequired = 407,
|
||||
k_EHTTPStatusCode408RequestTimeout = 408,
|
||||
k_EHTTPStatusCode409Conflict = 409,
|
||||
k_EHTTPStatusCode410Gone = 410,
|
||||
k_EHTTPStatusCode411LengthRequired = 411,
|
||||
k_EHTTPStatusCode412PreconditionFailed = 412,
|
||||
k_EHTTPStatusCode413RequestEntityTooLarge = 413,
|
||||
k_EHTTPStatusCode414RequestURITooLong = 414,
|
||||
k_EHTTPStatusCode415UnsupportedMediaType = 415,
|
||||
k_EHTTPStatusCode416RequestedRangeNotSatisfiable = 416,
|
||||
k_EHTTPStatusCode417ExpectationFailed = 417,
|
||||
|
||||
// Server error codes
|
||||
k_EHTTPStatusCode500InternalServerError = 500,
|
||||
k_EHTTPStatusCode501NotImplemented = 501,
|
||||
k_EHTTPStatusCode502BadGateway = 502,
|
||||
k_EHTTPStatusCode503ServiceUnavailable = 503,
|
||||
k_EHTTPStatusCode504GatewayTimeout = 504,
|
||||
k_EHTTPStatusCode505HTTPVersionNotSupported = 505,
|
||||
};
|
||||
|
||||
#endif // STEAMHTTPENUMS_H
|
||||
@@ -0,0 +1,90 @@
|
||||
//====== Copyright 1996-2008, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef STEAMPS3PARAMS_H
|
||||
#define STEAMPS3PARAMS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------//
|
||||
// PlayStation 3 initialization parameters
|
||||
//
|
||||
// The following structure must be passed to when loading steam_api_ps3.prx
|
||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------//
|
||||
#define STEAM_PS3_PATH_MAX 1055
|
||||
#define STEAM_PS3_SERVICE_ID_MAX 32
|
||||
#define STEAM_PS3_COMMUNICATION_ID_MAX 10
|
||||
#define STEAM_PS3_COMMUNICATION_SIG_MAX 160
|
||||
#define STEAM_PS3_GAMEBOOT_INVITE_SUBJECT_MAX 18
|
||||
#define STEAM_PS3_GAMEBOOT_INVITE_BODY_MAX 512
|
||||
struct SteamPS3Params_t
|
||||
{
|
||||
void *pReserved;
|
||||
uint32 m_nAppId;
|
||||
|
||||
char m_rgchInstallationPath[ STEAM_PS3_PATH_MAX ]; // directory containing latest steam prx's and sdata. Can be read only (BDVD)
|
||||
char m_rgchSystemCache[ STEAM_PS3_PATH_MAX ]; // temp working cache, not persistent
|
||||
char m_rgchGameData[ STEAM_PS3_PATH_MAX ]; // persistent game data path for storing user data
|
||||
char m_rgchNpServiceID[ STEAM_PS3_SERVICE_ID_MAX ];
|
||||
char m_rgchNpCommunicationID[ STEAM_PS3_COMMUNICATION_ID_MAX ];
|
||||
char m_rgchNpCommunicationSig[ STEAM_PS3_COMMUNICATION_SIG_MAX ];
|
||||
|
||||
char m_rgchGameBootInviteSubject[ STEAM_PS3_GAMEBOOT_INVITE_SUBJECT_MAX ];
|
||||
char m_rgchGameBootInviteBody[ STEAM_PS3_GAMEBOOT_INVITE_BODY_MAX ];
|
||||
|
||||
|
||||
// Should be SYS_TTYP3 through SYS_TTYP10, if it's 0 then Steam won't spawn a
|
||||
// thread to read console input at all. Using this let's you use Steam console commands
|
||||
// like: profile_on, profile_off, profile_dump, mem_stats, mem_validate.
|
||||
unsigned int m_cSteamInputTTY;
|
||||
|
||||
struct Ps3netInit_t
|
||||
{
|
||||
bool m_bNeedInit;
|
||||
void *m_pMemory;
|
||||
int m_nMemorySize;
|
||||
int m_flags;
|
||||
} m_sysNetInitInfo;
|
||||
|
||||
struct Ps3jpgInit_t
|
||||
{
|
||||
bool m_bNeedInit;
|
||||
} m_sysJpgInitInfo;
|
||||
|
||||
struct Ps3pngInit_t
|
||||
{
|
||||
bool m_bNeedInit;
|
||||
} m_sysPngInitInfo;
|
||||
|
||||
struct Ps3sysutilUserInfo_t
|
||||
{
|
||||
bool m_bNeedInit;
|
||||
} m_sysSysUtilUserInfo;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------//
|
||||
// PlayStation 3 memory structure
|
||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------//
|
||||
#define STEAMPS3_MALLOC_INUSE 0x53D04A51
|
||||
#define STEAMPS3_MALLOC_SYSTEM 0x0D102C48
|
||||
#define STEAMPS3_MALLOC_OK 0xFFD04A51
|
||||
struct SteamPS3Memory_t
|
||||
{
|
||||
bool m_bSingleAllocation; // If true, Steam will request one 6MB allocation and use the returned memory for all future allocations
|
||||
// If false, Steam will make call malloc for each allocation
|
||||
|
||||
// required function pointers
|
||||
void* (*m_pfMalloc)(size_t);
|
||||
void* (*m_pfRealloc)(void *, size_t);
|
||||
void (*m_pfFree)(void *);
|
||||
size_t (*m_pUsable_size)(void*);
|
||||
};
|
||||
|
||||
|
||||
#endif // STEAMPS3PARAMS_H
|
||||
@@ -1,27 +0,0 @@
|
||||
//====== Copyright 1996-2008, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef STEAM_PS3PARAMSINTERNAL_API_H
|
||||
#define STEAM_PS3PARAMSINTERNAL_API_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Params used only internally at Valve. This is the reserved pointer of SteamPS3Params_t
|
||||
//-----------------------------------------------------------------------------
|
||||
struct SteamPS3ParamsInternal_t
|
||||
{
|
||||
int m_nVersion;
|
||||
EUniverse m_eUniverse;
|
||||
const char *m_pchCMForce; // list of CMs in form "IP:port;IP:port" or "IP;IP"
|
||||
};
|
||||
|
||||
#define STEAM_PS3_PARAMS_INTERNAL_VERSION 1
|
||||
|
||||
|
||||
#endif // STEAM_PS3PARAMSINTERNAL_API_H
|
||||
@@ -122,7 +122,7 @@ const CellID_t k_uCellIDInvalid = 0xFFFFFFFF;
|
||||
typedef uint64 SteamAPICall_t;
|
||||
const SteamAPICall_t k_uAPICallInvalid = 0x0;
|
||||
|
||||
|
||||
typedef uint32 AccountID_t;
|
||||
|
||||
|
||||
#endif // STEAMTYPES_H
|
||||
|
||||
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.
@@ -8,11 +8,97 @@
|
||||
#ifndef GAMEENGINEOSX_H
|
||||
#define GAMEENGINEOSX_H
|
||||
|
||||
#ifdef __OBJC__
|
||||
#define OBJC_ENABLED 1
|
||||
#else
|
||||
#define OBJC_ENABLED 0
|
||||
#endif
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
#include "GameEngine.h"
|
||||
#include <OpenAL/al.h>
|
||||
#include <OpenAL/alc.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
|
||||
|
||||
// How big is the vertex buffer for batching lines in total?
|
||||
// NOTE: This must be a multiple of the batch size below!!! (crashes will occur if it isn't)
|
||||
#define LINE_BUFFER_TOTAL_SIZE 1000
|
||||
|
||||
// How many lines do we put in the buffer in between flushes?
|
||||
//
|
||||
// This should be enough smaller than the total size so that draw calls
|
||||
// can finish using the data before we wrap around and discard it.
|
||||
#define LINE_BUFFER_BATCH_SIZE 250
|
||||
|
||||
// How big is the vertex buffer for batching points in total?
|
||||
// NOTE: This must be a multiple of the batch size below!!! (crashes will occur if it isn't)
|
||||
#define POINT_BUFFER_TOTAL_SIZE 1800
|
||||
|
||||
// How many points do we put in the buffer in between flushes?
|
||||
//
|
||||
// This should be enough smaller than the total size so that draw calls
|
||||
// can finish using the data before we wrap around and discard it.
|
||||
#define POINT_BUFFER_BATCH_SIZE 600
|
||||
|
||||
// How big is the vertex buffer for batching quads in total?
|
||||
// NOTE: This must be a multiple of the batch size below!!! (crashes will occur if it isn't)
|
||||
#define QUAD_BUFFER_TOTAL_SIZE 1000
|
||||
|
||||
// How many quads do we put in the buffer in between flushes?
|
||||
//
|
||||
// This should be enough smaller than the total size so that draw calls
|
||||
// can finish using the data before we wrap around and discard it.
|
||||
#define QUAD_BUFFER_BATCH_SIZE 250
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DX9MODE
|
||||
#define DX9MODE 0 // change to 1 to turn on the DX9 mode
|
||||
#endif
|
||||
|
||||
#if DX9MODE
|
||||
#include "../glmgr/dxabstract.h"
|
||||
|
||||
class CShowPixelsParams
|
||||
{
|
||||
public:
|
||||
GLuint m_srcTexName;
|
||||
int m_width,m_height;
|
||||
};
|
||||
|
||||
// Vertex struct for line batches
|
||||
struct LineVertex_t
|
||||
{
|
||||
float x, y, z, rhw;
|
||||
DWORD color;
|
||||
};
|
||||
|
||||
|
||||
// Vertex struct for point batches
|
||||
struct PointVertex_t
|
||||
{
|
||||
float x, y, z, rhw;
|
||||
DWORD color;
|
||||
};
|
||||
|
||||
// Vertex struct for textured quads
|
||||
struct TexturedQuadVertex_t
|
||||
{
|
||||
float x, y, z, rhw;
|
||||
DWORD color;
|
||||
float u, v; // texture coordinates
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
class CVoiceContext;
|
||||
|
||||
class CGameEngineGL : public IGameEngine
|
||||
@@ -51,6 +137,7 @@ public:
|
||||
int32 GetViewportHeight() { return m_nWindowHeight; }
|
||||
|
||||
// Function for drawing text to the screen, dwFormat is a combination of flags like DT_LEFT, TEXTPOS_VCENTER etc...
|
||||
// on OSX client with DX9MODE=1, the HGAMEFONT is a texture with the glyphs in a 16x16 grid (see "g_glmDebugFontMap" in glmgrbasics.cpp)
|
||||
bool BDrawString( HGAMEFONT hFont, RECT rect, DWORD dwColor, DWORD dwFormat, const char *pchText );
|
||||
|
||||
// Create a new font returning our internal handle value for it (0 means failure)
|
||||
@@ -110,11 +197,14 @@ public:
|
||||
virtual void DestroyVoiceChannel( HGAMEVOICECHANNEL hChannel );
|
||||
virtual bool AddVoiceData( HGAMEVOICECHANNEL hChannel, const uint8 *pVoiceData, uint32 uLength );
|
||||
|
||||
private:
|
||||
void AdjustViewport();
|
||||
#if DX9MODE
|
||||
#else
|
||||
void AdjustViewport();
|
||||
|
||||
#endif
|
||||
|
||||
// Initialize the GL rendering interfaces and default state
|
||||
bool BInitializeGL();
|
||||
// Initialize graphics in either GL or DX9 form
|
||||
bool BInitializeGraphics();
|
||||
|
||||
// Initialize the debug font library
|
||||
bool BInitializeCellDbgFont();
|
||||
@@ -125,7 +215,6 @@ private:
|
||||
|
||||
void UpdateKey( uint32_t vkKey, int nDown );
|
||||
|
||||
private:
|
||||
// Tracks whether the engine is ready for use
|
||||
bool m_bEngineReadyForUse;
|
||||
|
||||
@@ -142,52 +231,199 @@ private:
|
||||
// Game time at the start of the previous frame
|
||||
uint64 m_ulPreviousGameTickCount;
|
||||
|
||||
// White texture used when drawing filled quads
|
||||
HGAMETEXTURE m_hTextureWhite;
|
||||
#if DX9MODE
|
||||
// Windows code transplants--------------------------------------------------------
|
||||
|
||||
NSOpenGLView *m_view;
|
||||
NSWindow *m_window;
|
||||
// Resets all the render, texture, and sampler states to our defaults
|
||||
void ResetRenderStates();
|
||||
|
||||
// Create a new vertex buffer returning our internal handle for it (0 means failure)
|
||||
HGAMEVERTBUF HCreateVertexBuffer( uint32 nSizeInBytes, DWORD dwUsage, DWORD dwFVF );
|
||||
|
||||
// Lock an entire vertex buffer with the specified flags
|
||||
bool BLockEntireVertexBuffer( HGAMEVERTBUF hVertBuf, void **ppVoid, DWORD dwFlags );
|
||||
|
||||
// Unlock a vertex buffer
|
||||
bool BUnlockVertexBuffer( HGAMEVERTBUF hVertBuf );
|
||||
|
||||
// Release a vertex buffer and free its resources
|
||||
bool BReleaseVertexBuffer( HGAMEVERTBUF hVertBuf );
|
||||
|
||||
// set vertex decl
|
||||
bool BSetVertexDeclaration( IDirect3DVertexDeclaration9 *decl );
|
||||
|
||||
// Set stream source
|
||||
bool BSetStreamSource( uint streamNumber, HGAMEVERTBUF hVertBuf, uint32 uOffset, uint32 uStride );
|
||||
|
||||
// Set shaders
|
||||
bool BSetShaders( IDirect3DVertexShader9 *vsh, IDirect3DPixelShader9 *psh );
|
||||
|
||||
// Render primitives out of the current stream source
|
||||
bool BRenderPrimitive( D3DPRIMITIVETYPE primType, uint32 uStartVertex, uint32 uCount );
|
||||
|
||||
bool BUberRenderPrimitive( IDirect3DVertexShader9 *vsh,
|
||||
IDirect3DPixelShader9 *psh,
|
||||
IDirect3DVertexDeclaration9 *decl,
|
||||
uint streamNumber,
|
||||
HGAMEVERTBUF hVertBuf,
|
||||
uint32 uOffset,
|
||||
uint32 uStride,
|
||||
D3DPRIMITIVETYPE primType,
|
||||
uint32 uStartVertex,
|
||||
uint32 uCount );
|
||||
|
||||
// fake hwnd is a WindowRef ( = [m_window windowRef] )
|
||||
void *m_hwnd;
|
||||
|
||||
// IDirect3D9 interface
|
||||
IDirect3D9 *m_pD3D9Interface;
|
||||
|
||||
// IDirect3DDevice9 interface
|
||||
IDirect3DDevice9 *m_pD3D9Device;
|
||||
|
||||
// Presentation parameters - device resets don't happen on OS X, but just for commonality with windows code
|
||||
D3DPRESENT_PARAMETERS m_d3dpp;
|
||||
|
||||
// vertex declarations - one per vertex layout used
|
||||
IDirect3DVertexDeclaration9 *m_decl_P4C1; // aka D3DFVF_XYZRHW | D3DFVF_DIFFUSE
|
||||
// (4 floats pos, one ubyte4 color) - 20 bytes / vert
|
||||
|
||||
IDirect3DVertexDeclaration9 *m_decl_P4C1T2; // aka D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1
|
||||
// (4 floats pos, one ubyte4 color, 2 floats texc) - 28 bytes / vert
|
||||
|
||||
// vertex and pixel shaders - one per vertex layout
|
||||
IDirect3DVertexShader9 *m_vsh_P4C1;
|
||||
IDirect3DVertexShader9 *m_vsh_P4C1T2;
|
||||
IDirect3DPixelShader9 *m_psh_P4C1;
|
||||
IDirect3DPixelShader9 *m_psh_P4C1T2;
|
||||
|
||||
|
||||
// Color we clear the background of the window to each frame
|
||||
DWORD m_dwBackgroundColor;
|
||||
|
||||
// Next vertex buffer handle value to give out
|
||||
HGAMEVERTBUF m_nNextVertBufferHandle;
|
||||
|
||||
// Map of handles to vertex buffer objects
|
||||
struct VertBufData_t
|
||||
{
|
||||
bool m_bIsLocked;
|
||||
IDirect3DVertexBuffer9 * m_pBuffer;
|
||||
};
|
||||
std::map<HGAMEVERTBUF, VertBufData_t> m_MapVertexBuffers;
|
||||
|
||||
HGAMETEXTURE m_nNextTextureHandle;
|
||||
|
||||
// Map of handles to texture objects
|
||||
struct TextureData_t
|
||||
{
|
||||
byte *m_pRGBAData; // We keep a copy of the raw data so we can rebuild textures after a device is lost
|
||||
uint32 m_uWidth;
|
||||
uint32 m_uHeight;
|
||||
LPDIRECT3DTEXTURE9 m_pTexture;
|
||||
};
|
||||
std::map<HGAMETEXTURE, TextureData_t> m_MapTextures;
|
||||
|
||||
// Internal vertex buffer for batching line drawing
|
||||
HGAMEVERTBUF m_hLineBuffer;
|
||||
|
||||
// Pointer to actual line buffer memory (valid only while locked)
|
||||
LineVertex_t *m_pLineVertexes;
|
||||
|
||||
// Track how many lines are awaiting flushing in our line buffer
|
||||
DWORD m_dwLinesToFlush;
|
||||
|
||||
// Track where the current batch starts in the vert buffer
|
||||
DWORD m_dwLineBufferBatchPos;
|
||||
|
||||
// Internal vertex buffer for batching point drawing
|
||||
HGAMEVERTBUF m_hPointBuffer;
|
||||
|
||||
// Pointer to actual point buffer memory (valid only while locked)
|
||||
PointVertex_t *m_pPointVertexes;
|
||||
|
||||
// Track how many points are awaiting flushing in our line buffer
|
||||
DWORD m_dwPointsToFlush;
|
||||
|
||||
// Track where the current batch starts in the vert buffer
|
||||
DWORD m_dwPointBufferBatchPos;
|
||||
|
||||
// Vertex buffer for textured quads
|
||||
HGAMEVERTBUF m_hQuadBuffer;
|
||||
|
||||
// Last texture used in drawing a batched quad
|
||||
HGAMETEXTURE m_hLastTexture;
|
||||
|
||||
// Pointer to quad vertex data
|
||||
TexturedQuadVertex_t *m_pQuadVertexes;
|
||||
|
||||
// How many quads are awaiting flushing
|
||||
DWORD m_dwQuadsToFlush;
|
||||
|
||||
// Where does the current batch begin
|
||||
DWORD m_dwQuadBufferBatchPos;
|
||||
|
||||
// White texture used when drawing filled quads
|
||||
HGAMETEXTURE m_hTextureWhite;
|
||||
|
||||
// font stuff
|
||||
HGAMEFONT m_nNextFontHandle;
|
||||
std::map< HGAMEFONT, HGAMETEXTURE > m_MapGameFonts;
|
||||
|
||||
//CocoaMgr transplants-------------------------------------------------------------
|
||||
GLMDisplayDB *GetDisplayDB ( void );
|
||||
void GetRendererInfo ( GLMRendererInfoFields *rendInfoOut );
|
||||
PseudoNSGLContextPtr GetNSGLContextForWindow( void* windowref );
|
||||
void RenderedSize ( uint &width, uint &height, bool set ); // either set or retrieve rendered size value (from dxabstract)
|
||||
void DisplayedSize ( uint &width, uint &height ); // query backbuffer size (window size whether FS or windowed)
|
||||
void ShowPixels ( CShowPixelsParams *params ); // present
|
||||
|
||||
|
||||
GLMDisplayDB *m_displayDB;
|
||||
#else
|
||||
// White texture used when drawing filled quads
|
||||
HGAMETEXTURE m_hTextureWhite;
|
||||
|
||||
// Pointer to actual data for points
|
||||
GLfloat *m_rgflPointsData;
|
||||
GLubyte *m_rgflPointsColorData;
|
||||
|
||||
// How many points are outstanding needing flush
|
||||
DWORD m_dwPointsToFlush;
|
||||
|
||||
// Pointer to actual data for lines
|
||||
GLfloat *m_rgflLinesData;
|
||||
GLubyte *m_rgflLinesColorData;
|
||||
|
||||
|
||||
// How many lines are outstanding needing flush
|
||||
DWORD m_dwLinesToFlush;
|
||||
|
||||
// Pointer to actual data for quads
|
||||
GLfloat *m_rgflQuadsData;
|
||||
GLubyte *m_rgflQuadsColorData;
|
||||
GLfloat *m_rgflQuadsTextureData;
|
||||
|
||||
// How many lines are outstanding needing flush
|
||||
DWORD m_dwQuadsToFlush;
|
||||
|
||||
// Map of font handles we have given out
|
||||
HGAMEFONT m_nNextFontHandle;
|
||||
std::map< HGAMEFONT, void* > m_MapGameFonts;
|
||||
std::map< std::string, GLString * > m_MapStrings;
|
||||
|
||||
// Map of handles to texture objects
|
||||
struct TextureData_t
|
||||
{
|
||||
uint32 m_uWidth;
|
||||
uint32 m_uHeight;
|
||||
GLuint m_uTextureID;
|
||||
};
|
||||
std::map<HGAMETEXTURE, TextureData_t> m_MapTextures;
|
||||
HGAMETEXTURE m_nNextTextureHandle;
|
||||
|
||||
// Last bound texture, used to know when we must flush
|
||||
HGAMETEXTURE m_hLastTexture;
|
||||
// Pointer to actual data for points
|
||||
GLfloat *m_rgflPointsData;
|
||||
GLubyte *m_rgflPointsColorData;
|
||||
|
||||
// How many points are outstanding needing flush
|
||||
DWORD m_dwPointsToFlush;
|
||||
|
||||
// Pointer to actual data for lines
|
||||
GLfloat *m_rgflLinesData;
|
||||
GLubyte *m_rgflLinesColorData;
|
||||
|
||||
|
||||
// How many lines are outstanding needing flush
|
||||
DWORD m_dwLinesToFlush;
|
||||
|
||||
// Pointer to actual data for quads
|
||||
GLfloat *m_rgflQuadsData;
|
||||
GLubyte *m_rgflQuadsColorData;
|
||||
GLfloat *m_rgflQuadsTextureData;
|
||||
|
||||
// How many lines are outstanding needing flush
|
||||
DWORD m_dwQuadsToFlush;
|
||||
|
||||
// Map of font handles we have given out
|
||||
HGAMEFONT m_nNextFontHandle;
|
||||
std::map< HGAMEFONT, void* > m_MapGameFonts;
|
||||
|
||||
// Map of handles to texture objects
|
||||
struct TextureData_t
|
||||
{
|
||||
uint32 m_uWidth;
|
||||
uint32 m_uHeight;
|
||||
GLuint m_uTextureID;
|
||||
};
|
||||
std::map<HGAMETEXTURE, TextureData_t> m_MapTextures;
|
||||
HGAMETEXTURE m_nNextTextureHandle;
|
||||
|
||||
// Last bound texture, used to know when we must flush
|
||||
HGAMETEXTURE m_hLastTexture;
|
||||
#endif
|
||||
|
||||
// Map of button state, translated to VK for win32.
|
||||
std::set< DWORD > m_SetKeysDown;
|
||||
@@ -199,6 +435,19 @@ private:
|
||||
std::map<HGAMEVOICECHANNEL, CVoiceContext* > m_MapVoiceChannel;
|
||||
uint32 m_unVoiceChannelCount;
|
||||
|
||||
#if OBJC_ENABLED
|
||||
// any objective-c members go at the end of the class in a block
|
||||
// they are invisible to callers in pure C++ files
|
||||
// that also means callers in pure C++ files must not try to instantiate or destroy this type of object
|
||||
|
||||
#if DX9MODE
|
||||
#else
|
||||
std::map< std::string, GLString * > m_MapStrings;
|
||||
#endif
|
||||
|
||||
NSOpenGLView *m_view;
|
||||
NSWindow *m_window;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // GAMEENGINEOSX_H
|
||||
+1518
-319
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,6 @@
|
||||
|
||||
#ifdef __OBJC__ // this declaration only appears for files compiling with objc enabled
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <OpenGL/gl.h>
|
||||
#import <OpenGL/glext.h>
|
||||
@@ -40,3 +43,4 @@
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -36,6 +36,19 @@
|
||||
503C6DB41269002800B66E3B /* libsteam_api.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 503C6DB31269002800B66E3B /* libsteam_api.dylib */; };
|
||||
504EDCBC126901EC00F96D63 /* libsteam_api.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 503C6DB31269002800B66E3B /* libsteam_api.dylib */; };
|
||||
504EDCC21269026C00F96D63 /* steam_appid.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 504EDCC01269025A00F96D63 /* steam_appid.txt */; };
|
||||
50E77DEB1362190C000FC072 /* cglmbuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DD11362190C000FC072 /* cglmbuffer.cpp */; };
|
||||
50E77DEC1362190C000FC072 /* cglmfbo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DD31362190C000FC072 /* cglmfbo.cpp */; };
|
||||
50E77DED1362190C000FC072 /* cglmprogram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DD51362190C000FC072 /* cglmprogram.cpp */; };
|
||||
50E77DEE1362190C000FC072 /* cglmquery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DD71362190C000FC072 /* cglmquery.cpp */; };
|
||||
50E77DEF1362190C000FC072 /* cglmtex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DD91362190C000FC072 /* cglmtex.cpp */; };
|
||||
50E77DF01362190C000FC072 /* dx9asmtogl2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DDB1362190C000FC072 /* dx9asmtogl2.cpp */; };
|
||||
50E77DF11362190C000FC072 /* dxabstract.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DDD1362190C000FC072 /* dxabstract.cpp */; };
|
||||
50E77DF21362190C000FC072 /* glmgr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DE11362190C000FC072 /* glmgr.cpp */; };
|
||||
50E77DF31362190C000FC072 /* glmgrbasics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DE31362190C000FC072 /* glmgrbasics.cpp */; };
|
||||
50E77DF41362190C000FC072 /* glmgrcocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DE51362190C000FC072 /* glmgrcocoa.mm */; };
|
||||
50E77DF51362190C000FC072 /* glmgrext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DE61362190C000FC072 /* glmgrext.cpp */; };
|
||||
50E77DF61362190C000FC072 /* mathlite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E77DE91362190C000FC072 /* mathlite.cpp */; };
|
||||
50E77DF813621991000FC072 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50E77DF713621991000FC072 /* IOKit.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
@@ -107,9 +120,36 @@
|
||||
503C6D0E1268F49F00B66E3B /* voicechat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = voicechat.h; sourceTree = "<group>"; };
|
||||
503C6DAA1268FE1000B66E3B /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
|
||||
503C6DAB1268FE1000B66E3B /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
|
||||
503C6DB31269002800B66E3B /* libsteam_api.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsteam_api.dylib; path = /Users/joer/Source/Steam3/main/src/lib/osx32/release/libsteam_api.dylib; sourceTree = "<absolute>"; };
|
||||
503C6DB31269002800B66E3B /* libsteam_api.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsteam_api.dylib; path = ../redistributable_bin/osx32/libsteam_api.dylib; sourceTree = "<absolute>"; };
|
||||
504EDCB4126900D600F96D63 /* steamworksexample-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "steamworksexample-Info.plist"; path = "osx/steamworksexample-Info.plist"; sourceTree = "<group>"; };
|
||||
504EDCC01269025A00F96D63 /* steam_appid.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = steam_appid.txt; path = osx/steam_appid.txt; sourceTree = "<group>"; };
|
||||
50E77DD11362190C000FC072 /* cglmbuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cglmbuffer.cpp; path = ../glmgr/cglmbuffer.cpp; sourceTree = "<group>"; };
|
||||
50E77DD21362190C000FC072 /* cglmbuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cglmbuffer.h; path = ../glmgr/cglmbuffer.h; sourceTree = "<group>"; };
|
||||
50E77DD31362190C000FC072 /* cglmfbo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cglmfbo.cpp; path = ../glmgr/cglmfbo.cpp; sourceTree = "<group>"; };
|
||||
50E77DD41362190C000FC072 /* cglmfbo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cglmfbo.h; path = ../glmgr/cglmfbo.h; sourceTree = "<group>"; };
|
||||
50E77DD51362190C000FC072 /* cglmprogram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cglmprogram.cpp; path = ../glmgr/cglmprogram.cpp; sourceTree = "<group>"; };
|
||||
50E77DD61362190C000FC072 /* cglmprogram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cglmprogram.h; path = ../glmgr/cglmprogram.h; sourceTree = "<group>"; };
|
||||
50E77DD71362190C000FC072 /* cglmquery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cglmquery.cpp; path = ../glmgr/cglmquery.cpp; sourceTree = "<group>"; };
|
||||
50E77DD81362190C000FC072 /* cglmquery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cglmquery.h; path = ../glmgr/cglmquery.h; sourceTree = "<group>"; };
|
||||
50E77DD91362190C000FC072 /* cglmtex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cglmtex.cpp; path = ../glmgr/cglmtex.cpp; sourceTree = "<group>"; };
|
||||
50E77DDA1362190C000FC072 /* cglmtex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cglmtex.h; path = ../glmgr/cglmtex.h; sourceTree = "<group>"; };
|
||||
50E77DDB1362190C000FC072 /* dx9asmtogl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dx9asmtogl2.cpp; path = ../glmgr/dx9asmtogl2.cpp; sourceTree = "<group>"; };
|
||||
50E77DDC1362190C000FC072 /* dx9asmtogl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dx9asmtogl2.h; path = ../glmgr/dx9asmtogl2.h; sourceTree = "<group>"; };
|
||||
50E77DDD1362190C000FC072 /* dxabstract.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dxabstract.cpp; path = ../glmgr/dxabstract.cpp; sourceTree = "<group>"; };
|
||||
50E77DDE1362190C000FC072 /* dxabstract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dxabstract.h; path = ../glmgr/dxabstract.h; sourceTree = "<group>"; };
|
||||
50E77DDF1362190C000FC072 /* glmdebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glmdebug.h; path = ../glmgr/glmdebug.h; sourceTree = "<group>"; };
|
||||
50E77DE01362190C000FC072 /* glmdisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glmdisplay.h; path = ../glmgr/glmdisplay.h; sourceTree = "<group>"; };
|
||||
50E77DE11362190C000FC072 /* glmgr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glmgr.cpp; path = ../glmgr/glmgr.cpp; sourceTree = "<group>"; };
|
||||
50E77DE21362190C000FC072 /* glmgr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glmgr.h; path = ../glmgr/glmgr.h; sourceTree = "<group>"; };
|
||||
50E77DE31362190C000FC072 /* glmgrbasics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glmgrbasics.cpp; path = ../glmgr/glmgrbasics.cpp; sourceTree = "<group>"; };
|
||||
50E77DE41362190C000FC072 /* glmgrbasics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glmgrbasics.h; path = ../glmgr/glmgrbasics.h; sourceTree = "<group>"; };
|
||||
50E77DE51362190C000FC072 /* glmgrcocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = glmgrcocoa.mm; path = ../glmgr/glmgrcocoa.mm; sourceTree = "<group>"; };
|
||||
50E77DE61362190C000FC072 /* glmgrext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glmgrext.cpp; path = ../glmgr/glmgrext.cpp; sourceTree = "<group>"; };
|
||||
50E77DE71362190C000FC072 /* glmgrext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glmgrext.h; path = ../glmgr/glmgrext.h; sourceTree = "<group>"; };
|
||||
50E77DE81362190C000FC072 /* imageformat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imageformat.h; path = ../glmgr/imageformat.h; sourceTree = "<group>"; };
|
||||
50E77DE91362190C000FC072 /* mathlite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mathlite.cpp; path = ../glmgr/mathlite.cpp; sourceTree = "<group>"; };
|
||||
50E77DEA1362190C000FC072 /* mathlite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mathlite.h; path = ../glmgr/mathlite.h; sourceTree = "<group>"; };
|
||||
50E77DF713621991000FC072 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -117,6 +157,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
50E77DF813621991000FC072 /* IOKit.framework in Frameworks */,
|
||||
503C6DB41269002800B66E3B /* libsteam_api.dylib in Frameworks */,
|
||||
503C6DAC1268FE1000B66E3B /* OpenAL.framework in Frameworks */,
|
||||
503C6DAD1268FE1000B66E3B /* OpenGL.framework in Frameworks */,
|
||||
@@ -130,8 +171,6 @@
|
||||
503C6CA31268F34200B66E3B = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
503C6DAA1268FE1000B66E3B /* OpenAL.framework */,
|
||||
503C6DAB1268FE1000B66E3B /* OpenGL.framework */,
|
||||
503C6D291268F4EE00B66E3B /* Headers */,
|
||||
503C6CAB1268F34200B66E3B /* Source */,
|
||||
503C6CAC1268F34200B66E3B /* Resources */,
|
||||
@@ -143,6 +182,7 @@
|
||||
503C6CAB1268F34200B66E3B /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
50E77DCF136218F5000FC072 /* glmgr */,
|
||||
503C6CED1268F49F00B66E3B /* p2pauth.cpp */,
|
||||
503C6CEF1268F49F00B66E3B /* PhotonBeam.cpp */,
|
||||
503C6CF11268F49F00B66E3B /* QuitMenu.cpp */,
|
||||
@@ -182,6 +222,9 @@
|
||||
503C6CAD1268F34200B66E3B /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
50E77DF713621991000FC072 /* IOKit.framework */,
|
||||
503C6DAA1268FE1000B66E3B /* OpenAL.framework */,
|
||||
503C6DAB1268FE1000B66E3B /* OpenGL.framework */,
|
||||
503C6DB31269002800B66E3B /* libsteam_api.dylib */,
|
||||
503C6CB51268F34200B66E3B /* Cocoa.framework */,
|
||||
);
|
||||
@@ -230,6 +273,39 @@
|
||||
name = Headers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
50E77DCF136218F5000FC072 /* glmgr */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
50E77DD11362190C000FC072 /* cglmbuffer.cpp */,
|
||||
50E77DD21362190C000FC072 /* cglmbuffer.h */,
|
||||
50E77DD31362190C000FC072 /* cglmfbo.cpp */,
|
||||
50E77DD41362190C000FC072 /* cglmfbo.h */,
|
||||
50E77DD51362190C000FC072 /* cglmprogram.cpp */,
|
||||
50E77DD61362190C000FC072 /* cglmprogram.h */,
|
||||
50E77DD71362190C000FC072 /* cglmquery.cpp */,
|
||||
50E77DD81362190C000FC072 /* cglmquery.h */,
|
||||
50E77DD91362190C000FC072 /* cglmtex.cpp */,
|
||||
50E77DDA1362190C000FC072 /* cglmtex.h */,
|
||||
50E77DDB1362190C000FC072 /* dx9asmtogl2.cpp */,
|
||||
50E77DDC1362190C000FC072 /* dx9asmtogl2.h */,
|
||||
50E77DDD1362190C000FC072 /* dxabstract.cpp */,
|
||||
50E77DDE1362190C000FC072 /* dxabstract.h */,
|
||||
50E77DDF1362190C000FC072 /* glmdebug.h */,
|
||||
50E77DE01362190C000FC072 /* glmdisplay.h */,
|
||||
50E77DE11362190C000FC072 /* glmgr.cpp */,
|
||||
50E77DE21362190C000FC072 /* glmgr.h */,
|
||||
50E77DE31362190C000FC072 /* glmgrbasics.cpp */,
|
||||
50E77DE41362190C000FC072 /* glmgrbasics.h */,
|
||||
50E77DE51362190C000FC072 /* glmgrcocoa.mm */,
|
||||
50E77DE61362190C000FC072 /* glmgrext.cpp */,
|
||||
50E77DE71362190C000FC072 /* glmgrext.h */,
|
||||
50E77DE81362190C000FC072 /* imageformat.h */,
|
||||
50E77DE91362190C000FC072 /* mathlite.cpp */,
|
||||
50E77DEA1362190C000FC072 /* mathlite.h */,
|
||||
);
|
||||
name = glmgr;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@@ -311,6 +387,18 @@
|
||||
503C6D261268F49F00B66E3B /* Sun.cpp in Sources */,
|
||||
503C6D271268F49F00B66E3B /* VectorEntity.cpp in Sources */,
|
||||
503C6D281268F49F00B66E3B /* voicechat.cpp in Sources */,
|
||||
50E77DEB1362190C000FC072 /* cglmbuffer.cpp in Sources */,
|
||||
50E77DEC1362190C000FC072 /* cglmfbo.cpp in Sources */,
|
||||
50E77DED1362190C000FC072 /* cglmprogram.cpp in Sources */,
|
||||
50E77DEE1362190C000FC072 /* cglmquery.cpp in Sources */,
|
||||
50E77DEF1362190C000FC072 /* cglmtex.cpp in Sources */,
|
||||
50E77DF01362190C000FC072 /* dx9asmtogl2.cpp in Sources */,
|
||||
50E77DF11362190C000FC072 /* dxabstract.cpp in Sources */,
|
||||
50E77DF21362190C000FC072 /* glmgr.cpp in Sources */,
|
||||
50E77DF31362190C000FC072 /* glmgrbasics.cpp in Sources */,
|
||||
50E77DF41362190C000FC072 /* glmgrcocoa.mm in Sources */,
|
||||
50E77DF51362190C000FC072 /* glmgrext.cpp in Sources */,
|
||||
50E77DF61362190C000FC072 /* mathlite.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -320,7 +408,7 @@
|
||||
503C6CC71268F34200B66E3B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
|
||||
@@ -342,7 +430,7 @@
|
||||
503C6CC81268F34200B66E3B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = (
|
||||
POSIX,
|
||||
|
||||
@@ -66,10 +66,10 @@ void CVoiceChat::RunFrame()
|
||||
if ( m_bIsActive )
|
||||
{
|
||||
// read local microphone input
|
||||
uint32 nBytesAvalaible = 0;
|
||||
EVoiceResult res = SteamUser()->GetAvailableVoice( &nBytesAvalaible, NULL );
|
||||
uint32 nBytesAvailable = 0;
|
||||
EVoiceResult res = SteamUser()->GetAvailableVoice( &nBytesAvailable, NULL, 0 );
|
||||
|
||||
if ( res == k_EVoiceResultOK && nBytesAvalaible > 0 )
|
||||
if ( res == k_EVoiceResultOK && nBytesAvailable > 0 )
|
||||
{
|
||||
uint32 nBytesWritten = 0;
|
||||
MsgVoiceChatData_t msg;
|
||||
@@ -77,7 +77,7 @@ void CVoiceChat::RunFrame()
|
||||
// don't send more then 1 KB at a time
|
||||
uint8 buffer[ 1024+sizeof(msg) ];
|
||||
|
||||
res = SteamUser()->GetVoice( true, buffer+sizeof(msg), 1024, &nBytesWritten, false, NULL, 0, NULL );
|
||||
res = SteamUser()->GetVoice( true, buffer+sizeof(msg), 1024, &nBytesWritten, false, NULL, 0, NULL, 0 );
|
||||
|
||||
if ( res == k_EVoiceResultOK && nBytesWritten > 0 )
|
||||
{
|
||||
@@ -98,7 +98,7 @@ void CVoiceChat::RunFrame()
|
||||
pVoiceData += sizeof(MsgVoiceChatData_t);
|
||||
|
||||
EVoiceResult res = SteamUser()->DecompressVoice( pVoiceData , nBytesWritten,
|
||||
m_ubUncompressedVoice, sizeof( m_ubUncompressedVoice ), &numUncompressedBytes );
|
||||
m_ubUncompressedVoice, sizeof( m_ubUncompressedVoice ), &numUncompressedBytes, VOICE_OUTPUT_SAMPLE_RATE );
|
||||
|
||||
if ( res == k_EVoiceResultOK && numUncompressedBytes > 0 )
|
||||
{
|
||||
@@ -140,7 +140,7 @@ bool CVoiceChat::HandleMessage( CSteamID fromSteamID, EMessage eMsg, const void
|
||||
pVoiceData += sizeof(MsgVoiceChatData_t);
|
||||
|
||||
EVoiceResult res = SteamUser()->DecompressVoice( pVoiceData , pMsgVoiceData->GetDataLength(),
|
||||
pbUncompressedVoice, sizeof( pbUncompressedVoice ), &numUncompressedBytes );
|
||||
pbUncompressedVoice, sizeof( pbUncompressedVoice ), &numUncompressedBytes, VOICE_OUTPUT_SAMPLE_RATE );
|
||||
|
||||
if ( res == k_EVoiceResultOK && numUncompressedBytes > 0 )
|
||||
{
|
||||
|
||||
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