]> git.cworth.org Git - apitrace/blob - d3d9/idirect3d9.cpp
Dump flags.
[apitrace] / d3d9 / idirect3d9.cpp
1 #include "StdAfx.h"
2
3 TraceDirect3D9::TraceDirect3D9(IDirect3D9 *pOriginal) {
4     m_pIDirect3D9 = pOriginal;
5 }
6
7 TraceDirect3D9::~TraceDirect3D9(void) {
8 }
9
10 HRESULT __stdcall TraceDirect3D9::QueryInterface(REFIID riid, void** ppvObj) {
11     *ppvObj = NULL;
12
13     // call this to increase AddRef at original object
14     // and to check if such an interface is there
15
16     HRESULT hRes = m_pIDirect3D9->QueryInterface(riid, ppvObj);
17
18     if (hRes == NOERROR) // if OK, send our "fake" address
19     {
20         *ppvObj = this;
21     }
22
23     return hRes;
24 }
25
26 ULONG __stdcall TraceDirect3D9::AddRef(void) {
27     return (m_pIDirect3D9->AddRef());
28 }
29
30 ULONG __stdcall TraceDirect3D9::Release(void) {
31     extern TraceDirect3D9* gl_pmyIDirect3D9;
32
33     // call original routine
34     ULONG count = m_pIDirect3D9->Release();
35
36     // in case no further Ref is there, the Original Object has deleted itself
37     // so do we here
38     if (count == 0) {
39         gl_pmyIDirect3D9 = NULL;
40         delete (this);
41     }
42
43     return (count);
44 }
45
46 HRESULT __stdcall TraceDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) {
47     return (m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction));
48 }
49
50 UINT __stdcall TraceDirect3D9::GetAdapterCount(void) {
51     return (m_pIDirect3D9->GetAdapterCount());
52 }
53
54 HRESULT __stdcall TraceDirect3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
55     return (m_pIDirect3D9->GetAdapterIdentifier(Adapter, Flags, pIdentifier));
56 }
57
58 UINT __stdcall TraceDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) {
59     return (m_pIDirect3D9->GetAdapterModeCount(Adapter, Format));
60 }
61
62 HRESULT __stdcall TraceDirect3D9::EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
63     return (m_pIDirect3D9->EnumAdapterModes(Adapter, Format, Mode, pMode));
64 }
65
66 HRESULT __stdcall TraceDirect3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) {
67     return (m_pIDirect3D9->GetAdapterDisplayMode(Adapter, pMode));
68 }
69
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));
72 }
73
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));
76 }
77
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));
80 }
81
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));
84 }
85
86 HRESULT __stdcall TraceDirect3D9::CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
87     return (m_pIDirect3D9->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat));
88 }
89
90 HRESULT __stdcall TraceDirect3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
91     return (m_pIDirect3D9->GetDeviceCaps(Adapter, DeviceType, pCaps));
92 }
93
94 HMONITOR __stdcall TraceDirect3D9::GetAdapterMonitor(UINT Adapter) {
95     return (m_pIDirect3D9->GetAdapterMonitor(Adapter));
96 }
97
98 HRESULT __stdcall TraceDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) {
99     // global var
100     extern TraceDirect3DDevice9* gl_pmyIDirect3DDevice9;
101
102     // we intercept this call and provide our own "fake" Device Object
103     HRESULT hres = m_pIDirect3D9->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
104
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);
108
109     // store our pointer (the fake one) for returning it to the calling progam
110     *ppReturnedDeviceInterface = gl_pmyIDirect3DDevice9;
111
112     return (hres);
113 }
114