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
22 #include "d3d9_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
26 /* IDirect3D9 IUnknown parts follow: */
27 HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface, REFIID riid, LPVOID* ppobj)
29 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
31 if (IsEqualGUID(riid, &IID_IUnknown)
32 || IsEqualGUID(riid, &IID_IDirect3D9)) {
33 IDirect3D9Impl_AddRef(iface);
38 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
42 ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface) {
43 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
44 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
48 ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9 iface) {
49 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
50 ULONG ref = --This->ref;
51 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
53 IWineD3D_Release(This->WineD3D);
54 HeapFree(GetProcessHeap(), 0, This);
60 /* IDirect3D9 Interface follow: */
61 HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9 iface, void* pInitializeFunction) {
62 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
63 return IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
66 UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9 iface) {
67 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
68 return IWineD3D_GetAdapterCount(This->WineD3D);
71 HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
72 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
73 WINED3DADAPTER_IDENTIFIER adapter_id;
75 /* dx8 and dx9 have different structures to be filled in, with incompatible
76 layouts so pass in pointers to the places to be filled via an internal
78 adapter_id.Driver = pIdentifier->Driver;
79 adapter_id.Description = pIdentifier->Description;
80 adapter_id.DeviceName = pIdentifier->DeviceName;
81 adapter_id.DriverVersion = &pIdentifier->DriverVersion;
82 adapter_id.VendorId = &pIdentifier->VendorId;
83 adapter_id.DeviceId = &pIdentifier->DeviceId;
84 adapter_id.SubSysId = &pIdentifier->SubSysId;
85 adapter_id.Revision = &pIdentifier->Revision;
86 adapter_id.DeviceIdentifier = &pIdentifier->DeviceIdentifier;
87 adapter_id.WHQLLevel = &pIdentifier->WHQLLevel;
89 return IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
92 UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format) {
93 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
94 return IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, Format);
97 HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
98 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
99 return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, Format, Mode, pMode);
102 HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
103 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
104 return IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, pMode);
107 HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9 iface,
108 UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
109 D3DFORMAT BackBufferFormat, BOOL Windowed) {
110 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
111 return IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, DisplayFormat,
112 BackBufferFormat, Windowed);
115 HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9 iface,
116 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
117 DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
118 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
119 return IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, AdapterFormat,
120 Usage, RType, CheckFormat);
123 HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(LPDIRECT3D9 iface,
124 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
125 BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
126 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
127 return IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType, SurfaceFormat,
128 Windowed, MultiSampleType, pQualityLevels);
131 HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(LPDIRECT3D9 iface,
132 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
133 D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
134 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
135 return IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType, AdapterFormat,
136 RenderTargetFormat, DepthStencilFormat);
139 HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
140 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
141 return IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType, SourceFormat,
145 HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
146 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
147 return IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, (void *)pCaps);
150 HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter) {
151 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
152 return IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
155 HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
156 DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,
157 IDirect3DDevice9** ppReturnedDeviceInterface) {
159 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
160 IDirect3DDevice9Impl *object = NULL;
161 WINED3DPRESENT_PARAMETERS localParameters;
163 /* Check the validity range of the adapter parameter */
164 if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) {
165 return D3DERR_INVALIDCALL;
168 /* Allocate the storage for the device object */
169 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice9Impl));
170 if (NULL == object) {
171 return D3DERR_OUTOFVIDEOMEMORY;
173 object->lpVtbl = &Direct3DDevice9_Vtbl;
175 object->direct3d = This;
176 IDirect3D9_AddRef((LPDIRECT3D9) object->direct3d);
177 *ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
179 /* Allocate an associated WineD3DDevice object */
180 localParameters.BackBufferWidth = &pPresentationParameters->BackBufferWidth;
181 localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight;
182 localParameters.BackBufferFormat = &pPresentationParameters->BackBufferFormat;
183 localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount;
184 localParameters.MultiSampleType = &pPresentationParameters->MultiSampleType;
185 localParameters.MultiSampleQuality = &pPresentationParameters->MultiSampleQuality;
186 localParameters.SwapEffect = &pPresentationParameters->SwapEffect;
187 localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow;
188 localParameters.Windowed = &pPresentationParameters->Windowed;
189 localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil;
190 localParameters.AutoDepthStencilFormat = &pPresentationParameters->AutoDepthStencilFormat;
191 localParameters.Flags = &pPresentationParameters->Flags;
192 localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz;
193 localParameters.PresentationInterval = &pPresentationParameters->PresentationInterval;
194 IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice);
196 FIXME("(%p) : incomplete stub\n", This);
200 IDirect3D9Vtbl Direct3D9_Vtbl =
202 IDirect3D9Impl_QueryInterface,
203 IDirect3D9Impl_AddRef,
204 IDirect3D9Impl_Release,
205 IDirect3D9Impl_RegisterSoftwareDevice,
206 IDirect3D9Impl_GetAdapterCount,
207 IDirect3D9Impl_GetAdapterIdentifier,
208 IDirect3D9Impl_GetAdapterModeCount,
209 IDirect3D9Impl_EnumAdapterModes,
210 IDirect3D9Impl_GetAdapterDisplayMode,
211 IDirect3D9Impl_CheckDeviceType,
212 IDirect3D9Impl_CheckDeviceFormat,
213 IDirect3D9Impl_CheckDeviceMultiSampleType,
214 IDirect3D9Impl_CheckDepthStencilMatch,
215 IDirect3D9Impl_CheckDeviceFormatConversion,
216 IDirect3D9Impl_GetDeviceCaps,
217 IDirect3D9Impl_GetAdapterMonitor,
218 IDirect3D9Impl_CreateDevice