2 * IDirect3DVolumeTexture8 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
29 #include "wine/debug.h"
31 #include "d3d8_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
35 /* IDirect3DVolumeTexture8 IUnknown parts follow: */
36 HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface,REFIID riid,LPVOID *ppobj)
38 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
40 TRACE("(%p) : QueryInterface\n", This);
41 if (IsEqualGUID(riid, &IID_IUnknown)
42 || IsEqualGUID(riid, &IID_IDirect3DResource8)
43 || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
44 || IsEqualGUID(riid, &IID_IDirect3DVolumeTexture8)) {
45 IDirect3DVolumeTexture8Impl_AddRef(iface);
50 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
54 ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface) {
55 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
56 ULONG ref = InterlockedIncrement(&This->ref);
58 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
63 ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
64 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
65 ULONG ref = InterlockedDecrement(&This->ref);
68 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
71 for (i = 0; i < This->levels; i++) {
72 if (This->volumes[i] != NULL) {
73 TRACE("(%p) : Releasing volume %p\n", This, This->volumes[i]);
74 IDirect3DVolume8Impl_Release((LPDIRECT3DVOLUME8) This->volumes[i]);
77 HeapFree(GetProcessHeap(), 0, This);
82 /* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
83 HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8** ppDevice) {
84 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
85 TRACE("(%p) : returning %p\n", This, This->Device);
86 *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
88 * Note Calling this method will increase the internal reference count
89 * on the IDirect3DDevice8 interface.
91 IDirect3DDevice8Impl_AddRef(*ppDevice);
94 HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
95 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
96 FIXME("(%p) : stub\n", This);
99 HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
100 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
101 FIXME("(%p) : stub\n", This);
104 HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
105 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
106 FIXME("(%p) : stub\n", This);
109 DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
110 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
111 FIXME("(%p) : stub returning 0\n", This);
114 DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
115 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
116 FIXME("(%p) : stub returning 0\n", This);
119 void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
121 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
122 TRACE("(%p) : About to load texture\n", This);
126 for (i = 0; i < This->levels; i++) {
127 if (i == 0 && This->volumes[i]->textureName != 0 && This->Dirty == FALSE) {
128 glBindTexture(GL_TEXTURE_3D, This->volumes[i]->textureName);
129 checkGLcall("glBindTexture");
130 TRACE("Texture %p (level %d) given name %d\n", This->volumes[i], i, This->volumes[i]->textureName);
131 /* No need to walk through all mip-map levels, since already all assigned */
135 if (This->volumes[i]->textureName == 0) {
136 glGenTextures(1, &This->volumes[i]->textureName);
137 checkGLcall("glGenTextures");
138 TRACE("Texture %p (level %d) given name %d\n", This->volumes[i], i, This->volumes[i]->textureName);
141 glBindTexture(GL_TEXTURE_3D, This->volumes[i]->textureName);
142 checkGLcall("glBindTexture");
144 TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels - 1);
145 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1);
146 checkGLcall("glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1)");
149 TRACE("Calling glTexImage3D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
152 D3DFmt2GLIntFmt(This->Device, This->format),
153 This->volumes[i]->myDesc.Width,
154 This->volumes[i]->myDesc.Height,
155 This->volumes[i]->myDesc.Depth,
157 D3DFmt2GLFmt(This->Device, This->format),
158 D3DFmt2GLType(This->Device, This->format),
159 This->volumes[i]->allocatedMemory);
160 glTexImage3D(GL_TEXTURE_3D,
162 D3DFmt2GLIntFmt(This->Device, This->format),
163 This->volumes[i]->myDesc.Width,
164 This->volumes[i]->myDesc.Height,
165 This->volumes[i]->myDesc.Depth,
167 D3DFmt2GLFmt(This->Device, This->format),
168 D3DFmt2GLType(This->Device, This->format),
169 This->volumes[i]->allocatedMemory);
170 checkGLcall("glTexImage3D");
172 /* Removed glTexParameterf now TextureStageStates are initialized at startup */
181 D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
182 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
183 TRACE("(%p) : returning %d\n", This, This->ResourceType);
184 return This->ResourceType;
187 /* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
188 DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
189 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
190 FIXME("(%p) : stub returning 0\n", This);
193 DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
194 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
195 FIXME("(%p) : stub returning 0\n", This);
198 DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
199 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
200 TRACE("(%p) : returning %d\n", This, This->levels);
204 /* IDirect3DVolumeTexture8 */
205 HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,D3DVOLUME_DESC *pDesc) {
206 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
207 if (Level < This->levels) {
208 TRACE("(%p) Level (%d)\n", This, Level);
209 return IDirect3DVolume8Impl_GetDesc((LPDIRECT3DVOLUME8) This->volumes[Level], pDesc);
211 FIXME("(%p) Level (%d)\n", This, Level);
215 HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8** ppVolumeLevel) {
216 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
217 if (Level < This->levels) {
218 *ppVolumeLevel = (LPDIRECT3DVOLUME8)This->volumes[Level];
219 IDirect3DVolume8Impl_AddRef((LPDIRECT3DVOLUME8) *ppVolumeLevel);
220 TRACE("(%p) -> level(%d) returning volume@%p\n", This, Level, *ppVolumeLevel);
222 FIXME("(%p) Level(%d) overflow Levels(%d)\n", This, Level, This->levels);
223 return D3DERR_INVALIDCALL;
228 HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
230 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
231 if (Level < This->levels) {
233 * Not dirtified while Surfaces don't notify dirtification
234 * This->Dirty = TRUE;
236 hr = IDirect3DVolume8Impl_LockBox((LPDIRECT3DVOLUME8) This->volumes[Level], pLockedVolume, pBox, Flags);
237 TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
239 FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
240 return D3DERR_INVALIDCALL;
244 HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
246 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
247 if (Level < This->levels) {
248 hr = IDirect3DVolume8Impl_UnlockBox((LPDIRECT3DVOLUME8) This->volumes[Level]);
249 TRACE("(%p) -> level(%d) success(%lu)\n", This, Level, hr);
251 FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
252 return D3DERR_INVALIDCALL;
256 HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX* pDirtyBox) {
257 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
259 TRACE("(%p) : dirtyfication of volume Level (0)\n", This);
260 return IDirect3DVolume8Impl_AddDirtyBox((LPDIRECT3DVOLUME8) This->volumes[0], pDirtyBox);
264 IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =
266 IDirect3DVolumeTexture8Impl_QueryInterface,
267 IDirect3DVolumeTexture8Impl_AddRef,
268 IDirect3DVolumeTexture8Impl_Release,
269 IDirect3DVolumeTexture8Impl_GetDevice,
270 IDirect3DVolumeTexture8Impl_SetPrivateData,
271 IDirect3DVolumeTexture8Impl_GetPrivateData,
272 IDirect3DVolumeTexture8Impl_FreePrivateData,
273 IDirect3DVolumeTexture8Impl_SetPriority,
274 IDirect3DVolumeTexture8Impl_GetPriority,
275 IDirect3DVolumeTexture8Impl_PreLoad,
276 IDirect3DVolumeTexture8Impl_GetType,
277 IDirect3DVolumeTexture8Impl_SetLOD,
278 IDirect3DVolumeTexture8Impl_GetLOD,
279 IDirect3DVolumeTexture8Impl_GetLevelCount,
280 IDirect3DVolumeTexture8Impl_GetLevelDesc,
281 IDirect3DVolumeTexture8Impl_GetVolumeLevel,
282 IDirect3DVolumeTexture8Impl_LockBox,
283 IDirect3DVolumeTexture8Impl_UnlockBox,
284 IDirect3DVolumeTexture8Impl_AddDirtyBox