-
Notifications
You must be signed in to change notification settings - Fork 0
/
myIDirect3D8.cpp
130 lines (100 loc) · 4.24 KB
/
myIDirect3D8.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// myIDirect3D8.cpp
#include "stdafx.h"
myIDirect3D8::myIDirect3D8(IDirect3D8 *pOriginal)
{
m_pIDirect3D8 = pOriginal; // store the pointer to original object
}
myIDirect3D8::~myIDirect3D8()
{
}
HRESULT __stdcall myIDirect3D8::QueryInterface(REFIID riid, void** ppvObj)
{
*ppvObj = NULL;
// call this to increase AddRef at original object
// and to check if such an interface is there
HRESULT hRes = m_pIDirect3D8->QueryInterface(riid, ppvObj);
if (hRes == NOERROR) // if OK, send our "fake" address
{
*ppvObj = this;
}
return hRes;
}
ULONG __stdcall myIDirect3D8::AddRef()
{
return(m_pIDirect3D8->AddRef());
}
ULONG __stdcall myIDirect3D8::Release()
{
extern myIDirect3D8* gl_pmyIDirect3D8;
// call original routine
ULONG count = m_pIDirect3D8->Release();
// in case no further Ref is there, the Original Object has deleted itself
// so do we here
if (count == 0)
{
gl_pmyIDirect3D8 = NULL;
delete(this);
}
return(count);
}
HRESULT __stdcall myIDirect3D8::RegisterSoftwareDevice(void* pInitializeFunction)
{
return(m_pIDirect3D8->RegisterSoftwareDevice(pInitializeFunction));
}
UINT __stdcall myIDirect3D8::GetAdapterCount()
{
return(m_pIDirect3D8->GetAdapterCount());
}
HRESULT __stdcall myIDirect3D8::GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER8* pIdentifier)
{
return(m_pIDirect3D8->GetAdapterIdentifier( Adapter, Flags, pIdentifier));
}
UINT __stdcall myIDirect3D8::GetAdapterModeCount(UINT Adapter)
{
return(m_pIDirect3D8->GetAdapterModeCount(Adapter));
}
HRESULT __stdcall myIDirect3D8::EnumAdapterModes(UINT Adapter,UINT Mode,D3DDISPLAYMODE* pMode)
{
return(m_pIDirect3D8->EnumAdapterModes( Adapter, Mode, pMode) );
}
HRESULT __stdcall myIDirect3D8::GetAdapterDisplayMode( UINT Adapter,D3DDISPLAYMODE* pMode)
{
return(m_pIDirect3D8->GetAdapterDisplayMode( Adapter, pMode) );
}
HRESULT __stdcall myIDirect3D8::CheckDeviceType(UINT Adapter,D3DDEVTYPE CheckType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL Windowed)
{
return(m_pIDirect3D8->CheckDeviceType( Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed) );
}
HRESULT __stdcall myIDirect3D8::CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat)
{
return(m_pIDirect3D8->CheckDeviceFormat( Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat) );
}
HRESULT __stdcall myIDirect3D8::CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType)
{
return(m_pIDirect3D8->CheckDeviceMultiSampleType( Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType));
}
HRESULT __stdcall myIDirect3D8::CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat)
{
return(m_pIDirect3D8->CheckDepthStencilMatch( Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat));
}
HRESULT __stdcall myIDirect3D8::GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS8* pCaps)
{
return(m_pIDirect3D8->GetDeviceCaps( Adapter, DeviceType, pCaps));
}
HMONITOR __stdcall myIDirect3D8::GetAdapterMonitor(UINT Adapter)
{
return(m_pIDirect3D8->GetAdapterMonitor( Adapter));
}
HRESULT __stdcall myIDirect3D8::CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice8** ppReturnedDeviceInterface)
{
// global var
extern myIDirect3DDevice8* gl_pmyIDirect3DDevice8;
// we intercept this call and provide our own "fake" Device Object
HRESULT hres = m_pIDirect3D8->CreateDevice( Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
// Create our own Device object and strore it in global pointer
// note: the object will delete itself once Ref count is zero (similar to COM objects)
gl_pmyIDirect3DDevice8 = new myIDirect3DDevice8(*ppReturnedDeviceInterface);
// store our pointer (the fake one) for returning it to the calling progam
*ppReturnedDeviceInterface = gl_pmyIDirect3DDevice8;
return(hres);
}