2 * IDirect3DVolume8 implementation
4 * Copyright 2005 Oliver Stieber
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 "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8
);
26 /* IDirect3DVolume8 IUnknown parts follow: */
27 HRESULT WINAPI
IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface
, REFIID riid
, LPVOID
*ppobj
) {
28 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
30 if (IsEqualGUID(riid
, &IID_IUnknown
)
31 || IsEqualGUID(riid
, &IID_IDirect3DVolume8
)) {
32 IUnknown_AddRef(iface
);
37 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
41 ULONG WINAPI
IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface
) {
42 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
43 ULONG ref
= InterlockedIncrement(&This
->ref
);
45 TRACE("(%p) : AddRef from %ld\n", This
, ref
- 1);
50 ULONG WINAPI
IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface
) {
51 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
52 ULONG ref
= InterlockedDecrement(&This
->ref
);
54 TRACE("(%p) : ReleaseRef to %ld\n", This
, ref
);
57 IWineD3DVolume_Release(This
->wineD3DVolume
);
58 HeapFree(GetProcessHeap(), 0, This
);
63 /* IDirect3DVolume8 Interface follow: */
64 HRESULT WINAPI
IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface
, IDirect3DDevice8
**ppDevice
) {
65 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
66 IWineD3DDevice
*myDevice
= NULL
;
68 IWineD3DVolume_GetDevice(This
->wineD3DVolume
, &myDevice
);
69 IWineD3DDevice_GetParent(myDevice
, (IUnknown
**)ppDevice
);
70 IWineD3DDevice_Release(myDevice
);
74 HRESULT WINAPI
IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface
, REFGUID refguid
, CONST
void *pData
, DWORD SizeOfData
, DWORD Flags
) {
75 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
76 TRACE("(%p) Relay\n", This
);
77 return IWineD3DVolume_SetPrivateData(This
->wineD3DVolume
, refguid
, pData
, SizeOfData
, Flags
);
80 HRESULT WINAPI
IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface
, REFGUID refguid
, void *pData
, DWORD
* pSizeOfData
) {
81 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
82 TRACE("(%p) Relay\n", This
);
83 return IWineD3DVolume_GetPrivateData(This
->wineD3DVolume
, refguid
, pData
, pSizeOfData
);
86 HRESULT WINAPI
IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface
, REFGUID refguid
) {
87 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
88 TRACE("(%p) Relay\n", This
);
89 return IWineD3DVolume_FreePrivateData(This
->wineD3DVolume
, refguid
);
92 HRESULT WINAPI
IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface
, REFIID riid
, void **ppContainer
) {
93 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
95 IUnknown
*IWineContainer
= NULL
;
97 TRACE("(%p) Relay\n", This
);
98 res
= IWineD3DVolume_GetContainer(This
->wineD3DVolume
, riid
, (void **)&IWineContainer
);
100 /* If this works, the only valid container is a child of resource (volumetexture) */
101 if (res
== D3D_OK
&& NULL
!= ppContainer
) {
102 IWineD3DResource_GetParent((IWineD3DResource
*)IWineContainer
, (IUnknown
**)ppContainer
);
103 IWineD3DResource_Release((IWineD3DResource
*)IWineContainer
);
109 HRESULT WINAPI
IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface
, D3DVOLUME_DESC
*pDesc
) {
110 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
111 WINED3DVOLUME_DESC wined3ddesc
;
114 TRACE("(%p) Relay\n", This
);
116 /* As d3d8 and d3d8 structures differ, pass in ptrs to where data needs to go */
117 wined3ddesc
.Format
= (WINED3DFORMAT
*)&pDesc
->Format
;
118 wined3ddesc
.Type
= &pDesc
->Type
;
119 wined3ddesc
.Usage
= &pDesc
->Usage
;
120 wined3ddesc
.Pool
= &pDesc
->Pool
;
121 wined3ddesc
.Size
= &tmpInt
;
122 wined3ddesc
.Width
= &pDesc
->Width
;
123 wined3ddesc
.Height
= &pDesc
->Height
;
124 wined3ddesc
.Depth
= &pDesc
->Depth
;
126 return IWineD3DVolume_GetDesc(This
->wineD3DVolume
, &wined3ddesc
);
129 HRESULT WINAPI
IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface
, D3DLOCKED_BOX
*pLockedVolume
, CONST D3DBOX
*pBox
, DWORD Flags
) {
130 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
131 TRACE("(%p) relay %p %p %p %ld\n", This
, This
->wineD3DVolume
, pLockedVolume
, pBox
, Flags
);
132 return IWineD3DVolume_LockBox(This
->wineD3DVolume
, pLockedVolume
, pBox
, Flags
);
135 HRESULT WINAPI
IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface
) {
136 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
137 TRACE("(%p) relay %p\n", This
, This
->wineD3DVolume
);
138 return IWineD3DVolume_UnlockBox(This
->wineD3DVolume
);
141 const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl
=
144 IDirect3DVolume8Impl_QueryInterface
,
145 IDirect3DVolume8Impl_AddRef
,
146 IDirect3DVolume8Impl_Release
,
147 /* IDirect3DVolume8 */
148 IDirect3DVolume8Impl_GetDevice
,
149 IDirect3DVolume8Impl_SetPrivateData
,
150 IDirect3DVolume8Impl_GetPrivateData
,
151 IDirect3DVolume8Impl_FreePrivateData
,
152 IDirect3DVolume8Impl_GetContainer
,
153 IDirect3DVolume8Impl_GetDesc
,
154 IDirect3DVolume8Impl_LockBox
,
155 IDirect3DVolume8Impl_UnlockBox
159 /* Internal function called back during the CreateVolumeTexture */
160 HRESULT WINAPI
D3D8CB_CreateVolume(IUnknown
*pDevice
, UINT Width
, UINT Height
, UINT Depth
,
161 WINED3DFORMAT Format
, D3DPOOL Pool
, DWORD Usage
,
162 IWineD3DVolume
**ppVolume
,
163 HANDLE
* pSharedHandle
) {
164 IDirect3DVolume8Impl
*object
;
165 IDirect3DDevice8Impl
*This
= (IDirect3DDevice8Impl
*)pDevice
;
166 HRESULT hrc
= D3D_OK
;
168 /* Allocate the storage for the device */
169 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DVolume8Impl
));
170 if (NULL
== object
) {
171 FIXME("Allocation of memory failed\n");
173 return D3DERR_OUTOFVIDEOMEMORY
;
176 object
->lpVtbl
= &Direct3DVolume8_Vtbl
;
178 hrc
= IWineD3DDevice_CreateVolume(This
->WineD3DDevice
, Width
, Height
, Depth
, Usage
, Format
,
179 Pool
, &object
->wineD3DVolume
, pSharedHandle
, (IUnknown
*)object
);
182 FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This
);
183 HeapFree(GetProcessHeap(), 0, object
);
186 *ppVolume
= (IWineD3DVolume
*)object
->wineD3DVolume
;
188 TRACE("(%p) Created volume %p\n", This
, *ppVolume
);