Print exe name when initialization fails.
[wine] / dlls / d3d9 / volumetexture.c
1 /*
2  * IDirect3DVolumeTexture9 implementation
3  *
4  * Copyright 2002-2003 Jason Edmeades
5  *                     Raphael Junqueira
6  *
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.
11  *
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.
16  *
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
20  */
21
22 #include "config.h"
23
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26 #include <stdarg.h>
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "wingdi.h"
32 #include "wine/debug.h"
33
34 #include "d3d9_private.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
37
38 /* IDirect3DVolumeTexture9 IUnknown parts follow: */
39 HRESULT WINAPI IDirect3DVolumeTexture9Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
40     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
41
42     if (IsEqualGUID(riid, &IID_IUnknown)
43         || IsEqualGUID(riid, &IID_IDirect3DResource9)
44         || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
45         || IsEqualGUID(riid, &IID_IDirect3DVolumeTexture9)) {
46         IDirect3DVolumeTexture9Impl_AddRef(iface);
47         *ppobj = This;
48         return D3D_OK;
49     }
50
51     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
52     return E_NOINTERFACE;
53 }
54
55 ULONG WINAPI IDirect3DVolumeTexture9Impl_AddRef(LPDIRECT3DVOLUMETEXTURE9 iface) {
56     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
57     TRACE("(%p) : AddRef from %ld\n", This, This->ref);
58     return ++(This->ref);
59 }
60
61 ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9 iface) {
62     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
63     ULONG ref = --This->ref;
64     UINT  i;
65
66     TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
67     if (ref == 0) {
68         for (i = 0; i < This->levels; i++) {
69             if (This->volumes[i] != NULL) {
70                 TRACE("(%p) : Releasing volume %p\n", This, This->volumes[i]);
71                 IDirect3DVolume9Impl_Release((LPDIRECT3DVOLUME9) This->volumes[i]);
72             }
73         }
74         HeapFree(GetProcessHeap(), 0, This);
75     }
76     return ref;
77 }
78
79 /* IDirect3DVolumeTexture9 IDirect3DResource9 Interface follow: */
80 HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
81     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
82     return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
83 }
84
85 HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
86     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
87     FIXME("(%p) : stub\n", This);
88     return D3D_OK;
89 }
90
91 HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
92     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
93     FIXME("(%p) : stub\n", This);
94     return D3D_OK;
95 }
96
97 HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid) {
98     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
99     FIXME("(%p) : stub\n", This);
100     return D3D_OK;
101 }
102
103 DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD PriorityNew) {
104     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
105     return IDirect3DResource9Impl_SetPriority((LPDIRECT3DRESOURCE9) This, PriorityNew);
106 }
107
108 DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE9 iface) {
109     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
110     return IDirect3DResource9Impl_GetPriority((LPDIRECT3DRESOURCE9) This);
111 }
112
113 void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE9 iface) {
114     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
115     FIXME("(%p) : stub\n", This);
116     return ;
117 }
118
119 D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLUMETEXTURE9 iface) {
120     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
121     return IDirect3DResource9Impl_GetType((LPDIRECT3DRESOURCE9) This);
122 }
123
124 /* IDirect3DVolumeTexture9 IDirect3DBaseTexture9 Interface follow: */
125 DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD LODNew) {
126     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
127     return IDirect3DBaseTexture9Impl_SetLOD((LPDIRECT3DBASETEXTURE9) This, LODNew);
128 }
129
130 DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE9 iface) {
131     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
132     return IDirect3DBaseTexture9Impl_GetLOD((LPDIRECT3DBASETEXTURE9) This);
133 }
134
135 DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE9 iface) {
136     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
137     return IDirect3DBaseTexture9Impl_GetLevelCount((LPDIRECT3DBASETEXTURE9) This);
138 }
139
140 HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
141     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
142     return IDirect3DBaseTexture9Impl_SetAutoGenFilterType((LPDIRECT3DBASETEXTURE9) This, FilterType);
143 }
144
145 D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface) {
146     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
147     return IDirect3DBaseTexture9Impl_GetAutoGenFilterType((LPDIRECT3DBASETEXTURE9) This);
148 }
149
150 void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVOLUMETEXTURE9 iface) {
151     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
152     FIXME("(%p) : stub\n", This);
153     return ;
154 }
155
156 /* IDirect3DVolumeTexture9 Interface follow: */
157 HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
158     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
159     if (Level < This->levels) {
160         TRACE("(%p) Level (%d)\n", This, Level);
161         return IDirect3DVolume9Impl_GetDesc((LPDIRECT3DVOLUME9) This->volumes[Level], pDesc);
162     } else {
163         FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
164         return D3DERR_INVALIDCALL;
165     }
166     return D3D_OK;
167 }
168
169 HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, IDirect3DVolume9** ppVolumeLevel) {
170     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
171     if (Level < This->levels) {
172       *ppVolumeLevel = (LPDIRECT3DVOLUME9) This->volumes[Level];
173       IDirect3DVolume9Impl_AddRef((LPDIRECT3DVOLUME9) *ppVolumeLevel);
174       TRACE("(%p) -> level(%d) returning volume@%p\n", This, Level, *ppVolumeLevel);
175     } else {
176       FIXME("(%p) Level(%d) overflow Levels(%d)\n", This, Level, This->levels);
177       return D3DERR_INVALIDCALL;
178     }
179     return D3D_OK;
180
181 }
182 HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
183     HRESULT hr;
184     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
185     if (Level < This->levels) {
186       /**
187        * Not dirtified while Surfaces don't notify dirtification
188        * This->Dirty = TRUE;
189        */
190       hr = IDirect3DVolume9Impl_LockBox((LPDIRECT3DVOLUME9) This->volumes[Level], pLockedVolume, pBox, Flags);
191       TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
192     } else {
193       FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
194       return D3DERR_INVALIDCALL;
195     }
196     return hr;
197 }
198
199 HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level) {
200     HRESULT hr;
201     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
202     if (Level < This->levels) {
203       hr = IDirect3DVolume9Impl_UnlockBox((LPDIRECT3DVOLUME9) This->volumes[Level]);
204       TRACE("(%p) -> level(%d) success(%lu)\n", This, Level, hr);
205     } else {
206       FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
207       return D3DERR_INVALIDCALL;
208     }
209     return hr;
210 }
211
212 HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE9 iface, CONST D3DBOX* pDirtyBox) {
213     ICOM_THIS(IDirect3DVolumeTexture9Impl,iface);
214     FIXME("(%p) : stub\n", This);
215     This->Dirty = TRUE;
216     return D3D_OK;
217 }
218
219
220 ICOM_VTABLE(IDirect3DVolumeTexture9) Direct3DVolumeTexture9_Vtbl =
221 {
222     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
223     IDirect3DVolumeTexture9Impl_QueryInterface,
224     IDirect3DVolumeTexture9Impl_AddRef,
225     IDirect3DVolumeTexture9Impl_Release,
226     IDirect3DVolumeTexture9Impl_GetDevice,
227     IDirect3DVolumeTexture9Impl_SetPrivateData,
228     IDirect3DVolumeTexture9Impl_GetPrivateData,
229     IDirect3DVolumeTexture9Impl_FreePrivateData,
230     IDirect3DVolumeTexture9Impl_SetPriority,
231     IDirect3DVolumeTexture9Impl_GetPriority,
232     IDirect3DVolumeTexture9Impl_PreLoad,
233     IDirect3DVolumeTexture9Impl_GetType,
234     IDirect3DVolumeTexture9Impl_SetLOD,
235     IDirect3DVolumeTexture9Impl_GetLOD,
236     IDirect3DVolumeTexture9Impl_GetLevelCount,
237     IDirect3DVolumeTexture9Impl_SetAutoGenFilterType,
238     IDirect3DVolumeTexture9Impl_GetAutoGenFilterType,
239     IDirect3DVolumeTexture9Impl_GenerateMipSubLevels,
240     IDirect3DVolumeTexture9Impl_GetLevelDesc,
241     IDirect3DVolumeTexture9Impl_GetVolumeLevel,
242     IDirect3DVolumeTexture9Impl_LockBox,
243     IDirect3DVolumeTexture9Impl_UnlockBox,
244     IDirect3DVolumeTexture9Impl_AddDirtyBox
245 };
246
247
248 /* IDirect3DDevice9 IDirect3DVolumeTexture9 Methods follow: */
249 HRESULT  WINAPI  IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9 iface, 
250                                                           UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, 
251                                                           D3DFORMAT Format, D3DPOOL Pool, 
252                                                           IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) {
253
254     ICOM_THIS(IDirect3DDevice9Impl,iface);
255     FIXME("(%p) : stub\n", This);
256     return D3D_OK;
257 }