3 TraceDirect3D9::TraceDirect3D9(IDirect3D9 *pOriginal) {
4 m_pIDirect3D9 = pOriginal;
7 TraceDirect3D9::~TraceDirect3D9(void) {
10 HRESULT __stdcall TraceDirect3D9::QueryInterface(REFIID riid, void** ppvObj) {
13 // call this to increase AddRef at original object
14 // and to check if such an interface is there
16 HRESULT hRes = m_pIDirect3D9->QueryInterface(riid, ppvObj);
18 if (hRes == NOERROR) // if OK, send our "fake" address
26 ULONG __stdcall TraceDirect3D9::AddRef(void) {
27 return (m_pIDirect3D9->AddRef());
30 ULONG __stdcall TraceDirect3D9::Release(void) {
31 extern TraceDirect3D9* gl_pmyIDirect3D9;
33 // call original routine
34 ULONG count = m_pIDirect3D9->Release();
36 // in case no further Ref is there, the Original Object has deleted itself
39 gl_pmyIDirect3D9 = NULL;
46 HRESULT __stdcall TraceDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) {
47 return (m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction));
50 UINT __stdcall TraceDirect3D9::GetAdapterCount(void) {
51 return (m_pIDirect3D9->GetAdapterCount());
54 HRESULT __stdcall TraceDirect3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
55 return (m_pIDirect3D9->GetAdapterIdentifier(Adapter, Flags, pIdentifier));
58 UINT __stdcall TraceDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) {
59 return (m_pIDirect3D9->GetAdapterModeCount(Adapter, Format));
62 HRESULT __stdcall TraceDirect3D9::EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
63 return (m_pIDirect3D9->EnumAdapterModes(Adapter, Format, Mode, pMode));
66 HRESULT __stdcall TraceDirect3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) {
67 return (m_pIDirect3D9->GetAdapterDisplayMode(Adapter, pMode));
70 HRESULT __stdcall TraceDirect3D9::CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) {
71 return (m_pIDirect3D9->CheckDeviceType(iAdapter, DevType, DisplayFormat, BackBufferFormat, bWindowed));
74 HRESULT __stdcall TraceDirect3D9::CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
75 return (m_pIDirect3D9->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat));
78 HRESULT __stdcall TraceDirect3D9::CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
79 return (m_pIDirect3D9->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels));
82 HRESULT __stdcall TraceDirect3D9::CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
83 return (m_pIDirect3D9->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat));
86 HRESULT __stdcall TraceDirect3D9::CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
87 return (m_pIDirect3D9->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat));
90 HRESULT __stdcall TraceDirect3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
91 return (m_pIDirect3D9->GetDeviceCaps(Adapter, DeviceType, pCaps));
94 HMONITOR __stdcall TraceDirect3D9::GetAdapterMonitor(UINT Adapter) {
95 return (m_pIDirect3D9->GetAdapterMonitor(Adapter));
98 HRESULT __stdcall TraceDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) {
100 extern TraceDirect3DDevice9* gl_pmyIDirect3DDevice9;
102 // we intercept this call and provide our own "fake" Device Object
103 HRESULT hres = m_pIDirect3D9->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
105 // Create our own Device object and store it in global pointer
106 // note: the object will delete itself once Ref count is zero (similar to COM objects)
107 gl_pmyIDirect3DDevice9 = new TraceDirect3DDevice9(*ppReturnedDeviceInterface);
109 // store our pointer (the fake one) for returning it to the calling progam
110 *ppReturnedDeviceInterface = gl_pmyIDirect3DDevice9;