2 * IDirect3D9 implementation
4 * Copyright 2002 Jason Edmeades
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "d3d9_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
38 /* IDirect3D9 IUnknown parts follow: */
39 HRESULT WINAPI
IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface
, REFIID riid
, LPVOID
* ppobj
)
41 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
43 if (IsEqualGUID(riid
, &IID_IUnknown
)
44 || IsEqualGUID(riid
, &IID_IDirect3D9
)) {
45 IDirect3D9Impl_AddRef(iface
);
50 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
54 ULONG WINAPI
IDirect3D9Impl_AddRef(LPDIRECT3D9 iface
) {
55 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
56 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
60 ULONG WINAPI
IDirect3D9Impl_Release(LPDIRECT3D9 iface
) {
61 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
62 ULONG ref
= --This
->ref
;
63 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
65 IWineD3D_Release(This
->WineD3D
);
66 HeapFree(GetProcessHeap(), 0, This
);
72 /* IDirect3D9 Interface follow: */
73 HRESULT WINAPI
IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9 iface
, void* pInitializeFunction
) {
74 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
75 return IWineD3D_RegisterSoftwareDevice(This
->WineD3D
, pInitializeFunction
);
78 UINT WINAPI
IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9 iface
) {
79 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
80 return IWineD3D_GetAdapterCount(This
->WineD3D
);
83 HRESULT WINAPI
IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface
, UINT Adapter
, DWORD Flags
, D3DADAPTER_IDENTIFIER9
* pIdentifier
) {
84 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
85 WINED3DADAPTER_IDENTIFIER adapter_id
;
87 /* dx8 and dx9 have different structures to be filled in, with incompatible
88 layouts so pass in pointers to the places to be filled via an internal
90 adapter_id
.Driver
= pIdentifier
->Driver
;
91 adapter_id
.Description
= pIdentifier
->Description
;
92 adapter_id
.DeviceName
= pIdentifier
->DeviceName
;
93 adapter_id
.DriverVersion
= &pIdentifier
->DriverVersion
;
94 adapter_id
.VendorId
= &pIdentifier
->VendorId
;
95 adapter_id
.DeviceId
= &pIdentifier
->DeviceId
;
96 adapter_id
.SubSysId
= &pIdentifier
->SubSysId
;
97 adapter_id
.Revision
= &pIdentifier
->Revision
;
98 adapter_id
.DeviceIdentifier
= &pIdentifier
->DeviceIdentifier
;
99 adapter_id
.WHQLLevel
= &pIdentifier
->WHQLLevel
;
101 return IWineD3D_GetAdapterIdentifier(This
->WineD3D
, Adapter
, Flags
, &adapter_id
);
104 UINT WINAPI
IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface
, UINT Adapter
, D3DFORMAT Format
) {
105 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
106 return IWineD3D_GetAdapterModeCount(This
->WineD3D
, Adapter
, Format
);
109 HRESULT WINAPI
IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface
, UINT Adapter
, D3DFORMAT Format
, UINT Mode
, D3DDISPLAYMODE
* pMode
) {
110 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
111 return IWineD3D_EnumAdapterModes(This
->WineD3D
, Adapter
, Format
, Mode
, pMode
);
114 HRESULT WINAPI
IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9 iface
, UINT Adapter
, D3DDISPLAYMODE
* pMode
) {
115 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
116 return IWineD3D_GetAdapterDisplayMode(This
->WineD3D
, Adapter
, pMode
);
119 HRESULT WINAPI
IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9 iface
,
120 UINT Adapter
, D3DDEVTYPE CheckType
, D3DFORMAT DisplayFormat
,
121 D3DFORMAT BackBufferFormat
, BOOL Windowed
) {
122 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
123 return IWineD3D_CheckDeviceType(This
->WineD3D
, Adapter
, CheckType
, DisplayFormat
,
124 BackBufferFormat
, Windowed
);
127 HRESULT WINAPI
IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9 iface
,
128 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
129 DWORD Usage
, D3DRESOURCETYPE RType
, D3DFORMAT CheckFormat
) {
130 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
131 return IWineD3D_CheckDeviceFormat(This
->WineD3D
, Adapter
, DeviceType
, AdapterFormat
,
132 Usage
, RType
, CheckFormat
);
135 HRESULT WINAPI
IDirect3D9Impl_CheckDeviceMultiSampleType(LPDIRECT3D9 iface
,
136 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT SurfaceFormat
,
137 BOOL Windowed
, D3DMULTISAMPLE_TYPE MultiSampleType
, DWORD
* pQualityLevels
) {
138 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
139 return IWineD3D_CheckDeviceMultiSampleType(This
->WineD3D
, Adapter
, DeviceType
, SurfaceFormat
,
140 Windowed
, MultiSampleType
, pQualityLevels
);
143 HRESULT WINAPI
IDirect3D9Impl_CheckDepthStencilMatch(LPDIRECT3D9 iface
,
144 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
145 D3DFORMAT RenderTargetFormat
, D3DFORMAT DepthStencilFormat
) {
146 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
147 return IWineD3D_CheckDepthStencilMatch(This
->WineD3D
, Adapter
, DeviceType
, AdapterFormat
,
148 RenderTargetFormat
, DepthStencilFormat
);
151 HRESULT WINAPI
IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9 iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT SourceFormat
, D3DFORMAT TargetFormat
) {
152 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
153 return IWineD3D_CheckDeviceFormatConversion(This
->WineD3D
, Adapter
, DeviceType
, SourceFormat
,
157 HRESULT WINAPI
IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, D3DCAPS9
* pCaps
) {
158 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
159 return IWineD3D_GetDeviceCaps(This
->WineD3D
, Adapter
, DeviceType
, (void *)pCaps
);
162 HMONITOR WINAPI
IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface
, UINT Adapter
) {
163 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
164 return IWineD3D_GetAdapterMonitor(This
->WineD3D
, Adapter
);
167 HRESULT WINAPI
IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, HWND hFocusWindow
,
168 DWORD BehaviourFlags
, D3DPRESENT_PARAMETERS
* pPresentationParameters
,
169 IDirect3DDevice9
** ppReturnedDeviceInterface
) {
171 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
172 FIXME("(%p) : stub\n", This
);
176 IDirect3D9Vtbl Direct3D9_Vtbl
=
178 IDirect3D9Impl_QueryInterface
,
179 IDirect3D9Impl_AddRef
,
180 IDirect3D9Impl_Release
,
181 IDirect3D9Impl_RegisterSoftwareDevice
,
182 IDirect3D9Impl_GetAdapterCount
,
183 IDirect3D9Impl_GetAdapterIdentifier
,
184 IDirect3D9Impl_GetAdapterModeCount
,
185 IDirect3D9Impl_EnumAdapterModes
,
186 IDirect3D9Impl_GetAdapterDisplayMode
,
187 IDirect3D9Impl_CheckDeviceType
,
188 IDirect3D9Impl_CheckDeviceFormat
,
189 IDirect3D9Impl_CheckDeviceMultiSampleType
,
190 IDirect3D9Impl_CheckDepthStencilMatch
,
191 IDirect3D9Impl_CheckDeviceFormatConversion
,
192 IDirect3D9Impl_GetDeviceCaps
,
193 IDirect3D9Impl_GetAdapterMonitor
,
194 IDirect3D9Impl_CreateDevice