mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-01-03 16:13:34 +08:00
[saco] Implement DXUT_Dynamic_*
functions
This commit is contained in:
parent
95be49b49c
commit
07b017d217
@ -321,3 +321,115 @@ bool DXUTFindMediaSearchParentDirs( TCHAR* strSearchPath, int cchSearch, TCHAR*
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Direct3D9 dynamic linking support -- calls top-level D3D9 APIs with graceful
|
||||
// failure if APIs are not present.
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Function prototypes
|
||||
typedef IDirect3D9* (WINAPI * LPDIRECT3DCREATE9) (UINT);
|
||||
typedef INT (WINAPI * LPD3DPERF_BEGINEVENT)(D3DCOLOR, LPCTSTR);
|
||||
typedef INT (WINAPI * LPD3DPERF_ENDEVENT)(void);
|
||||
typedef VOID (WINAPI * LPD3DPERF_SETMARKER)(D3DCOLOR, LPCTSTR);
|
||||
typedef VOID (WINAPI * LPD3DPERF_SETREGION)(D3DCOLOR, LPCTSTR);
|
||||
typedef BOOL (WINAPI * LPD3DPERF_QUERYREPEATFRAME)(void);
|
||||
typedef VOID (WINAPI * LPD3DPERF_SETOPTIONS)( DWORD dwOptions );
|
||||
typedef DWORD (WINAPI * LPD3DPERF_GETSTATUS)( void );
|
||||
|
||||
// Module and function pointers
|
||||
static HMODULE s_hModD3D9 = NULL;
|
||||
static LPDIRECT3DCREATE9 s_DynamicDirect3DCreate9 = NULL;
|
||||
static LPD3DPERF_BEGINEVENT s_DynamicD3DPERF_BeginEvent = NULL;
|
||||
static LPD3DPERF_ENDEVENT s_DynamicD3DPERF_EndEvent = NULL;
|
||||
static LPD3DPERF_SETMARKER s_DynamicD3DPERF_SetMarker = NULL;
|
||||
static LPD3DPERF_SETREGION s_DynamicD3DPERF_SetRegion = NULL;
|
||||
static LPD3DPERF_QUERYREPEATFRAME s_DynamicD3DPERF_QueryRepeatFrame = NULL;
|
||||
static LPD3DPERF_SETOPTIONS s_DynamicD3DPERF_SetOptions = NULL;
|
||||
static LPD3DPERF_GETSTATUS s_DynamicD3DPERF_GetStatus = NULL;
|
||||
|
||||
// Ensure function pointers are initialized
|
||||
static bool DXUT_EnsureD3DAPIs( void )
|
||||
{
|
||||
// If module is non-NULL, this function has already been called. Note
|
||||
// that this doesn't guarantee that all D3D9 procaddresses were found.
|
||||
if( s_hModD3D9 != NULL )
|
||||
return true;
|
||||
|
||||
// This may fail if DirectX 9 isn't installed
|
||||
TCHAR wszPath[MAX_PATH+1];
|
||||
if( !::GetSystemDirectory( wszPath, MAX_PATH+1 ) )
|
||||
return false;
|
||||
StringCchCat( wszPath, MAX_PATH, "\\d3d9.dll" );
|
||||
s_hModD3D9 = LoadLibrary( wszPath );
|
||||
if( s_hModD3D9 == NULL )
|
||||
return false;
|
||||
s_DynamicDirect3DCreate9 = (LPDIRECT3DCREATE9)GetProcAddress( s_hModD3D9, "Direct3DCreate9" );
|
||||
s_DynamicD3DPERF_BeginEvent = (LPD3DPERF_BEGINEVENT)GetProcAddress( s_hModD3D9, "D3DPERF_BeginEvent" );
|
||||
s_DynamicD3DPERF_EndEvent = (LPD3DPERF_ENDEVENT)GetProcAddress( s_hModD3D9, "D3DPERF_EndEvent" );
|
||||
s_DynamicD3DPERF_SetMarker = (LPD3DPERF_SETMARKER)GetProcAddress( s_hModD3D9, "D3DPERF_SetMarker" );
|
||||
s_DynamicD3DPERF_SetRegion = (LPD3DPERF_SETREGION)GetProcAddress( s_hModD3D9, "D3DPERF_SetRegion" );
|
||||
s_DynamicD3DPERF_QueryRepeatFrame = (LPD3DPERF_QUERYREPEATFRAME)GetProcAddress( s_hModD3D9, "D3DPERF_QueryRepeatFrame" );
|
||||
s_DynamicD3DPERF_SetOptions = (LPD3DPERF_SETOPTIONS)GetProcAddress( s_hModD3D9, "D3DPERF_SetOptions" );
|
||||
s_DynamicD3DPERF_GetStatus = (LPD3DPERF_GETSTATUS)GetProcAddress( s_hModD3D9, "D3DPERF_GetStatus" );
|
||||
return true;
|
||||
}
|
||||
|
||||
IDirect3D9 * WINAPI DXUT_Dynamic_Direct3DCreate9(UINT SDKVersion)
|
||||
{
|
||||
if( DXUT_EnsureD3DAPIs() && s_DynamicDirect3DCreate9 != NULL )
|
||||
return s_DynamicDirect3DCreate9( SDKVersion );
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int WINAPI DXUT_Dynamic_D3DPERF_BeginEvent( D3DCOLOR col, LPCTSTR wszName )
|
||||
{
|
||||
if( DXUT_EnsureD3DAPIs() && s_DynamicD3DPERF_BeginEvent != NULL )
|
||||
return s_DynamicD3DPERF_BeginEvent( col, wszName );
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
int WINAPI DXUT_Dynamic_D3DPERF_EndEvent( void )
|
||||
{
|
||||
if( DXUT_EnsureD3DAPIs() && s_DynamicD3DPERF_EndEvent != NULL )
|
||||
return s_DynamicD3DPERF_EndEvent();
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
void WINAPI DXUT_Dynamic_D3DPERF_SetMarker( D3DCOLOR col, LPCTSTR wszName )
|
||||
{
|
||||
if( DXUT_EnsureD3DAPIs() && s_DynamicD3DPERF_SetMarker != NULL )
|
||||
s_DynamicD3DPERF_SetMarker( col, wszName );
|
||||
}
|
||||
|
||||
void WINAPI DXUT_Dynamic_D3DPERF_SetRegion( D3DCOLOR col, LPCTSTR wszName )
|
||||
{
|
||||
if( DXUT_EnsureD3DAPIs() && s_DynamicD3DPERF_SetRegion != NULL )
|
||||
s_DynamicD3DPERF_SetRegion( col, wszName );
|
||||
}
|
||||
|
||||
BOOL WINAPI DXUT_Dynamic_D3DPERF_QueryRepeatFrame( void )
|
||||
{
|
||||
if( DXUT_EnsureD3DAPIs() && s_DynamicD3DPERF_QueryRepeatFrame != NULL )
|
||||
return s_DynamicD3DPERF_QueryRepeatFrame();
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void WINAPI DXUT_Dynamic_D3DPERF_SetOptions( DWORD dwOptions )
|
||||
{
|
||||
if( DXUT_EnsureD3DAPIs() && s_DynamicD3DPERF_SetOptions != NULL )
|
||||
s_DynamicD3DPERF_SetOptions( dwOptions );
|
||||
}
|
||||
|
||||
DWORD WINAPI DXUT_Dynamic_D3DPERF_GetStatus( void )
|
||||
{
|
||||
if( DXUT_EnsureD3DAPIs() && s_DynamicD3DPERF_GetStatus != NULL )
|
||||
return s_DynamicD3DPERF_GetStatus();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,11 @@
|
||||
#include <stdio.h>
|
||||
#include <multimon.h>
|
||||
|
||||
// Direct3D includes
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include <dxerr9.h>
|
||||
|
||||
|
||||
#define STRSAFE_NO_DEPRECATE
|
||||
#include <strsafe.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user