2 * IWineD3DVolumeTexture implementation
4 * Copyright 2002-2005 Jason Edmeades
5 * Copyright 2002-2005 Raphael Junqueira
6 * Copyright 2005 Oliver Stieber
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wined3d_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
27 #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
29 /* *******************************************
30 IWineD3DTexture IUnknown parts follow
31 ******************************************* */
32 HRESULT WINAPI IWineD3DVolumeTextureImpl_QueryInterface(IWineD3DVolumeTexture *iface, REFIID riid, LPVOID *ppobj)
34 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
35 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
36 if (IsEqualGUID(riid, &IID_IUnknown)
37 || IsEqualGUID(riid, &IID_IWineD3DBase)
38 || IsEqualGUID(riid, &IID_IWineD3DResource)
39 || IsEqualGUID(riid, &IID_IWineD3DBaseTexture)
40 || IsEqualGUID(riid, &IID_IWineD3DVolumeTexture)) {
41 IUnknown_AddRef(iface);
49 ULONG WINAPI IWineD3DVolumeTextureImpl_AddRef(IWineD3DVolumeTexture *iface) {
50 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
51 TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
52 return InterlockedIncrement(&This->resource.ref);
55 ULONG WINAPI IWineD3DVolumeTextureImpl_Release(IWineD3DVolumeTexture *iface) {
56 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
59 TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
60 ref = InterlockedDecrement(&This->resource.ref);
62 for (i = 0; i < This->baseTexture.levels; i++) {
63 if (This->volumes[i] != NULL) {
64 /* Since the volumes were created by callback, the texture is
65 * keeping the reference to the parent, so the texture should
67 IUnknown *volumeParent = NULL;
69 TRACE("(%p) : Releasing volume %p\n", This, This->volumes[i]);
71 /* Cleanup the container */
72 IWineD3DVolume_SetContainer(This->volumes[i], 0);
73 /* Now, release the parent, which will take care of cleaning up the volume for us */
74 IWineD3DVolume_GetParent(This->volumes[i], &volumeParent);
75 IUnknown_Release(volumeParent); /* Once for the reference GetParent added */
76 IUnknown_Release(volumeParent); /* Once for the reference we're keeping */
79 IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface);
80 HeapFree(GetProcessHeap(), 0, This);
85 /* ****************************************************
86 IWineD3DVolumeTexture IWineD3DResource parts follow
87 **************************************************** */
88 HRESULT WINAPI IWineD3DVolumeTextureImpl_GetDevice(IWineD3DVolumeTexture *iface, IWineD3DDevice** ppDevice) {
89 return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
92 HRESULT WINAPI IWineD3DVolumeTextureImpl_SetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
93 return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
96 HRESULT WINAPI IWineD3DVolumeTextureImpl_GetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
97 return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
100 HRESULT WINAPI IWineD3DVolumeTextureImpl_FreePrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid) {
101 return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
104 DWORD WINAPI IWineD3DVolumeTextureImpl_SetPriority(IWineD3DVolumeTexture *iface, DWORD PriorityNew) {
105 return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
108 DWORD WINAPI IWineD3DVolumeTextureImpl_GetPriority(IWineD3DVolumeTexture *iface) {
109 return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
112 void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) {
113 /* Overrider the IWineD3DResource Preload method */
115 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
117 TRACE("(%p) : About to load texture\n", This);
119 IWineD3DVolumeTexture_BindTexture(iface);
122 /* If were dirty then reload the volumes */
123 if(This->baseTexture.dirty != FALSE) {
124 for (i = 0; i < This->baseTexture.levels; i++) {
125 IWineD3DVolume_LoadTexture(This->volumes[i], i);
128 /* No longer dirty */
129 This->baseTexture.dirty = FALSE;
136 WINED3DRESOURCETYPE WINAPI IWineD3DVolumeTextureImpl_GetType(IWineD3DVolumeTexture *iface) {
137 return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
140 HRESULT WINAPI IWineD3DVolumeTextureImpl_GetParent(IWineD3DVolumeTexture *iface, IUnknown **pParent) {
141 return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
144 /* ******************************************************
145 IWineD3DVolumeTexture IWineD3DBaseTexture parts follow
146 ****************************************************** */
147 DWORD WINAPI IWineD3DVolumeTextureImpl_SetLOD(IWineD3DVolumeTexture *iface, DWORD LODNew) {
148 return IWineD3DBaseTextureImpl_SetLOD((IWineD3DBaseTexture *)iface, LODNew);
151 DWORD WINAPI IWineD3DVolumeTextureImpl_GetLOD(IWineD3DVolumeTexture *iface) {
152 return IWineD3DBaseTextureImpl_GetLOD((IWineD3DBaseTexture *)iface);
155 DWORD WINAPI IWineD3DVolumeTextureImpl_GetLevelCount(IWineD3DVolumeTexture *iface) {
156 return IWineD3DBaseTextureImpl_GetLevelCount((IWineD3DBaseTexture *)iface);
159 HRESULT WINAPI IWineD3DVolumeTextureImpl_SetAutoGenFilterType(IWineD3DVolumeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
160 return IWineD3DBaseTextureImpl_SetAutoGenFilterType((IWineD3DBaseTexture *)iface, FilterType);
163 WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DVolumeTextureImpl_GetAutoGenFilterType(IWineD3DVolumeTexture *iface) {
164 return IWineD3DBaseTextureImpl_GetAutoGenFilterType((IWineD3DBaseTexture *)iface);
167 void WINAPI IWineD3DVolumeTextureImpl_GenerateMipSubLevels(IWineD3DVolumeTexture *iface) {
168 return IWineD3DBaseTextureImpl_GenerateMipSubLevels((IWineD3DBaseTexture *)iface);
171 /* Internal function, No d3d mapping */
172 BOOL WINAPI IWineD3DVolumeTextureImpl_SetDirty(IWineD3DVolumeTexture *iface, BOOL dirty) {
173 return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, dirty);
176 BOOL WINAPI IWineD3DVolumeTextureImpl_GetDirty(IWineD3DVolumeTexture *iface) {
177 return IWineD3DBaseTextureImpl_GetDirty((IWineD3DBaseTexture *)iface);
180 HRESULT WINAPI IWineD3DVolumeTextureImpl_BindTexture(IWineD3DVolumeTexture *iface) {
181 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
182 TRACE("(%p) : relay to BaseTexture\n", This);
183 return IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface);
186 HRESULT WINAPI IWineD3DVolumeTextureImpl_UnBindTexture(IWineD3DVolumeTexture *iface) {
187 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
188 TRACE("(%p) : relay to BaseTexture\n", This);
189 return IWineD3DBaseTextureImpl_UnBindTexture((IWineD3DBaseTexture *)iface);
192 UINT WINAPI IWineD3DVolumeTextureImpl_GetTextureDimensions(IWineD3DVolumeTexture *iface) {
193 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
194 TRACE("(%p)\n", This);
195 return GL_TEXTURE_3D;
198 void WINAPI IWineD3DVolumeTextureImpl_ApplyStateChanges(IWineD3DVolumeTexture *iface,
199 const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
200 const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
201 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
202 TRACE("(%p) : nothing to do, passing to base texture\n", This);
203 IWineD3DBaseTextureImpl_ApplyStateChanges((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
207 /* *******************************************
208 IWineD3DVolumeTexture IWineD3DVolumeTexture parts follow
209 ******************************************* */
210 HRESULT WINAPI IWineD3DVolumeTextureImpl_GetLevelDesc(IWineD3DVolumeTexture *iface, UINT Level,WINED3DVOLUME_DESC *pDesc) {
211 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
212 if (Level < This->baseTexture.levels) {
213 TRACE("(%p) Level (%d)\n", This, Level);
214 return IWineD3DVolume_GetDesc((IWineD3DVolume *) This->volumes[Level], pDesc);
216 FIXME("(%p) Level (%d)\n", This, Level);
220 HRESULT WINAPI IWineD3DVolumeTextureImpl_GetVolumeLevel(IWineD3DVolumeTexture *iface, UINT Level, IWineD3DVolume** ppVolumeLevel) {
221 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
222 if (Level < This->baseTexture.levels) {
223 *ppVolumeLevel = (IWineD3DVolume *)This->volumes[Level];
224 IWineD3DVolume_AddRef((IWineD3DVolume *) *ppVolumeLevel);
225 TRACE("(%p) -> level(%d) returning volume@%p\n", This, Level, *ppVolumeLevel);
227 FIXME("(%p) Level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
228 return WINED3DERR_INVALIDCALL;
233 HRESULT WINAPI IWineD3DVolumeTextureImpl_LockBox(IWineD3DVolumeTexture *iface, UINT Level, WINED3DLOCKED_BOX* pLockedVolume, CONST WINED3DBOX* pBox, DWORD Flags) {
235 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
237 if (Level < This->baseTexture.levels) {
238 hr = IWineD3DVolume_LockBox((IWineD3DVolume *)This->volumes[Level], pLockedVolume, pBox, Flags);
239 TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
242 FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
243 return WINED3DERR_INVALIDCALL;
248 HRESULT WINAPI IWineD3DVolumeTextureImpl_UnlockBox(IWineD3DVolumeTexture *iface, UINT Level) {
250 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
252 if (Level < This->baseTexture.levels) {
253 hr = IWineD3DVolume_UnlockBox((IWineD3DVolume*) This->volumes[Level]);
254 TRACE("(%p) -> level(%d) success(%lu)\n", This, Level, hr);
257 FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
258 return WINED3DERR_INVALIDCALL;
263 HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTexture *iface, CONST WINED3DBOX* pDirtyBox) {
264 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
265 This->baseTexture.dirty = TRUE;
266 TRACE("(%p) : dirtyfication of volume Level (0)\n", This);
267 return IWineD3DVolume_AddDirtyBox((IWineD3DVolume *) This->volumes[0], pDirtyBox);
270 const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl =
273 IWineD3DVolumeTextureImpl_QueryInterface,
274 IWineD3DVolumeTextureImpl_AddRef,
275 IWineD3DVolumeTextureImpl_Release,
277 IWineD3DVolumeTextureImpl_GetParent,
278 IWineD3DVolumeTextureImpl_GetDevice,
279 IWineD3DVolumeTextureImpl_SetPrivateData,
280 IWineD3DVolumeTextureImpl_GetPrivateData,
281 IWineD3DVolumeTextureImpl_FreePrivateData,
282 IWineD3DVolumeTextureImpl_SetPriority,
283 IWineD3DVolumeTextureImpl_GetPriority,
284 IWineD3DVolumeTextureImpl_PreLoad,
285 IWineD3DVolumeTextureImpl_GetType,
287 IWineD3DVolumeTextureImpl_SetLOD,
288 IWineD3DVolumeTextureImpl_GetLOD,
289 IWineD3DVolumeTextureImpl_GetLevelCount,
290 IWineD3DVolumeTextureImpl_SetAutoGenFilterType,
291 IWineD3DVolumeTextureImpl_GetAutoGenFilterType,
292 IWineD3DVolumeTextureImpl_GenerateMipSubLevels,
293 IWineD3DVolumeTextureImpl_SetDirty,
294 IWineD3DVolumeTextureImpl_GetDirty,
296 IWineD3DVolumeTextureImpl_BindTexture,
297 IWineD3DVolumeTextureImpl_UnBindTexture,
298 IWineD3DVolumeTextureImpl_GetTextureDimensions,
299 IWineD3DVolumeTextureImpl_ApplyStateChanges,
301 IWineD3DVolumeTextureImpl_GetLevelDesc,
302 IWineD3DVolumeTextureImpl_GetVolumeLevel,
303 IWineD3DVolumeTextureImpl_LockBox,
304 IWineD3DVolumeTextureImpl_UnlockBox,
305 IWineD3DVolumeTextureImpl_AddDirtyBox