Reboot (int19) under DOS now does ExitProcess.
[wine.git] / dlls / d3d8 / volumetexture.c
blobb2ac97da132e974622290b2c6d0054b3c295bd8e
1 /*
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
21 #include "config.h"
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "wingdi.h"
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 ICOM_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);
46 *ppobj = This;
47 return D3D_OK;
50 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
51 return E_NOINTERFACE;
54 ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface) {
55 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
56 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
57 return ++(This->ref);
60 ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
61 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
62 ULONG ref = --This->ref;
63 UINT i;
65 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
66 if (ref == 0) {
67 for (i = 0; i < This->levels; i++) {
68 if (This->volumes[i] != NULL) {
69 TRACE("(%p) : Releasing volume %p\n", This, This->volumes[i]);
70 IDirect3DVolume8Impl_Release((LPDIRECT3DVOLUME8) This->volumes[i]);
73 HeapFree(GetProcessHeap(), 0, This);
75 return ref;
78 /* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
79 HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8** ppDevice) {
80 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
81 TRACE("(%p) : returning %p\n", This, This->Device);
82 *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
83 /**
84 * Note Calling this method will increase the internal reference count
85 * on the IDirect3DDevice8 interface.
87 IDirect3DDevice8Impl_AddRef(*ppDevice);
88 return D3D_OK;
90 HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
91 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
92 FIXME("(%p) : stub\n", This);
93 return D3D_OK;
95 HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
96 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
97 FIXME("(%p) : stub\n", This);
98 return D3D_OK;
100 HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
101 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
102 FIXME("(%p) : stub\n", This);
103 return D3D_OK;
105 DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
106 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
107 FIXME("(%p) : stub returning 0\n", This);
108 return 0;
110 DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
111 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
112 FIXME("(%p) : stub returning 0\n", This);
113 return 0;
115 void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
116 int i;
117 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
118 TRACE("(%p) : About to load texture\n", This);
120 ENTER_GL();
122 for (i = 0; i < This->levels; i++) {
123 if (i == 0 && This->volumes[i]->textureName != 0 && This->Dirty == FALSE) {
124 glBindTexture(GL_TEXTURE_3D, This->volumes[i]->textureName);
125 checkGLcall("glBindTexture");
126 TRACE("Texture %p (level %d) given name %d\n", This->volumes[i], i, This->volumes[i]->textureName);
127 /* No need to walk through all mip-map levels, since already all assigned */
128 i = This->levels;
129 } else {
130 if (i == 0) {
131 if (This->volumes[i]->textureName == 0) {
132 glGenTextures(1, &This->volumes[i]->textureName);
133 checkGLcall("glGenTextures");
134 TRACE("Texture %p (level %d) given name %d\n", This->volumes[i], i, This->volumes[i]->textureName);
137 glBindTexture(GL_TEXTURE_3D, This->volumes[i]->textureName);
138 checkGLcall("glBindTexture");
140 TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels - 1);
141 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1);
142 checkGLcall("glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1)");
145 TRACE("Calling glTexImage3D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
146 GL_TEXTURE_3D,
148 D3DFmt2GLIntFmt(This->Device, This->format),
149 This->volumes[i]->myDesc.Width,
150 This->volumes[i]->myDesc.Height,
151 This->volumes[i]->myDesc.Depth,
153 D3DFmt2GLFmt(This->Device, This->format),
154 D3DFmt2GLType(This->Device, This->format),
155 This->volumes[i]->allocatedMemory);
156 glTexImage3D(GL_TEXTURE_3D,
158 D3DFmt2GLIntFmt(This->Device, This->format),
159 This->volumes[i]->myDesc.Width,
160 This->volumes[i]->myDesc.Height,
161 This->volumes[i]->myDesc.Depth,
163 D3DFmt2GLFmt(This->Device, This->format),
164 D3DFmt2GLType(This->Device, This->format),
165 This->volumes[i]->allocatedMemory);
166 checkGLcall("glTexImage3D");
168 /* Removed glTexParameterf now TextureStageStates are initialized at startup */
169 This->Dirty = FALSE;
173 LEAVE_GL();
175 return ;
177 D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
178 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
179 TRACE("(%p) : returning %d\n", This, This->ResourceType);
180 return This->ResourceType;
183 /* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
184 DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
185 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
186 FIXME("(%p) : stub returning 0\n", This);
187 return 0;
189 DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
190 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
191 FIXME("(%p) : stub returning 0\n", This);
192 return 0;
194 DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
195 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
196 TRACE("(%p) : returning %d\n", This, This->levels);
197 return This->levels;
200 /* IDirect3DVolumeTexture8 */
201 HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,D3DVOLUME_DESC *pDesc) {
202 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
203 if (Level < This->levels) {
204 TRACE("(%p) Level (%d)\n", This, Level);
205 return IDirect3DVolume8Impl_GetDesc((LPDIRECT3DVOLUME8) This->volumes[Level], pDesc);
206 } else {
207 FIXME("(%p) Level (%d)\n", This, Level);
209 return D3D_OK;
211 HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8** ppVolumeLevel) {
212 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
213 if (Level < This->levels) {
214 *ppVolumeLevel = (LPDIRECT3DVOLUME8)This->volumes[Level];
215 IDirect3DVolume8Impl_AddRef((LPDIRECT3DVOLUME8) *ppVolumeLevel);
216 TRACE("(%p) -> level(%d) returning volume@%p\n", This, Level, *ppVolumeLevel);
217 } else {
218 FIXME("(%p) Level(%d) overflow Levels(%d)\n", This, Level, This->levels);
219 return D3DERR_INVALIDCALL;
221 return D3D_OK;
224 HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
225 HRESULT hr;
226 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
227 if (Level < This->levels) {
229 * Not dirtified while Surfaces don't notify dirtification
230 * This->Dirty = TRUE;
232 hr = IDirect3DVolume8Impl_LockBox((LPDIRECT3DVOLUME8) This->volumes[Level], pLockedVolume, pBox, Flags);
233 TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
234 } else {
235 FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
236 return D3DERR_INVALIDCALL;
238 return hr;
240 HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
241 HRESULT hr;
242 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
243 if (Level < This->levels) {
244 hr = IDirect3DVolume8Impl_UnlockBox((LPDIRECT3DVOLUME8) This->volumes[Level]);
245 TRACE("(%p) -> level(%d) success(%lu)\n", This, Level, hr);
246 } else {
247 FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
248 return D3DERR_INVALIDCALL;
250 return hr;
252 HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX* pDirtyBox) {
253 ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
254 This->Dirty = TRUE;
255 TRACE("(%p) : dirtyfication of volume Level (0)\n", This);
256 return IDirect3DVolume8Impl_AddDirtyBox((LPDIRECT3DVOLUME8) This->volumes[0], pDirtyBox);
260 ICOM_VTABLE(IDirect3DVolumeTexture8) Direct3DVolumeTexture8_Vtbl =
262 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
263 IDirect3DVolumeTexture8Impl_QueryInterface,
264 IDirect3DVolumeTexture8Impl_AddRef,
265 IDirect3DVolumeTexture8Impl_Release,
266 IDirect3DVolumeTexture8Impl_GetDevice,
267 IDirect3DVolumeTexture8Impl_SetPrivateData,
268 IDirect3DVolumeTexture8Impl_GetPrivateData,
269 IDirect3DVolumeTexture8Impl_FreePrivateData,
270 IDirect3DVolumeTexture8Impl_SetPriority,
271 IDirect3DVolumeTexture8Impl_GetPriority,
272 IDirect3DVolumeTexture8Impl_PreLoad,
273 IDirect3DVolumeTexture8Impl_GetType,
274 IDirect3DVolumeTexture8Impl_SetLOD,
275 IDirect3DVolumeTexture8Impl_GetLOD,
276 IDirect3DVolumeTexture8Impl_GetLevelCount,
277 IDirect3DVolumeTexture8Impl_GetLevelDesc,
278 IDirect3DVolumeTexture8Impl_GetVolumeLevel,
279 IDirect3DVolumeTexture8Impl_LockBox,
280 IDirect3DVolumeTexture8Impl_UnlockBox,
281 IDirect3DVolumeTexture8Impl_AddDirtyBox