Move the GetDeviceCaps into the wined3d library and call from d3d9.
[wine/multimedia.git] / dlls / d3d9 / directx.c
blob4bcea3f34a6b16bf4313b5b5d509124ed3590cf8
1 /*
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
21 #include "config.h"
23 #include <stdarg.h>
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "wingdi.h"
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);
46 *ppobj = This;
47 return D3D_OK;
50 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
51 return E_NOINTERFACE;
54 ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface) {
55 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
56 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
57 return ++(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);
64 if (ref == 0) {
65 IWineD3D_Release(This->WineD3D);
66 HeapFree(GetProcessHeap(), 0, This);
69 return ref;
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
89 structure */
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,
154 TargetFormat);
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);
173 return D3D_OK;
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