d3d9: Add typecasts for WINED3DLOCKED_BOX to avoid compiler warnings.
[wine/multimedia.git] / dlls / d3d9 / volumetexture.c
blob032bdf5a09919745a5a8e4ea674688a4ebac54f4
1 /*
2 * IDirect3DVolumeTexture9 implementation
4 * Copyright 2002-2005 Jason Edmeades
5 * Raphael Junqueira
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
27 /* IDirect3DVolumeTexture9 IUnknown parts follow: */
28 HRESULT WINAPI IDirect3DVolumeTexture9Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
29 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
31 if (IsEqualGUID(riid, &IID_IUnknown)
32 || IsEqualGUID(riid, &IID_IDirect3DResource9)
33 || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
34 || IsEqualGUID(riid, &IID_IDirect3DVolumeTexture9)) {
35 IUnknown_AddRef(iface);
36 *ppobj = This;
37 return D3D_OK;
40 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
41 return E_NOINTERFACE;
44 ULONG WINAPI IDirect3DVolumeTexture9Impl_AddRef(LPDIRECT3DVOLUMETEXTURE9 iface) {
45 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
46 ULONG ref = InterlockedIncrement(&This->ref);
48 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
50 return ref;
53 ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9 iface) {
54 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
55 ULONG ref = InterlockedDecrement(&This->ref);
57 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
59 if (ref == 0) {
60 IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
61 HeapFree(GetProcessHeap(), 0, This);
63 return ref;
66 /* IDirect3DVolumeTexture9 IDirect3DResource9 Interface follow: */
67 HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
68 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
69 TRACE("(%p) Relay\n", This);
70 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
73 HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
74 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
75 TRACE("(%p) Relay\n", This);
76 return IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
79 HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
80 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
81 TRACE("(%p) Relay\n", This);
82 return IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
85 HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid) {
86 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
87 TRACE("(%p) Relay\n", This);
88 return IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
91 DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD PriorityNew) {
92 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
93 TRACE("(%p) Relay\n", This);
94 return IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
97 DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE9 iface) {
98 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
99 TRACE("(%p) Relay\n", This);
100 return IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
103 void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE9 iface) {
104 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
105 TRACE("(%p) Relay\n", This);
106 return IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
109 D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLUMETEXTURE9 iface) {
110 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
111 TRACE("(%p) Relay\n", This);
112 return IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
115 /* IDirect3DVolumeTexture9 IDirect3DBaseTexture9 Interface follow: */
116 DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD LODNew) {
117 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
118 TRACE("(%p) Relay\n", This);
119 return IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
122 DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE9 iface) {
123 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
124 TRACE("(%p) Relay\n", This);
125 return IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
128 DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE9 iface) {
129 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
130 TRACE("(%p) Relay\n", This);
131 return IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
134 HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
135 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
136 TRACE("(%p) Relay\n", This);
137 return IWineD3DVolumeTexture_SetAutoGenFilterType(This->wineD3DVolumeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
140 D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface) {
141 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
142 TRACE("(%p) Relay\n", This);
143 return (D3DTEXTUREFILTERTYPE) IWineD3DVolumeTexture_GetAutoGenFilterType(This->wineD3DVolumeTexture);
146 void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVOLUMETEXTURE9 iface) {
147 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
148 TRACE("(%p) Relay\n", This);
149 return IWineD3DVolumeTexture_GenerateMipSubLevels(This->wineD3DVolumeTexture);
152 /* IDirect3DVolumeTexture9 Interface follow: */
153 HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
154 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
155 WINED3DVOLUME_DESC wined3ddesc;
156 UINT tmpInt = -1;
158 TRACE("(%p) Relay\n", This);
160 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
161 wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
162 wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
163 wined3ddesc.Usage = &pDesc->Usage;
164 wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
165 wined3ddesc.Size = &tmpInt;
166 wined3ddesc.Width = &pDesc->Width;
167 wined3ddesc.Height = &pDesc->Height;
168 wined3ddesc.Depth = &pDesc->Depth;
170 return IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
173 HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, IDirect3DVolume9** ppVolumeLevel) {
174 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
175 HRESULT hrc = D3D_OK;
176 IWineD3DVolume *myVolume = NULL;
178 TRACE("(%p) Relay\n", This);
180 hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
181 if (hrc == D3D_OK && NULL != ppVolumeLevel) {
182 IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
183 IWineD3DVolumeTexture_Release(myVolume);
185 return hrc;
188 HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
189 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
190 TRACE("(%p) Relay %p %p %p %ld\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
191 return IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (WINED3DBOX *) pBox, Flags);
194 HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level) {
195 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
196 TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
197 return IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
200 HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE9 iface, CONST D3DBOX* pDirtyBox) {
201 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
202 TRACE("(%p) Relay\n", This);
203 return IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (WINED3DBOX *) pDirtyBox);
207 const IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl =
209 /* IUnknown */
210 IDirect3DVolumeTexture9Impl_QueryInterface,
211 IDirect3DVolumeTexture9Impl_AddRef,
212 IDirect3DVolumeTexture9Impl_Release,
213 /* IDirect3DResource9 */
214 IDirect3DVolumeTexture9Impl_GetDevice,
215 IDirect3DVolumeTexture9Impl_SetPrivateData,
216 IDirect3DVolumeTexture9Impl_GetPrivateData,
217 IDirect3DVolumeTexture9Impl_FreePrivateData,
218 IDirect3DVolumeTexture9Impl_SetPriority,
219 IDirect3DVolumeTexture9Impl_GetPriority,
220 IDirect3DVolumeTexture9Impl_PreLoad,
221 IDirect3DVolumeTexture9Impl_GetType,
222 /* IDirect3DBaseTexture9 */
223 IDirect3DVolumeTexture9Impl_SetLOD,
224 IDirect3DVolumeTexture9Impl_GetLOD,
225 IDirect3DVolumeTexture9Impl_GetLevelCount,
226 IDirect3DVolumeTexture9Impl_SetAutoGenFilterType,
227 IDirect3DVolumeTexture9Impl_GetAutoGenFilterType,
228 IDirect3DVolumeTexture9Impl_GenerateMipSubLevels,
229 /* IDirect3DVolumeTexture9 */
230 IDirect3DVolumeTexture9Impl_GetLevelDesc,
231 IDirect3DVolumeTexture9Impl_GetVolumeLevel,
232 IDirect3DVolumeTexture9Impl_LockBox,
233 IDirect3DVolumeTexture9Impl_UnlockBox,
234 IDirect3DVolumeTexture9Impl_AddDirtyBox
238 /* IDirect3DDevice9 IDirect3DVolumeTexture9 Methods follow: */
239 HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9 iface,
240 UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage,
241 D3DFORMAT Format, D3DPOOL Pool,
242 IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) {
244 IDirect3DVolumeTexture9Impl *object;
245 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
246 HRESULT hrc = D3D_OK;
248 TRACE("(%p) Relay\n", This);
250 /* Allocate the storage for the device */
251 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture9Impl));
252 if (NULL == object) {
253 FIXME("(%p) allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n", This);
254 return D3DERR_OUTOFVIDEOMEMORY;
257 object->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
258 object->ref = 1;
259 hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage,
260 (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DVolumeTexture, pSharedHandle,
261 (IUnknown *)object, D3D9CB_CreateVolume);
264 if (hrc != D3D_OK) {
266 /* free up object */
267 FIXME("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This);
268 HeapFree(GetProcessHeap(), 0, object);
269 } else {
270 *ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE9) object;
271 TRACE("(%p) : Created volume texture %p\n", This, object);
273 TRACE("(%p) returning %p\n", This , *ppVolumeTexture);
274 return hrc;