2 * Copyright (c) 1998-2004 Lionel Ulmer
3 * Copyright (c) 2002-2005 Christian Costa
4 * Copyright (c) 2006 Stefan Dösinger
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * IDirect3DDevice implementation, version 1, 2, 3 and 7. Rendering is relayed
21 * to WineD3D, some minimal DirectDraw specific management is handled here.
22 * The Direct3DDevice is NOT the parent of the WineD3DDevice, because d3d
23 * is initialized when DirectDraw creates the primary surface.
24 * Some type management is necessary, because some D3D types changed between
30 #include "wine/port.h"
31 #include "wine/debug.h"
44 #include "wine/exception.h"
49 #include "ddraw_private.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
52 WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
55 const GUID IID_D3DDEVICE_WineD3D = {
59 { 0xb7,0x98,0xc6,0x8a,0x77,0x2d,0x72,0x2a }
62 /*****************************************************************************
63 * IUnknown Methods. Common for Version 1, 2, 3 and 7
64 *****************************************************************************/
66 /*****************************************************************************
67 * IDirect3DDevice7::QueryInterface
69 * Used to query other interfaces from a Direct3DDevice interface.
70 * It can return interface pointers to all Direct3DDevice versions as well
71 * as IDirectDraw and IDirect3D. For a link to QueryInterface
72 * rules see ddraw.c, IDirectDraw7::QueryInterface
74 * Exists in Version 1, 2, 3 and 7
77 * refiid: Interface ID queried for
78 * obj: Used to return the interface pointer
81 * D3D_OK or E_NOINTERFACE
83 *****************************************************************************/
85 IDirect3DDeviceImpl_7_QueryInterface(IDirect3DDevice7 *iface,
89 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
90 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(refiid), obj);
92 /* According to COM docs, if the QueryInterface fails, obj should be set to NULL */
96 return DDERR_INVALIDPARAMS;
98 if ( IsEqualGUID( &IID_IUnknown, refiid ) )
100 *obj = ICOM_INTERFACE(This, IDirect3DDevice7);
103 /* Check DirectDraw Interfac
\ 1s */
104 else if( IsEqualGUID( &IID_IDirectDraw7, refiid ) )
106 *obj = ICOM_INTERFACE(This->ddraw, IDirectDraw7);
107 TRACE("(%p) Returning IDirectDraw7 interface at %p\n", This, *obj);
109 else if ( IsEqualGUID( &IID_IDirectDraw4, refiid ) )
111 *obj = ICOM_INTERFACE(This->ddraw, IDirectDraw4);
112 TRACE("(%p) Returning IDirectDraw4 interface at %p\n", This, *obj);
114 else if ( IsEqualGUID( &IID_IDirectDraw2, refiid ) )
116 *obj = ICOM_INTERFACE(This->ddraw, IDirectDraw2);
117 TRACE("(%p) Returning IDirectDraw2 interface at %p\n", This, *obj);
119 else if( IsEqualGUID( &IID_IDirectDraw, refiid ) )
121 *obj = ICOM_INTERFACE(This->ddraw, IDirectDraw);
122 TRACE("(%p) Returning IDirectDraw interface at %p\n", This, *obj);
126 else if ( IsEqualGUID( &IID_IDirect3D , refiid ) )
128 *obj = ICOM_INTERFACE(This->ddraw, IDirect3D);
129 TRACE("(%p) Returning IDirect3D interface at %p\n", This, *obj);
131 else if ( IsEqualGUID( &IID_IDirect3D2 , refiid ) )
133 *obj = ICOM_INTERFACE(This->ddraw, IDirect3D2);
134 TRACE("(%p) Returning IDirect3D2 interface at %p\n", This, *obj);
136 else if ( IsEqualGUID( &IID_IDirect3D3 , refiid ) )
138 *obj = ICOM_INTERFACE(This->ddraw, IDirect3D3);
139 TRACE("(%p) Returning IDirect3D3 interface at %p\n", This, *obj);
141 else if ( IsEqualGUID( &IID_IDirect3D7 , refiid ) )
143 *obj = ICOM_INTERFACE(This->ddraw, IDirect3D7);
144 TRACE("(%p) Returning IDirect3D7 interface at %p\n", This, *obj);
148 else if ( IsEqualGUID( &IID_IDirect3DDevice , refiid ) )
150 *obj = ICOM_INTERFACE(This, IDirect3DDevice);
151 TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This, *obj);
153 else if ( IsEqualGUID( &IID_IDirect3DDevice2 , refiid ) ) {
154 *obj = ICOM_INTERFACE(This, IDirect3DDevice2);
155 TRACE("(%p) Returning IDirect3DDevice2 interface at %p\n", This, *obj);
157 else if ( IsEqualGUID( &IID_IDirect3DDevice3 , refiid ) ) {
158 *obj = ICOM_INTERFACE(This, IDirect3DDevice3);
159 TRACE("(%p) Returning IDirect3DDevice3 interface at %p\n", This, *obj);
161 else if ( IsEqualGUID( &IID_IDirect3DDevice7 , refiid ) ) {
162 *obj = ICOM_INTERFACE(This, IDirect3DDevice7);
163 TRACE("(%p) Returning IDirect3DDevice7 interface at %p\n", This, *obj);
166 /* Unknown interface */
169 ERR("(%p)->(%s, %p): No interface found\n", This, debugstr_guid(refiid), obj);
170 return E_NOINTERFACE;
173 /* AddRef the returned interface */
174 IUnknown_AddRef( (IUnknown *) *obj);
178 static HRESULT WINAPI
179 Thunk_IDirect3DDeviceImpl_3_QueryInterface(IDirect3DDevice3 *iface,
183 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
184 TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", This, debugstr_guid(riid), obj);
185 return IDirect3DDevice7_QueryInterface(ICOM_INTERFACE(This, IDirect3DDevice7),
190 static HRESULT WINAPI
191 Thunk_IDirect3DDeviceImpl_2_QueryInterface(IDirect3DDevice2 *iface,
195 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
196 TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", This, debugstr_guid(riid), obj);
197 return IDirect3DDevice7_QueryInterface(ICOM_INTERFACE(This, IDirect3DDevice7),
202 static HRESULT WINAPI
203 Thunk_IDirect3DDeviceImpl_1_QueryInterface(IDirect3DDevice *iface,
207 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
208 TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", This, debugstr_guid(riid), obp);
209 return IDirect3DDevice7_QueryInterface(ICOM_INTERFACE(This, IDirect3DDevice7),
214 /*****************************************************************************
215 * IDirect3DDevice7::AddRef
217 * Increases the refcount....
218 * The most exciting Method, definitely
220 * Exists in Version 1, 2, 3 and 7
225 *****************************************************************************/
227 IDirect3DDeviceImpl_7_AddRef(IDirect3DDevice7 *iface)
229 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
230 ULONG ref = InterlockedIncrement(&This->ref);
232 TRACE("(%p) : incrementing from %u.\n", This, ref -1);
238 Thunk_IDirect3DDeviceImpl_3_AddRef(IDirect3DDevice3 *iface)
240 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
241 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
242 return IDirect3DDevice7_AddRef(ICOM_INTERFACE(This, IDirect3DDevice7));
246 Thunk_IDirect3DDeviceImpl_2_AddRef(IDirect3DDevice2 *iface)
248 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
249 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
250 return IDirect3DDevice7_AddRef(ICOM_INTERFACE(This, IDirect3DDevice7));
254 Thunk_IDirect3DDeviceImpl_1_AddRef(IDirect3DDevice *iface)
256 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface);
257 return IDirect3DDevice7_AddRef(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice7, iface));
260 /*****************************************************************************
261 * IDirect3DDevice7::Release
263 * Decreases the refcount of the interface
264 * When the refcount is reduced to 0, the object is destroyed.
266 * Exists in Version 1, 2, 3 and 7
271 *****************************************************************************/
273 IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
275 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
276 ULONG ref = InterlockedDecrement(&This->ref);
278 TRACE("(%p)->() decrementing from %u.\n", This, ref +1);
280 /* This method doesn't destroy the WineD3DDevice, because it's still in use for
281 * 2D rendering. IDirectDrawSurface7::Release will destroy the WineD3DDevice
282 * when the render target is released
286 IParent *IndexBufferParent;
289 /* Free the index buffer. */
290 IWineD3DDevice_SetIndices(This->wineD3DDevice,
293 IWineD3DIndexBuffer_GetParent(This->indexbuffer,
294 (IUnknown **) &IndexBufferParent);
295 IParent_Release(IndexBufferParent); /* Once for the getParent */
296 if( IParent_Release(IndexBufferParent) != 0) /* And now to destroy it */
298 ERR(" (%p) Something is still holding the index buffer parent %p\n", This, IndexBufferParent);
301 /* There is no need to unset the vertex buffer here, IWineD3DDevice_Uninit3D will do that when
302 * destroying the primary stateblock. If a vertex buffer is destroyed while it is bound
303 * IDirect3DVertexBuffer::Release will unset it.
306 /* Restore the render targets */
307 if(This->OffScreenTarget)
313 vp.Width = This->ddraw->d3d_target->surface_desc.dwWidth;
314 vp.Height = This->ddraw->d3d_target->surface_desc.dwHeight;
317 IWineD3DDevice_SetViewport(This->wineD3DDevice,
320 /* Set the device up to render to the front buffer since the back buffer will
323 IWineD3DDevice_SetRenderTarget(This->wineD3DDevice, 0,
324 This->ddraw->d3d_target->WineD3DSurface);
325 /* This->target is the offscreen target.
326 * This->ddraw->d3d_target is the target used by DDraw
328 TRACE("(%p) Release: Using %p as front buffer, %p as back buffer\n", This, This->ddraw->d3d_target, NULL);
329 IWineD3DDevice_SetFrontBackBuffers(This->wineD3DDevice,
330 This->ddraw->d3d_target->WineD3DSurface,
334 /* Release the WineD3DDevice. This won't destroy it */
335 if(IWineD3DDevice_Release(This->wineD3DDevice) <= 0)
337 ERR(" (%p) The wineD3D device %p was destroyed unexpectadely. Prepare for trouble\n", This, This->wineD3DDevice);
340 /* The texture handles should be unset by now, but there might be some bits
341 * missing in our reference counting(needs test). Do a sanity check
343 for(i = 0; i < This->numHandles; i++)
345 if(This->Handles[i].ptr)
347 switch(This->Handles[i].type)
349 case DDrawHandle_Texture:
351 IDirectDrawSurfaceImpl *surf = (IDirectDrawSurfaceImpl *) This->Handles[i].ptr;
352 FIXME("Texture Handle %d not unset properly\n", i + 1);
357 case DDrawHandle_Material:
359 IDirect3DMaterialImpl *mat = (IDirect3DMaterialImpl *) This->Handles[i].ptr;
360 FIXME("Material handle %d not unset properly\n", i + 1);
365 case DDrawHandle_Matrix:
367 /* No fixme here because this might happen because of sloppy apps */
368 WARN("Leftover matrix handle %d, deleting\n", i + 1);
369 IDirect3DDevice_DeleteMatrix(ICOM_INTERFACE(This, IDirect3DDevice),
374 case DDrawHandle_StateBlock:
376 /* No fixme here because this might happen because of sloppy apps */
377 WARN("Leftover stateblock handle %d, deleting\n", i + 1);
378 IDirect3DDevice7_DeleteStateBlock(ICOM_INTERFACE(This, IDirect3DDevice7),
384 FIXME("Unknown handle %d not unset properly\n", i + 1);
389 HeapFree(GetProcessHeap(), 0, This->Handles);
391 TRACE("Releasing target %p %p\n", This->target, This->ddraw->d3d_target);
392 /* Release the render target and the WineD3D render target
393 * (See IDirect3D7::CreateDevice for more comments on this)
395 IDirectDrawSurface7_Release(ICOM_INTERFACE(This->target, IDirectDrawSurface7));
396 IDirectDrawSurface7_Release(ICOM_INTERFACE(This->ddraw->d3d_target,IDirectDrawSurface7));
397 TRACE("Target release done\n");
399 This->ddraw->d3ddevice = NULL;
401 /* Now free the structure */
402 HeapFree(GetProcessHeap(), 0, This);
410 Thunk_IDirect3DDeviceImpl_3_Release(IDirect3DDevice3 *iface)
412 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
413 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
414 return IDirect3DDevice7_Release(ICOM_INTERFACE(This, IDirect3DDevice7));
418 Thunk_IDirect3DDeviceImpl_2_Release(IDirect3DDevice2 *iface)
420 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
421 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
422 return IDirect3DDevice7_Release(ICOM_INTERFACE(This, IDirect3DDevice7));
426 Thunk_IDirect3DDeviceImpl_1_Release(IDirect3DDevice *iface)
428 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
429 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
430 return IDirect3DDevice7_Release(ICOM_INTERFACE(This, IDirect3DDevice7));
433 /*****************************************************************************
434 * IDirect3DDevice Methods
435 *****************************************************************************/
437 /*****************************************************************************
438 * IDirect3DDevice::Initialize
440 * Initializes a Direct3DDevice. This implementation is a no-op, as all
441 * initialization is done at create time.
443 * Exists in Version 1
446 * No idea what they mean, as the MSDN page is gone
450 *****************************************************************************/
451 static HRESULT WINAPI
452 IDirect3DDeviceImpl_1_Initialize(IDirect3DDevice *iface,
453 IDirect3D *Direct3D, GUID *guid,
456 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
458 /* It shouldn't be crucial, but print a FIXME, I'm interested if
459 * any game calls it and when
461 FIXME("(%p)->(%p,%p,%p): No-op!\n", This, Direct3D, guid, Desc);
466 /*****************************************************************************
467 * IDirect3DDevice7::GetCaps
469 * Retrieves the device's capabilities
471 * This implementation is used for Version 7 only, the older versions have
472 * their own implementation.
475 * Desc: Pointer to a D3DDEVICEDESC7 structure to fill
479 * D3DERR_* if a problem occurs. See WineD3D
481 *****************************************************************************/
482 static HRESULT WINAPI
483 IDirect3DDeviceImpl_7_GetCaps(IDirect3DDevice7 *iface,
484 D3DDEVICEDESC7 *Desc)
486 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
487 D3DDEVICEDESC OldDesc;
488 TRACE("(%p)->(%p)\n", This, Desc);
490 /* Call the same function used by IDirect3D, this saves code */
491 return IDirect3DImpl_GetCaps(This->ddraw->wineD3D, &OldDesc, Desc);
494 /*****************************************************************************
495 * IDirect3DDevice3::GetCaps
497 * Retrieves the capabilities of the hardware device and the emulation
498 * device. For Wine, hardware and emulation are the same (it's all HW).
500 * This implementation is used for Version 1, 2, and 3. Version 7 has its own
503 * HWDesc: Structure to fill with the HW caps
504 * HelDesc: Structure to fill with the hardare emulation caps
508 * D3DERR_* if a problem occurs. See WineD3D
510 *****************************************************************************/
511 static HRESULT WINAPI
512 IDirect3DDeviceImpl_3_GetCaps(IDirect3DDevice3 *iface,
513 D3DDEVICEDESC *HWDesc,
514 D3DDEVICEDESC *HelDesc)
516 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
517 D3DDEVICEDESC7 newDesc;
519 TRACE("(%p)->(%p,%p)\n", iface, HWDesc, HelDesc);
521 hr = IDirect3DImpl_GetCaps(This->ddraw->wineD3D, HWDesc, &newDesc);
522 if(hr != D3D_OK) return hr;
528 static HRESULT WINAPI
529 Thunk_IDirect3DDeviceImpl_2_GetCaps(IDirect3DDevice2 *iface,
530 D3DDEVICEDESC *D3DHWDevDesc,
531 D3DDEVICEDESC *D3DHELDevDesc)
533 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
534 TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DDevice3 interface.\n", This, D3DHWDevDesc, D3DHELDevDesc);
535 return IDirect3DDevice3_GetCaps(ICOM_INTERFACE(This, IDirect3DDevice3),
540 static HRESULT WINAPI
541 Thunk_IDirect3DDeviceImpl_1_GetCaps(IDirect3DDevice *iface,
542 D3DDEVICEDESC *D3DHWDevDesc,
543 D3DDEVICEDESC *D3DHELDevDesc)
545 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
546 TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DDevice3 interface.\n", This, D3DHWDevDesc, D3DHELDevDesc);
547 return IDirect3DDevice3_GetCaps(ICOM_INTERFACE(This, IDirect3DDevice3),
552 /*****************************************************************************
553 * IDirect3DDevice2::SwapTextureHandles
555 * Swaps the texture handles of 2 Texture interfaces. Version 1 and 2
558 * Tex1, Tex2: The 2 Textures to swap
563 *****************************************************************************/
564 static HRESULT WINAPI
565 IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2 *iface,
566 IDirect3DTexture2 *Tex1,
567 IDirect3DTexture2 *Tex2)
569 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
571 IDirectDrawSurfaceImpl *surf1 = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture2, Tex1);
572 IDirectDrawSurfaceImpl *surf2 = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture2, Tex2);
573 TRACE("(%p)->(%p,%p)\n", This, surf1, surf2);
575 This->Handles[surf1->Handle - 1].ptr = surf2;
576 This->Handles[surf2->Handle - 1].ptr = surf1;
578 swap = surf2->Handle;
579 surf2->Handle = surf1->Handle;
580 surf1->Handle = swap;
585 static HRESULT WINAPI
586 Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles(IDirect3DDevice *iface,
587 IDirect3DTexture *D3DTex1,
588 IDirect3DTexture *D3DTex2)
590 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
591 IDirectDrawSurfaceImpl *surf1 = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture, D3DTex1);
592 IDirectDrawSurfaceImpl *surf2 = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture, D3DTex2);
593 TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", This, surf1, surf2);
594 return IDirect3DDevice2_SwapTextureHandles(ICOM_INTERFACE(This, IDirect3DDevice2),
595 ICOM_INTERFACE(surf1, IDirect3DTexture2),
596 ICOM_INTERFACE(surf2, IDirect3DTexture2));
599 /*****************************************************************************
600 * IDirect3DDevice3::GetStats
602 * This method seems to retrieve some stats from the device.
603 * The MSDN documentation doesn't exist any more, but the D3DSTATS
604 * structure suggests that the amout of drawn primitives and processed
605 * vertices is returned.
607 * Exists in Version 1, 2 and 3
610 * Stats: Pointer to a D3DSTATS structure to be filled
614 * DDERR_INVALIDPARAMS if Stats == NULL
616 *****************************************************************************/
617 static HRESULT WINAPI
618 IDirect3DDeviceImpl_3_GetStats(IDirect3DDevice3 *iface,
621 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
622 FIXME("(%p)->(%p): Stub!\n", This, Stats);
625 return DDERR_INVALIDPARAMS;
627 /* Fill the Stats with 0 */
628 Stats->dwTrianglesDrawn = 0;
629 Stats->dwLinesDrawn = 0;
630 Stats->dwPointsDrawn = 0;
631 Stats->dwSpansDrawn = 0;
632 Stats->dwVerticesProcessed = 0;
637 static HRESULT WINAPI
638 Thunk_IDirect3DDeviceImpl_2_GetStats(IDirect3DDevice2 *iface,
641 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
642 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, Stats);
643 return IDirect3DDevice3_GetStats(ICOM_INTERFACE(This, IDirect3DDevice3),
647 static HRESULT WINAPI
648 Thunk_IDirect3DDeviceImpl_1_GetStats(IDirect3DDevice *iface,
651 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
652 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, Stats);
653 return IDirect3DDevice3_GetStats(ICOM_INTERFACE(This, IDirect3DDevice3),
657 /*****************************************************************************
658 * IDirect3DDevice::CreateExecuteBuffer
660 * Creates an IDirect3DExecuteBuffer, used for rendering with a
666 * Desc: Buffer description
667 * ExecuteBuffer: Address to return the Interface pointer at
668 * UnkOuter: Must be NULL. Basically for aggregation, which ddraw doesn't
672 * CLASS_E_NOAGGREGATION if UnkOuter != NULL
673 * DDERR_OUTOFMEMORY if we ran out of memory
676 *****************************************************************************/
677 static HRESULT WINAPI
678 IDirect3DDeviceImpl_1_CreateExecuteBuffer(IDirect3DDevice *iface,
679 D3DEXECUTEBUFFERDESC *Desc,
680 IDirect3DExecuteBuffer **ExecuteBuffer,
683 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
684 IDirect3DExecuteBufferImpl* object;
685 TRACE("(%p)->(%p,%p,%p)!\n", This, Desc, ExecuteBuffer, UnkOuter);
688 return CLASS_E_NOAGGREGATION;
690 /* Allocate the new Execute Buffer */
691 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DExecuteBufferImpl));
694 ERR("Out of memory when allocating a IDirect3DExecuteBufferImpl structure\n");
695 return DDERR_OUTOFMEMORY;
698 ICOM_INIT_INTERFACE(object, IDirect3DExecuteBuffer, IDirect3DExecuteBuffer_Vtbl);
701 object->d3ddev = This;
703 /* Initializes memory */
704 memcpy(&object->desc, Desc, Desc->dwSize);
706 /* No buffer given */
707 if ((object->desc.dwFlags & D3DDEB_LPDATA) == 0)
708 object->desc.lpData = NULL;
710 /* No buffer size given */
711 if ((object->desc.dwFlags & D3DDEB_BUFSIZE) == 0)
712 object->desc.dwBufferSize = 0;
714 /* Create buffer if asked */
715 if ((object->desc.lpData == NULL) && (object->desc.dwBufferSize > 0))
717 object->need_free = TRUE;
718 object->desc.lpData = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,object->desc.dwBufferSize);
719 if(!object->desc.lpData)
721 ERR("Out of memory when allocating the execute buffer data\n");
722 HeapFree(GetProcessHeap(), 0, object);
723 return DDERR_OUTOFMEMORY;
728 object->need_free = FALSE;
731 /* No vertices for the moment */
732 object->vertex_data = NULL;
734 object->desc.dwFlags |= D3DDEB_LPDATA;
736 object->indices = NULL;
737 object->nb_indices = 0;
739 *ExecuteBuffer = ICOM_INTERFACE(object, IDirect3DExecuteBuffer);
741 TRACE(" Returning IDirect3DExecuteBuffer at %p, implementation is at %p\n", *ExecuteBuffer, object);
746 /*****************************************************************************
747 * IDirect3DDevice::Execute
749 * Executes all the stuff in an execute buffer.
752 * ExecuteBuffer: The buffer to execute
753 * Viewport: The viewport used for rendering
757 * DDERR_INVALIDPARAMS if ExecuteBuffer == NULL
760 *****************************************************************************/
761 static HRESULT WINAPI
762 IDirect3DDeviceImpl_1_Execute(IDirect3DDevice *iface,
763 IDirect3DExecuteBuffer *ExecuteBuffer,
764 IDirect3DViewport *Viewport,
767 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
768 IDirect3DExecuteBufferImpl *Direct3DExecuteBufferImpl = ICOM_OBJECT(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, ExecuteBuffer);
769 IDirect3DViewportImpl *Direct3DViewportImpl = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport);
771 TRACE("(%p)->(%p,%p,%08x)\n", This, Direct3DExecuteBufferImpl, Direct3DViewportImpl, Flags);
773 if(!Direct3DExecuteBufferImpl)
774 return DDERR_INVALIDPARAMS;
777 IDirect3DExecuteBufferImpl_Execute(Direct3DExecuteBufferImpl, This, Direct3DViewportImpl);
782 /*****************************************************************************
783 * IDirect3DDevice3::AddViewport
785 * Add a Direct3DViewport to the device's viewport list. These viewports
786 * are wrapped to IDirect3DDevice7 viewports in viewport.c
788 * Exists in Version 1, 2 and 3. Note that IDirect3DViewport 1, 2 and 3
789 * are the same interfaces.
792 * Viewport: The viewport to add
795 * DDERR_INVALIDPARAMS if Viewport == NULL
798 *****************************************************************************/
799 static HRESULT WINAPI
800 IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3 *iface,
801 IDirect3DViewport3 *Viewport)
803 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
804 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport);
806 TRACE("(%p)->(%p)\n", This, vp);
810 return DDERR_INVALIDPARAMS;
812 vp->next = This->viewport_list;
813 This->viewport_list = vp;
818 static HRESULT WINAPI
819 Thunk_IDirect3DDeviceImpl_2_AddViewport(IDirect3DDevice2 *iface,
820 IDirect3DViewport2 *Direct3DViewport2)
822 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
823 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport2);
824 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, vp);
825 return IDirect3DDevice3_AddViewport(ICOM_INTERFACE(This, IDirect3DDevice3),
826 ICOM_INTERFACE(vp, IDirect3DViewport3));
829 static HRESULT WINAPI
830 Thunk_IDirect3DDeviceImpl_1_AddViewport(IDirect3DDevice *iface,
831 IDirect3DViewport *Direct3DViewport)
833 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
834 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport);
835 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, vp);
836 return IDirect3DDevice3_AddViewport(ICOM_INTERFACE(This, IDirect3DDevice3),
837 ICOM_INTERFACE(vp, IDirect3DViewport3));
840 /*****************************************************************************
841 * IDirect3DDevice3::DeleteViewport
843 * Deletes a Direct3DViewport from the device's viewport list.
845 * Exists in Version 1, 2 and 3. Note that all Viewport interface versions
849 * Viewport: The viewport to delete
853 * DDERR_INVALIDPARAMS if the viewport wasn't found in the list
855 *****************************************************************************/
856 static HRESULT WINAPI
857 IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3 *iface,
858 IDirect3DViewport3 *Viewport)
860 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
861 IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *) Viewport;
862 IDirect3DViewportImpl *cur_viewport, *prev_viewport = NULL;
864 TRACE("(%p)->(%p)\n", This, vp);
866 cur_viewport = This->viewport_list;
867 while (cur_viewport != NULL)
869 if (cur_viewport == vp)
871 if (prev_viewport == NULL) This->viewport_list = cur_viewport->next;
872 else prev_viewport->next = cur_viewport->next;
873 /* TODO : add desactivate of the viewport and all associated lights... */
876 prev_viewport = cur_viewport;
877 cur_viewport = cur_viewport->next;
880 return DDERR_INVALIDPARAMS;
883 static HRESULT WINAPI
884 Thunk_IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2 *iface,
885 IDirect3DViewport2 *Direct3DViewport2)
887 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
888 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport2);
889 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, vp);
890 return IDirect3DDevice3_DeleteViewport(ICOM_INTERFACE(This, IDirect3DDevice3),
891 ICOM_INTERFACE(vp, IDirect3DViewport3));
894 static HRESULT WINAPI
895 Thunk_IDirect3DDeviceImpl_1_DeleteViewport(IDirect3DDevice *iface,
896 IDirect3DViewport *Direct3DViewport)
898 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
899 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport);
900 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, vp);
901 return IDirect3DDevice3_DeleteViewport(ICOM_INTERFACE(This, IDirect3DDevice3),
902 ICOM_INTERFACE(vp, IDirect3DViewport3));
905 /*****************************************************************************
906 * IDirect3DDevice3::NextViewport
908 * Returns a viewport from the viewport list, depending on the
909 * passed viewport and the flags.
911 * Exists in Version 1, 2 and 3. Note that all Viewport interface versions
915 * Viewport: Viewport to use for beginning the search
916 * Flags: D3DNEXT_NEXT, D3DNEXT_HEAD or D3DNEXT_TAIL
920 * DDERR_INVALIDPARAMS if the flags were wrong, or Viewport was NULL
922 *****************************************************************************/
923 static HRESULT WINAPI
924 IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
925 IDirect3DViewport3 *Viewport3,
926 IDirect3DViewport3 **lplpDirect3DViewport3,
929 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
930 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport3);
931 IDirect3DViewportImpl *res = NULL;
933 TRACE("(%p)->(%p,%p,%08x)\n", This, vp, lplpDirect3DViewport3, Flags);
937 *lplpDirect3DViewport3 = NULL;
938 return DDERR_INVALIDPARAMS;
951 res = This->viewport_list;
956 IDirect3DViewportImpl *cur_viewport = This->viewport_list;
957 if (cur_viewport != NULL)
959 while (cur_viewport->next != NULL) cur_viewport = cur_viewport->next;
965 *lplpDirect3DViewport3 = NULL;
966 return DDERR_INVALIDPARAMS;
969 *lplpDirect3DViewport3 = ICOM_INTERFACE(res, IDirect3DViewport3);
973 static HRESULT WINAPI
974 Thunk_IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2 *iface,
975 IDirect3DViewport2 *Viewport2,
976 IDirect3DViewport2 **lplpDirect3DViewport2,
979 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
980 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport2);
981 IDirect3DViewport3 *res;
983 TRACE_(ddraw_thunk)("(%p)->(%p,%p,%08x) thunking to IDirect3DDevice3 interface.\n", This, vp, lplpDirect3DViewport2, Flags);
984 hr = IDirect3DDevice3_NextViewport(ICOM_INTERFACE(This, IDirect3DDevice3),
985 ICOM_INTERFACE(vp, IDirect3DViewport3),
988 *lplpDirect3DViewport2 = (IDirect3DViewport2 *) COM_INTERFACE_CAST(IDirect3DViewportImpl, IDirect3DViewport3, IDirect3DViewport3, res);
992 static HRESULT WINAPI
993 Thunk_IDirect3DDeviceImpl_1_NextViewport(IDirect3DDevice *iface,
994 IDirect3DViewport *Viewport,
995 IDirect3DViewport **lplpDirect3DViewport,
998 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
999 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport);
1000 IDirect3DViewport3 *res;
1002 TRACE_(ddraw_thunk)("(%p)->(%p,%p,%08x) thunking to IDirect3DDevice3 interface.\n", This, vp, lplpDirect3DViewport, Flags);
1003 hr = IDirect3DDevice3_NextViewport(ICOM_INTERFACE(This, IDirect3DDevice3),
1004 ICOM_INTERFACE(vp, IDirect3DViewport3),
1007 *lplpDirect3DViewport = (IDirect3DViewport *) COM_INTERFACE_CAST(IDirect3DViewportImpl, IDirect3DViewport3, IDirect3DViewport3, res);
1011 /*****************************************************************************
1012 * IDirect3DDevice::Pick
1014 * Executes an execute buffer without performing rendering. Instead, a
1015 * list of primitives that intersect with (x1,y1) of the passed rectangle
1016 * is created. IDirect3DDevice::GetPickRecords can be used to retrieve
1022 * ExecuteBuffer: Buffer to execute
1023 * Viewport: Viewport to use for execution
1024 * Flags: None are defined, according to the SDK
1025 * Rect: Specifies the coordinates to be picked. Only x1 and y2 are used,
1026 * x2 and y2 are ignored.
1029 * D3D_OK because it's a stub
1031 *****************************************************************************/
1032 static HRESULT WINAPI
1033 IDirect3DDeviceImpl_1_Pick(IDirect3DDevice *iface,
1034 IDirect3DExecuteBuffer *ExecuteBuffer,
1035 IDirect3DViewport *Viewport,
1039 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
1040 IDirect3DExecuteBufferImpl *execbuf = ICOM_OBJECT(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, ExecuteBuffer);
1041 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Viewport);
1042 FIXME("(%p)->(%p,%p,%08x,%p): stub!\n", This, execbuf, vp, Flags, Rect);
1047 /*****************************************************************************
1048 * IDirect3DDevice::GetPickRecords
1050 * Retrieves the pick records generated by IDirect3DDevice::GetPickRecords
1055 * Count: Pointer to a DWORD containing the numbers of pick records to
1057 * D3DPickRec: Address to store the resulting D3DPICKRECORD arry.
1060 * D3D_OK, because it's a stub
1062 *****************************************************************************/
1063 static HRESULT WINAPI
1064 IDirect3DDeviceImpl_1_GetPickRecords(IDirect3DDevice *iface,
1066 D3DPICKRECORD *D3DPickRec)
1068 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
1069 FIXME("(%p)->(%p,%p): stub!\n", This, Count, D3DPickRec);
1074 /*****************************************************************************
1075 * IDirect3DDevice7::EnumTextureformats
1077 * Enumerates the supported texture formats. It has a list of all possible
1078 * formats and calls IWineD3D::CheckDeviceFormat for each format to see if
1079 * WineD3D supports it. If so, then it is passed to the app.
1081 * This is for Version 7 and 3, older versions have a different
1082 * callback function and their own implementation
1085 * Callback: Callback to call for each enumerated format
1086 * Arg: Argument to pass to the callback
1090 * DDERR_INVALIDPARAMS if Callback == NULL
1092 *****************************************************************************/
1093 static HRESULT WINAPI
1094 IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
1095 LPD3DENUMPIXELFORMATSCALLBACK Callback,
1098 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
1102 WINED3DFORMAT FormatList[] = {
1104 WINED3DFMT_A8R8G8B8,
1105 WINED3DFMT_X8R8G8B8,
1109 WINED3DFMT_A1R5G5B5,
1110 WINED3DFMT_A4R4G4B4,
1112 WINED3DFMT_X1R5G5B5,
1122 WINED3DFORMAT BumpFormatList[] = {
1125 WINED3DFMT_X8L8V8U8,
1126 WINED3DFMT_Q8W8V8U8,
1128 WINED3DFMT_W11V11U10,
1129 WINED3DFMT_A2W10V10U10
1132 TRACE("(%p)->(%p,%p): Relay\n", This, Callback, Arg);
1135 return DDERR_INVALIDPARAMS;
1137 for(i = 0; i < sizeof(FormatList) / sizeof(WINED3DFORMAT); i++)
1139 hr = IWineD3D_CheckDeviceFormat(This->ddraw->wineD3D,
1142 0 /* AdapterFormat */,
1144 0 /* ResourceType */,
1148 DDPIXELFORMAT pformat;
1150 memset(&pformat, 0, sizeof(pformat));
1151 pformat.dwSize = sizeof(pformat);
1152 PixelFormat_WineD3DtoDD(&pformat, FormatList[i]);
1154 TRACE("Enumerating WineD3DFormat %d\n", FormatList[i]);
1155 hr = Callback(&pformat, Arg);
1156 if(hr != DDENUMRET_OK)
1158 TRACE("Format enumeration cancelled by application\n");
1164 for(i = 0; i < sizeof(BumpFormatList) / sizeof(WINED3DFORMAT); i++)
1166 hr = IWineD3D_CheckDeviceFormat(This->ddraw->wineD3D,
1169 0 /* AdapterFormat */,
1170 WINED3DUSAGE_QUERY_LEGACYBUMPMAP,
1171 0 /* ResourceType */,
1175 DDPIXELFORMAT pformat;
1177 memset(&pformat, 0, sizeof(pformat));
1178 pformat.dwSize = sizeof(pformat);
1179 PixelFormat_WineD3DtoDD(&pformat, BumpFormatList[i]);
1181 TRACE("Enumerating WineD3DFormat %d\n", BumpFormatList[i]);
1182 hr = Callback(&pformat, Arg);
1183 if(hr != DDENUMRET_OK)
1185 TRACE("Format enumeration cancelled by application\n");
1190 TRACE("End of enumeration\n");
1194 static HRESULT WINAPI
1195 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats(IDirect3DDevice3 *iface,
1196 LPD3DENUMPIXELFORMATSCALLBACK Callback,
1199 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1200 TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DDevice7 interface.\n", This, Callback, Arg);
1201 return IDirect3DDevice7_EnumTextureFormats(ICOM_INTERFACE(This, IDirect3DDevice7),
1206 /*****************************************************************************
1207 * IDirect3DDevice2::EnumTextureformats
1209 * EnumTextureFormats for Version 1 and 2, see
1210 * IDirect3DDevice7::EnumTexureFormats for a more detailed description.
1212 * This version has a different callback and does not enumerate FourCC
1215 *****************************************************************************/
1216 static HRESULT WINAPI
1217 IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,
1218 LPD3DENUMTEXTUREFORMATSCALLBACK Callback,
1221 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
1225 WINED3DFORMAT FormatList[] = {
1227 WINED3DFMT_A8R8G8B8,
1228 WINED3DFMT_X8R8G8B8,
1232 WINED3DFMT_A1R5G5B5,
1233 WINED3DFMT_A4R4G4B4,
1235 WINED3DFMT_X1R5G5B5,
1239 /* FOURCC codes - Not in this version*/
1242 TRACE("(%p)->(%p,%p): Relay\n", This, Callback, Arg);
1245 return DDERR_INVALIDPARAMS;
1247 for(i = 0; i < sizeof(FormatList) / sizeof(WINED3DFORMAT); i++)
1249 hr = IWineD3D_CheckDeviceFormat(This->ddraw->wineD3D,
1252 0 /* AdapterFormat */,
1254 0 /* ResourceType */,
1258 DDSURFACEDESC sdesc;
1260 memset(&sdesc, 0, sizeof(sdesc));
1261 sdesc.dwSize = sizeof(sdesc);
1262 sdesc.dwFlags = DDSD_PIXELFORMAT | DDSD_CAPS;
1263 sdesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
1264 sdesc.ddpfPixelFormat.dwSize = sizeof(sdesc.ddpfPixelFormat);
1265 PixelFormat_WineD3DtoDD(&sdesc.ddpfPixelFormat, FormatList[i]);
1267 TRACE("Enumerating WineD3DFormat %d\n", FormatList[i]);
1268 hr = Callback(&sdesc, Arg);
1269 if(hr != DDENUMRET_OK)
1271 TRACE("Format enumeration cancelled by application\n");
1276 TRACE("End of enumeration\n");
1280 static HRESULT WINAPI
1281 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats(IDirect3DDevice *iface,
1282 LPD3DENUMTEXTUREFORMATSCALLBACK Callback,
1285 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
1286 TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", This, Callback, Arg);
1287 return IDirect3DDevice2_EnumTextureFormats(ICOM_INTERFACE(This, IDirect3DDevice2),
1292 /*****************************************************************************
1293 * IDirect3DDevice::CreateMatrix
1295 * Creates a matrix handle. A handle is created and memory for a D3DMATRIX is
1296 * allocated for the handle.
1301 * D3DMatHandle: Address to return the handle at
1305 * DDERR_INVALIDPARAMS if D3DMatHandle = NULL
1307 *****************************************************************************/
1308 static HRESULT WINAPI
1309 IDirect3DDeviceImpl_1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE *D3DMatHandle)
1311 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
1313 TRACE("(%p)->(%p)\n", This, D3DMatHandle);
1316 return DDERR_INVALIDPARAMS;
1318 Matrix = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D3DMATRIX));
1321 ERR("Out of memory when allocating a D3DMATRIX\n");
1322 return DDERR_OUTOFMEMORY;
1324 *D3DMatHandle = IDirect3DDeviceImpl_CreateHandle(This);
1325 if(!(*D3DMatHandle))
1327 ERR("Failed to create a matrix handle\n");
1328 HeapFree(GetProcessHeap(), 0, Matrix);
1329 return DDERR_OUTOFMEMORY;
1331 This->Handles[(DWORD) *D3DMatHandle - 1].ptr = Matrix;
1332 This->Handles[(DWORD) *D3DMatHandle - 1].type = DDrawHandle_Matrix;
1333 TRACE(" returning matrix handle %d\n", *D3DMatHandle);
1338 /*****************************************************************************
1339 * IDirect3DDevice::SetMatrix
1341 * Sets a matrix for a matrix handle. The matrix is copied into the memory
1342 * allocated for the handle
1347 * D3DMatHandle: Handle to set the matrix to
1348 * D3DMatrix: Matrix to set
1352 * DDERR_INVALIDPARAMS if the handle of the matrix is invalid or the matrix
1355 *****************************************************************************/
1356 static HRESULT WINAPI
1357 IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice *iface,
1358 D3DMATRIXHANDLE D3DMatHandle,
1359 D3DMATRIX *D3DMatrix)
1361 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
1362 TRACE("(%p)->(%08x,%p)\n", This, (DWORD) D3DMatHandle, D3DMatrix);
1364 if( (!D3DMatHandle) || (!D3DMatrix) )
1365 return DDERR_INVALIDPARAMS;
1367 if(D3DMatHandle > This->numHandles)
1369 ERR("Handle %d out of range\n", D3DMatHandle);
1370 return DDERR_INVALIDPARAMS;
1372 else if(This->Handles[D3DMatHandle - 1].type != DDrawHandle_Matrix)
1374 ERR("Handle %d is not a matrix handle\n", D3DMatHandle);
1375 return DDERR_INVALIDPARAMS;
1379 dump_D3DMATRIX(D3DMatrix);
1381 *((D3DMATRIX *) This->Handles[D3DMatHandle - 1].ptr) = *D3DMatrix;
1386 /*****************************************************************************
1387 * IDirect3DDevice::SetMatrix
1389 * Returns the content of a D3DMATRIX handle
1394 * D3DMatHandle: Matrix handle to read the content from
1395 * D3DMatrix: Address to store the content at
1399 * DDERR_INVALIDPARAMS if D3DMatHandle is invalid or D3DMatrix is NULL
1401 *****************************************************************************/
1402 static HRESULT WINAPI
1403 IDirect3DDeviceImpl_1_GetMatrix(IDirect3DDevice *iface,
1404 D3DMATRIXHANDLE D3DMatHandle,
1405 D3DMATRIX *D3DMatrix)
1407 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
1408 TRACE("(%p)->(%08x,%p)\n", This, (DWORD) D3DMatHandle, D3DMatrix);
1411 return DDERR_INVALIDPARAMS;
1413 return DDERR_INVALIDPARAMS;
1415 if(D3DMatHandle > This->numHandles)
1417 ERR("Handle %d out of range\n", D3DMatHandle);
1418 return DDERR_INVALIDPARAMS;
1420 else if(This->Handles[D3DMatHandle - 1].type != DDrawHandle_Matrix)
1422 ERR("Handle %d is not a matrix handle\n", D3DMatHandle);
1423 return DDERR_INVALIDPARAMS;
1426 /* The handle is simply a pointer to a D3DMATRIX structure */
1427 *D3DMatrix = *((D3DMATRIX *) This->Handles[D3DMatHandle - 1].ptr);
1432 /*****************************************************************************
1433 * IDirect3DDevice::DeleteMatrix
1435 * Destroys a Matrix handle. Frees the memory and unsets the handle data
1440 * D3DMatHandle: Handle to destroy
1444 * DDERR_INVALIDPARAMS if D3DMatHandle is invalid
1446 *****************************************************************************/
1447 static HRESULT WINAPI
1448 IDirect3DDeviceImpl_1_DeleteMatrix(IDirect3DDevice *iface,
1449 D3DMATRIXHANDLE D3DMatHandle)
1451 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
1452 TRACE("(%p)->(%08x)\n", This, (DWORD) D3DMatHandle);
1455 return DDERR_INVALIDPARAMS;
1457 if(D3DMatHandle > This->numHandles)
1459 ERR("Handle %d out of range\n", D3DMatHandle);
1460 return DDERR_INVALIDPARAMS;
1462 else if(This->Handles[D3DMatHandle - 1].type != DDrawHandle_Matrix)
1464 ERR("Handle %d is not a matrix handle\n", D3DMatHandle);
1465 return DDERR_INVALIDPARAMS;
1468 HeapFree(GetProcessHeap(), 0, This->Handles[D3DMatHandle - 1].ptr);
1469 This->Handles[D3DMatHandle - 1].ptr = NULL;
1470 This->Handles[D3DMatHandle - 1].type = DDrawHandle_Unknown;
1475 /*****************************************************************************
1476 * IDirect3DDevice7::BeginScene
1478 * This method must be called before any rendering is performed.
1479 * IDirect3DDevice::EndScene has to be called after the scene is complete
1481 * Version 1, 2, 3 and 7
1484 * D3D_OK on success, for details see IWineD3DDevice::BeginScene
1485 * D3DERR_SCENE_IN_SCENE if WineD3D returns an error(Only in case of an already
1488 *****************************************************************************/
1489 static HRESULT WINAPI
1490 IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7 *iface)
1492 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
1494 TRACE("(%p): Relay\n", This);
1496 hr = IWineD3DDevice_BeginScene(This->wineD3DDevice);
1497 if(hr == WINED3D_OK) return D3D_OK;
1498 else return D3DERR_SCENE_IN_SCENE; /* TODO: Other possible causes of failure */
1501 static HRESULT WINAPI
1502 Thunk_IDirect3DDeviceImpl_3_BeginScene(IDirect3DDevice3 *iface)
1504 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1505 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
1506 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This, IDirect3DDevice7));
1509 static HRESULT WINAPI
1510 Thunk_IDirect3DDeviceImpl_2_BeginScene(IDirect3DDevice2 *iface)
1512 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
1513 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
1514 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This, IDirect3DDevice7));
1517 static HRESULT WINAPI
1518 Thunk_IDirect3DDeviceImpl_1_BeginScene(IDirect3DDevice *iface)
1520 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
1521 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
1522 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This, IDirect3DDevice7));
1525 /*****************************************************************************
1526 * IDirect3DDevice7::EndScene
1528 * Ends a scene that has been begun with IDirect3DDevice7::BeginScene.
1529 * This method must be called after rendering is finished.
1531 * Version 1, 2, 3 and 7
1534 * D3D_OK on success, for details see IWineD3DDevice::EndScene
1535 * D3DERR_SCENE_NOT_IN_SCENE is returned if WineD3D returns an error. It does
1536 * that only if the scene was already ended.
1538 *****************************************************************************/
1539 static HRESULT WINAPI
1540 IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7 *iface)
1542 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
1544 TRACE("(%p): Relay\n", This);
1546 hr = IWineD3DDevice_EndScene(This->wineD3DDevice);
1547 if(hr == WINED3D_OK) return D3D_OK;
1548 else return D3DERR_SCENE_NOT_IN_SCENE;
1551 static HRESULT WINAPI
1552 Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3 *iface)
1554 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1555 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
1556 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This, IDirect3DDevice7));
1559 static HRESULT WINAPI
1560 Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2 *iface)
1562 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
1563 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
1564 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This, IDirect3DDevice7));
1567 static HRESULT WINAPI
1568 Thunk_IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice *iface)
1570 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
1571 TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This);
1572 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This, IDirect3DDevice7));
1575 /*****************************************************************************
1576 * IDirect3DDevice7::GetDirect3D
1578 * Returns the IDirect3D(= interface to the DirectDraw object) used to create
1582 * Direct3D7: Address to store the interface pointer at
1586 * DDERR_INVALIDPARAMS if Direct3D7 == NULL
1588 *****************************************************************************/
1589 static HRESULT WINAPI
1590 IDirect3DDeviceImpl_7_GetDirect3D(IDirect3DDevice7 *iface,
1591 IDirect3D7 **Direct3D7)
1593 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
1594 TRACE("(%p)->(%p)\n", This, Direct3D7);
1597 return DDERR_INVALIDPARAMS;
1599 *Direct3D7 = ICOM_INTERFACE(This->ddraw, IDirect3D7);
1600 IDirect3D7_AddRef(*Direct3D7);
1602 TRACE(" returning interface %p\n", *Direct3D7);
1606 static HRESULT WINAPI
1607 Thunk_IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3 *iface,
1608 IDirect3D3 **Direct3D3)
1610 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1612 IDirect3D7 *ret_ptr;
1614 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, Direct3D3);
1615 ret = IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This, IDirect3DDevice7),
1619 *Direct3D3 = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D3, ret_ptr);
1620 TRACE(" returning interface %p\n", *Direct3D3);
1624 static HRESULT WINAPI
1625 Thunk_IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2 *iface,
1626 IDirect3D2 **Direct3D2)
1628 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
1630 IDirect3D7 *ret_ptr;
1632 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, Direct3D2);
1633 ret = IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This, IDirect3DDevice7),
1637 *Direct3D2 = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D2, ret_ptr);
1638 TRACE(" returning interface %p\n", *Direct3D2);
1642 static HRESULT WINAPI
1643 Thunk_IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice *iface,
1644 IDirect3D **Direct3D)
1646 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface);
1648 IDirect3D7 *ret_ptr;
1650 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, Direct3D);
1651 ret = IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This, IDirect3DDevice7),
1655 *Direct3D = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D, ret_ptr);
1656 TRACE(" returning interface %p\n", *Direct3D);
1660 /*****************************************************************************
1661 * IDirect3DDevice3::SetCurrentViewport
1663 * Sets a Direct3DViewport as the current viewport.
1664 * For the thunks note that all viewport interface versions are equal
1667 * Direct3DViewport3: The viewport to set
1673 * (Is a NULL viewport valid?)
1675 *****************************************************************************/
1676 static HRESULT WINAPI
1677 IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3 *iface,
1678 IDirect3DViewport3 *Direct3DViewport3)
1680 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1681 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport3);
1682 TRACE("(%p)->(%p)\n", This, Direct3DViewport3);
1684 /* Do nothing if the specified viewport is the same as the current one */
1685 if (This->current_viewport == vp )
1688 /* Should check if the viewport was added or not */
1690 /* Release previous viewport and AddRef the new one */
1691 if (This->current_viewport)
1693 TRACE("ViewportImpl is at %p, interface is at %p\n", This->current_viewport, ICOM_INTERFACE(This->current_viewport, IDirect3DViewport3));
1694 IDirect3DViewport3_Release( ICOM_INTERFACE(This->current_viewport, IDirect3DViewport3) );
1696 IDirect3DViewport3_AddRef(Direct3DViewport3);
1698 /* Set this viewport as the current viewport */
1699 This->current_viewport = vp;
1701 /* Activate this viewport */
1702 This->current_viewport->active_device = This;
1703 This->current_viewport->activate(This->current_viewport);
1708 static HRESULT WINAPI
1709 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2 *iface,
1710 IDirect3DViewport2 *Direct3DViewport2)
1712 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
1713 IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, Direct3DViewport2);
1714 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, vp);
1715 return IDirect3DDevice3_SetCurrentViewport(ICOM_INTERFACE(This, IDirect3DDevice3),
1716 ICOM_INTERFACE(vp, IDirect3DViewport3));
1719 /*****************************************************************************
1720 * IDirect3DDevice3::GetCurrentViewport
1722 * Returns the currently active viewport.
1727 * Direct3DViewport3: Address to return the interface pointer at
1731 * DDERR_INVALIDPARAMS if Direct3DViewport == NULL
1733 *****************************************************************************/
1734 static HRESULT WINAPI
1735 IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3 *iface,
1736 IDirect3DViewport3 **Direct3DViewport3)
1738 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1739 TRACE("(%p)->(%p)\n", This, Direct3DViewport3);
1741 if(!Direct3DViewport3)
1742 return DDERR_INVALIDPARAMS;
1744 *Direct3DViewport3 = ICOM_INTERFACE(This->current_viewport, IDirect3DViewport3);
1746 /* AddRef the returned viewport */
1747 if(*Direct3DViewport3) IDirect3DViewport3_AddRef(*Direct3DViewport3);
1749 TRACE(" returning interface %p\n", *Direct3DViewport3);
1754 static HRESULT WINAPI
1755 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(IDirect3DDevice2 *iface,
1756 IDirect3DViewport2 **Direct3DViewport2)
1758 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1760 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, Direct3DViewport2);
1761 hr = IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This, IDirect3DDevice3),
1762 (IDirect3DViewport3 **) Direct3DViewport2);
1763 if(hr != D3D_OK) return hr;
1764 *Direct3DViewport2 = (IDirect3DViewport2 *) COM_INTERFACE_CAST(IDirect3DViewportImpl, IDirect3DViewport3, IDirect3DViewport3, *Direct3DViewport2);
1768 /*****************************************************************************
1769 * IDirect3DDevice7::SetRenderTarget
1771 * Sets the render target for the Direct3DDevice.
1772 * For the thunks note that IDirectDrawSurface7 == IDirectDrawSurface4 and
1773 * IDirectDrawSurface3 == IDirectDrawSurface
1775 * Version 2, 3 and 7
1778 * NewTarget: Pointer to an IDirectDrawSurface7 interface to set as the new
1783 * D3D_OK on success, for details see IWineD3DDevice::SetRenderTarget
1785 *****************************************************************************/
1786 static HRESULT WINAPI
1787 IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7 *iface,
1788 IDirectDrawSurface7 *NewTarget,
1791 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
1792 IDirectDrawSurfaceImpl *Target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, NewTarget);
1794 TRACE("(%p)->(%p,%08x): Relay\n", This, NewTarget, Flags);
1796 /* Flags: Not used */
1798 hr = IWineD3DDevice_SetRenderTarget(This->wineD3DDevice,
1800 Target ? Target->WineD3DSurface : NULL);
1805 IDirectDrawSurface7_AddRef(NewTarget);
1806 IDirectDrawSurface7_Release(ICOM_INTERFACE(This->target, IDirectDrawSurface7));
1807 This->target = Target;
1808 IDirect3DDeviceImpl_UpdateDepthStencil(This);
1812 static HRESULT WINAPI
1813 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3 *iface,
1814 IDirectDrawSurface4 *NewRenderTarget,
1817 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1818 IDirectDrawSurfaceImpl *Target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, NewRenderTarget);
1819 TRACE_(ddraw_thunk)("(%p)->(%p,%08x) thunking to IDirect3DDevice7 interface.\n", This, Target, Flags);
1820 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This, IDirect3DDevice7),
1821 ICOM_INTERFACE(Target, IDirectDrawSurface7),
1825 static HRESULT WINAPI
1826 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2 *iface,
1827 IDirectDrawSurface *NewRenderTarget,
1830 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
1831 IDirectDrawSurfaceImpl *Target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface3, NewRenderTarget);
1832 TRACE_(ddraw_thunk)("(%p)->(%p,%08x) thunking to IDirect3DDevice7 interface.\n", This, Target, Flags);
1833 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This, IDirect3DDevice7),
1834 ICOM_INTERFACE(Target, IDirectDrawSurface7),
1838 /*****************************************************************************
1839 * IDirect3DDevice7::GetRenderTarget
1841 * Returns the current render target.
1842 * This is handled locally, because the WineD3D render target's parent
1845 * Version 2, 3 and 7
1848 * RenderTarget: Address to store the surface interface pointer
1852 * DDERR_INVALIDPARAMS if RenderTarget == NULL
1854 *****************************************************************************/
1855 static HRESULT WINAPI
1856 IDirect3DDeviceImpl_7_GetRenderTarget(IDirect3DDevice7 *iface,
1857 IDirectDrawSurface7 **RenderTarget)
1859 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
1860 TRACE("(%p)->(%p): Relay\n", This, RenderTarget);
1863 return DDERR_INVALIDPARAMS;
1865 *RenderTarget = ICOM_INTERFACE(This->target, IDirectDrawSurface7);
1866 IDirectDrawSurface7_AddRef(*RenderTarget);
1871 static HRESULT WINAPI
1872 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3 *iface,
1873 IDirectDrawSurface4 **RenderTarget)
1875 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1877 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, RenderTarget);
1878 hr = IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This, IDirect3DDevice7),
1879 (IDirectDrawSurface7 **) RenderTarget);
1880 if(hr != D3D_OK) return hr;
1881 *RenderTarget = (IDirectDrawSurface4 *) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7, IDirectDrawSurface7, *RenderTarget);
1885 static HRESULT WINAPI
1886 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(IDirect3DDevice2 *iface,
1887 IDirectDrawSurface **RenderTarget)
1889 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
1891 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, RenderTarget);
1892 hr = IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This, IDirect3DDevice7),
1893 (IDirectDrawSurface7 **) RenderTarget);
1894 if(hr != D3D_OK) return hr;
1895 *RenderTarget = (IDirectDrawSurface *) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7, IDirectDrawSurface3, *RenderTarget);
1899 /*****************************************************************************
1900 * IDirect3DDevice3::Begin
1902 * Begins a description block of vertices. This is similar to glBegin()
1903 * and glEnd(). After a call to IDirect3DDevice3::End, the vertices
1904 * described with IDirect3DDevice::Vertex are drawn.
1909 * PrimitiveType: The type of primitives to draw
1910 * VertexTypeDesc: A flexible vertex format description of the vertices
1911 * Flags: Some flags..
1916 *****************************************************************************/
1917 static HRESULT WINAPI
1918 IDirect3DDeviceImpl_3_Begin(IDirect3DDevice3 *iface,
1919 D3DPRIMITIVETYPE PrimitiveType,
1920 DWORD VertexTypeDesc,
1923 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1924 TRACE("(%p)->(%d,%d,%08x)\n", This, PrimitiveType, VertexTypeDesc, Flags);
1926 This->primitive_type = PrimitiveType;
1927 This->vertex_type = VertexTypeDesc;
1928 This->render_flags = Flags;
1929 This->vertex_size = get_flexible_vertex_size(This->vertex_type);
1930 This->nb_vertices = 0;
1935 static HRESULT WINAPI
1936 Thunk_IDirect3DDeviceImpl_2_Begin(IDirect3DDevice2 *iface,
1937 D3DPRIMITIVETYPE d3dpt,
1938 D3DVERTEXTYPE dwVertexTypeDesc,
1942 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
1943 TRACE_(ddraw_thunk)("(%p/%p)->(%08x,%08x,%08x): Thunking to IDirect3DDevice3\n", This, iface, d3dpt, dwVertexTypeDesc, dwFlags);
1945 switch(dwVertexTypeDesc)
1947 case D3DVT_VERTEX: FVF = D3DFVF_VERTEX; break;
1948 case D3DVT_LVERTEX: FVF = D3DFVF_LVERTEX; break;
1949 case D3DVT_TLVERTEX: FVF = D3DFVF_TLVERTEX; break;
1951 ERR("Unexpected vertex type %d\n", dwVertexTypeDesc);
1952 return DDERR_INVALIDPARAMS; /* Should never happen */
1955 return IDirect3DDevice3_Begin(ICOM_INTERFACE(This, IDirect3DDevice3),
1961 /*****************************************************************************
1962 * IDirect3DDevice3::BeginIndexed
1964 * Draws primitives based on vertices in a vertex array which are specified
1970 * PrimitiveType: Primitive type to draw
1971 * VertexType: A FVF description of the vertex format
1972 * Vertices: pointer to an array containing the vertices
1973 * NumVertices: The number of vertices in the vertex array
1974 * Flags: Some flags ...
1977 * D3D_OK, because it's a stub
1979 *****************************************************************************/
1980 static HRESULT WINAPI
1981 IDirect3DDeviceImpl_3_BeginIndexed(IDirect3DDevice3 *iface,
1982 D3DPRIMITIVETYPE PrimitiveType,
1988 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
1989 FIXME("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This, PrimitiveType, VertexType, Vertices, NumVertices, Flags);
1994 static HRESULT WINAPI
1995 Thunk_IDirect3DDeviceImpl_2_BeginIndexed(IDirect3DDevice2 *iface,
1996 D3DPRIMITIVETYPE d3dptPrimitiveType,
1997 D3DVERTEXTYPE d3dvtVertexType,
1999 DWORD dwNumVertices,
2003 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2004 TRACE_(ddraw_thunk)("(%p/%p)->(%08x,%08x,%p,%08x,%08x): Thunking to IDirect3DDevice3\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwNumVertices, dwFlags);
2006 switch(d3dvtVertexType)
2008 case D3DVT_VERTEX: FVF = D3DFVF_VERTEX; break;
2009 case D3DVT_LVERTEX: FVF = D3DFVF_LVERTEX; break;
2010 case D3DVT_TLVERTEX: FVF = D3DFVF_TLVERTEX; break;
2012 ERR("Unexpected vertex type %d\n", d3dvtVertexType);
2013 return DDERR_INVALIDPARAMS; /* Should never happen */
2016 return IDirect3DDevice3_BeginIndexed(ICOM_INTERFACE(This,IDirect3DDevice3),
2024 /*****************************************************************************
2025 * IDirect3DDevice3::Vertex
2027 * Draws a vertex as described by IDirect3DDevice3::Begin. It places all
2028 * drawn vertices in a vertex buffer. If the buffer is too small, its
2029 * size is increased.
2034 * Vertex: Pointer to the vertex
2037 * D3D_OK, on success
2038 * DDERR_INVALIDPARAMS if Vertex is NULL
2040 *****************************************************************************/
2041 static HRESULT WINAPI
2042 IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3 *iface,
2045 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
2046 TRACE("(%p)->(%p)\n", This, Vertex);
2049 return DDERR_INVALIDPARAMS;
2051 if ((This->nb_vertices+1)*This->vertex_size > This->buffer_size)
2054 This->buffer_size = This->buffer_size ? This->buffer_size * 2 : This->vertex_size * 3;
2055 old_buffer = This->vertex_buffer;
2056 This->vertex_buffer = HeapAlloc(GetProcessHeap(), 0, This->buffer_size);
2059 CopyMemory(This->vertex_buffer, old_buffer, This->nb_vertices * This->vertex_size);
2060 HeapFree(GetProcessHeap(), 0, old_buffer);
2064 CopyMemory(This->vertex_buffer + This->nb_vertices++ * This->vertex_size, Vertex, This->vertex_size);
2069 static HRESULT WINAPI
2070 Thunk_IDirect3DDeviceImpl_2_Vertex(IDirect3DDevice2 *iface,
2073 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2074 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This, lpVertexType);
2075 return IDirect3DDevice3_Vertex(ICOM_INTERFACE(This, IDirect3DDevice3),
2079 /*****************************************************************************
2080 * IDirect3DDevice3::Index
2082 * Specifies an index to a vertex to be drawn. The vertex array has to
2083 * be specified with BeginIndexed first.
2086 * VertexIndex: The index of the vertex to draw
2089 * D3D_OK because it's a stub
2091 *****************************************************************************/
2092 static HRESULT WINAPI
2093 IDirect3DDeviceImpl_3_Index(IDirect3DDevice3 *iface,
2096 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
2097 FIXME("(%p)->(%04x): stub!\n", This, VertexIndex);
2101 static HRESULT WINAPI
2102 Thunk_IDirect3DDeviceImpl_2_Index(IDirect3DDevice2 *iface,
2105 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2106 TRACE_(ddraw_thunk)("(%p)->(%04x) thunking to IDirect3DDevice3 interface.\n", This, wVertexIndex);
2107 return IDirect3DDevice3_Index(ICOM_INTERFACE(This, IDirect3DDevice3),
2111 /*****************************************************************************
2112 * IDirect3DDevice3::End
2114 * Ends a draw begun with IDirect3DDevice3::Begin or
2115 * IDirect3DDevice::BeginIndexed. The vertices specified with
2116 * IDirect3DDevice::Vertex or IDirect3DDevice::Index are drawn using
2117 * the IDirect3DDevice7::DrawPrimitive method. So far only
2118 * non-indexed mode is supported
2123 * Flags: Some flags, as usual. Don't know which are defined
2126 * The return value of IDirect3DDevice7::DrawPrimitive
2128 *****************************************************************************/
2129 static HRESULT WINAPI
2130 IDirect3DDeviceImpl_3_End(IDirect3DDevice3 *iface,
2133 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
2134 TRACE("(%p)->(%08x)\n", This, Flags);
2136 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This, IDirect3DDevice7),
2137 This->primitive_type, This->vertex_type,
2138 This->vertex_buffer, This->nb_vertices,
2139 This->render_flags);
2142 static HRESULT WINAPI
2143 Thunk_IDirect3DDeviceImpl_2_End(IDirect3DDevice2 *iface,
2146 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2147 TRACE_(ddraw_thunk)("(%p)->(%08x) thunking to IDirect3DDevice3 interface.\n", This, dwFlags);
2148 return IDirect3DDevice3_End(ICOM_INTERFACE(This, IDirect3DDevice3),
2152 /*****************************************************************************
2153 * IDirect3DDevice7::GetRenderState
2155 * Returns the value of a render state. The possible render states are
2156 * defined in include/d3dtypes.h
2158 * Version 2, 3 and 7
2161 * RenderStateType: Render state to return the current setting of
2162 * Value: Address to store the value at
2165 * D3D_OK on success, for details see IWineD3DDevice::GetRenderState
2166 * DDERR_INVALIDPARAMS if Value == NULL
2168 *****************************************************************************/
2169 static HRESULT WINAPI
2170 IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
2171 D3DRENDERSTATETYPE RenderStateType,
2174 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
2176 TRACE("(%p)->(%08x,%p): Relay\n", This, RenderStateType, Value);
2179 return DDERR_INVALIDPARAMS;
2181 switch(RenderStateType)
2183 case D3DRENDERSTATE_TEXTUREHANDLE:
2185 /* This state is wrapped to SetTexture in SetRenderState, so
2186 * it has to be wrapped to GetTexture here
2188 IWineD3DBaseTexture *tex = NULL;
2191 hr = IWineD3DDevice_GetTexture(This->wineD3DDevice,
2195 if(hr == WINED3D_OK && tex)
2197 IDirectDrawSurface7 *parent = NULL;
2198 hr = IWineD3DBaseTexture_GetParent(tex,
2199 (IUnknown **) &parent);
2202 /* The parent of the texture is the IDirectDrawSurface7 interface
2203 * of the ddraw surface
2205 IDirectDrawSurfaceImpl *texImpl = ICOM_OBJECT(IDirectDrawSurfaceImpl,
2206 IDirectDrawSurface7,
2208 *Value = texImpl->Handle;
2209 IDirectDrawSurface7_Release(parent);
2211 IWineD3DBaseTexture_Release(tex);
2216 case D3DRENDERSTATE_TEXTUREMAG:
2218 WINED3DTEXTUREFILTERTYPE tex_mag;
2220 hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
2221 0, WINED3DSAMP_MAGFILTER,
2226 case WINED3DTEXF_POINT:
2227 *Value = D3DFILTER_NEAREST;
2229 case WINED3DTEXF_LINEAR:
2230 *Value = D3DFILTER_LINEAR;
2233 ERR("Unhandled texture mag %d !\n",tex_mag);
2239 case D3DRENDERSTATE_TEXTUREMIN:
2241 WINED3DTEXTUREFILTERTYPE tex_min;
2243 hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
2244 0, WINED3DSAMP_MINFILTER,
2249 case WINED3DTEXF_POINT:
2250 *Value = D3DFILTER_NEAREST;
2252 case WINED3DTEXF_LINEAR:
2253 *Value = D3DFILTER_LINEAR;
2256 ERR("Unhandled texture mag %d !\n",tex_min);
2262 case D3DRENDERSTATE_TEXTUREADDRESS:
2263 case D3DRENDERSTATE_TEXTUREADDRESSU:
2264 return IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
2265 0, WINED3DSAMP_ADDRESSU,
2267 case D3DRENDERSTATE_TEXTUREADDRESSV:
2268 return IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
2269 0, WINED3DSAMP_ADDRESSV,
2273 /* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
2274 return IWineD3DDevice_GetRenderState(This->wineD3DDevice,
2280 static HRESULT WINAPI
2281 Thunk_IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
2282 D3DRENDERSTATETYPE dwRenderStateType,
2283 DWORD *lpdwRenderState)
2285 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
2286 TRACE_(ddraw_thunk)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This, dwRenderStateType, lpdwRenderState);
2287 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This, IDirect3DDevice7),
2292 static HRESULT WINAPI
2293 Thunk_IDirect3DDeviceImpl_2_GetRenderState(IDirect3DDevice2 *iface,
2294 D3DRENDERSTATETYPE dwRenderStateType,
2295 DWORD *lpdwRenderState)
2297 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2298 TRACE_(ddraw_thunk)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This, dwRenderStateType, lpdwRenderState);
2299 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This, IDirect3DDevice7),
2304 /*****************************************************************************
2305 * IDirect3DDevice7::SetRenderState
2307 * Sets a render state. The possible render states are defined in
2308 * include/d3dtypes.h
2310 * Version 2, 3 and 7
2313 * RenderStateType: State to set
2314 * Value: Value to assign to that state
2317 * D3D_OK on success,
2318 * for details see IWineD3DDevice::SetRenderState
2320 *****************************************************************************/
2321 static HRESULT WINAPI
2322 IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
2323 D3DRENDERSTATETYPE RenderStateType,
2326 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
2327 TRACE("(%p)->(%08x,%d): Relay\n", This, RenderStateType, Value);
2329 /* Some render states need special care */
2330 switch(RenderStateType)
2332 case D3DRENDERSTATE_TEXTUREHANDLE:
2336 return IWineD3DDevice_SetTexture(This->wineD3DDevice,
2341 if(Value > This->numHandles)
2343 FIXME("Specified handle %d out of range\n", Value);
2344 return DDERR_INVALIDPARAMS;
2346 if(This->Handles[Value - 1].type != DDrawHandle_Texture)
2348 FIXME("Handle %d isn't a texture handle\n", Value);
2349 return DDERR_INVALIDPARAMS;
2353 IDirectDrawSurfaceImpl *surf = (IDirectDrawSurfaceImpl *) This->Handles[Value - 1].ptr;
2354 return IWineD3DDevice_SetTexture(This->wineD3DDevice,
2356 surf->wineD3DTexture);
2360 case D3DRENDERSTATE_TEXTUREMAG:
2362 WINED3DTEXTUREFILTERTYPE tex_mag = WINED3DTEXF_NONE;
2364 switch ((D3DTEXTUREFILTER) Value)
2366 case D3DFILTER_NEAREST:
2367 case D3DFILTER_LINEARMIPNEAREST:
2368 tex_mag = WINED3DTEXF_POINT;
2370 case D3DFILTER_LINEAR:
2371 case D3DFILTER_LINEARMIPLINEAR:
2372 tex_mag = WINED3DTEXF_LINEAR;
2375 ERR("Unhandled texture mag %d !\n",Value);
2378 return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
2379 0, WINED3DSAMP_MAGFILTER,
2383 case D3DRENDERSTATE_TEXTUREMIN:
2385 WINED3DTEXTUREFILTERTYPE tex_min = WINED3DTEXF_NONE;
2386 WINED3DTEXTUREFILTERTYPE tex_mip = WINED3DTEXF_NONE;
2388 switch ((D3DTEXTUREFILTER) Value)
2390 case D3DFILTER_NEAREST:
2391 tex_min = WINED3DTEXF_POINT;
2393 case D3DFILTER_LINEAR:
2394 tex_min = WINED3DTEXF_LINEAR;
2396 case D3DFILTER_MIPNEAREST:
2397 tex_min = WINED3DTEXF_NONE;
2398 tex_mip = WINED3DTEXF_POINT;
2400 case D3DFILTER_MIPLINEAR:
2401 tex_min = WINED3DTEXF_NONE;
2402 tex_mip = WINED3DTEXF_LINEAR;
2404 case D3DFILTER_LINEARMIPNEAREST:
2405 tex_min = WINED3DTEXF_POINT;
2406 tex_mip = WINED3DTEXF_LINEAR;
2408 case D3DFILTER_LINEARMIPLINEAR:
2409 tex_min = WINED3DTEXF_LINEAR;
2410 tex_mip = WINED3DTEXF_LINEAR;
2414 ERR("Unhandled texture min %d !\n",Value);
2417 IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
2418 0, WINED3DSAMP_MIPFILTER,
2420 return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
2421 0, WINED3DSAMP_MINFILTER,
2425 case D3DRENDERSTATE_TEXTUREADDRESS:
2426 IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
2427 0, WINED3DSAMP_ADDRESSV,
2430 case D3DRENDERSTATE_TEXTUREADDRESSU:
2431 return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
2432 0, WINED3DSAMP_ADDRESSU,
2434 case D3DRENDERSTATE_TEXTUREADDRESSV:
2435 return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
2436 0, WINED3DSAMP_ADDRESSV,
2439 case D3DRENDERSTATE_TEXTUREMAPBLEND:
2441 /* Old texture combine setup style, superseded by texture stage states
2442 * in D3D7. It is safe for us to wrap it to texture stage states.
2444 switch ( (D3DTEXTUREBLEND) Value)
2446 case D3DTBLEND_MODULATE:
2447 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
2448 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
2449 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
2450 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE);
2451 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
2454 case D3DTBLEND_MODULATEALPHA:
2455 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
2456 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
2457 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
2458 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
2459 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE);
2460 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_MODULATE);
2463 case D3DTBLEND_DECAL:
2464 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
2465 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
2466 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_SELECTARG1);
2467 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
2470 case D3DTBLEND_DECALALPHA:
2471 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
2472 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
2473 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
2474 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_SELECTARG1);
2475 IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_MODULATE);
2479 ERR("Unhandled texture environment %d !\n",Value);
2487 /* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
2489 return IWineD3DDevice_SetRenderState(This->wineD3DDevice,
2495 static HRESULT WINAPI
2496 Thunk_IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
2497 D3DRENDERSTATETYPE RenderStateType,
2500 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
2501 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, RenderStateType, Value);
2502 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This, IDirect3DDevice7),
2507 static HRESULT WINAPI
2508 Thunk_IDirect3DDeviceImpl_2_SetRenderState(IDirect3DDevice2 *iface,
2509 D3DRENDERSTATETYPE RenderStateType,
2512 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2513 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, RenderStateType, Value);
2514 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This, IDirect3DDevice7),
2519 /*****************************************************************************
2520 * Direct3DDevice3::SetLightState
2522 * Sets a light state for Direct3DDevice3 and Direct3DDevice2. The
2523 * light states are forwarded to Direct3DDevice7 render states
2528 * LightStateType: The light state to change
2529 * Value: The value to assign to that light state
2533 * DDERR_INVALIDPARAMS if the parameters were incorrect
2534 * Also check IDirect3DDevice7::SetRenderState
2536 *****************************************************************************/
2537 static HRESULT WINAPI
2538 IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
2539 D3DLIGHTSTATETYPE LightStateType,
2542 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
2544 TRACE("(%p)->(%08x,%08x)\n", This, LightStateType, Value);
2546 if (!LightStateType && (LightStateType > D3DLIGHTSTATE_COLORVERTEX))
2548 TRACE("Unexpected Light State Type\n");
2549 return DDERR_INVALIDPARAMS;
2552 if (LightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */)
2554 IDirect3DMaterialImpl *mat;
2556 if(Value == 0) mat = NULL;
2557 else if(Value > This->numHandles)
2559 ERR("Material handle out of range(%d)\n", Value);
2560 return DDERR_INVALIDPARAMS;
2562 else if(This->Handles[Value - 1].type != DDrawHandle_Material)
2564 ERR("Invalid handle %d\n", Value);
2565 return DDERR_INVALIDPARAMS;
2569 mat = (IDirect3DMaterialImpl *) This->Handles[Value - 1].ptr;
2574 TRACE(" activating material %p.\n", mat);
2579 FIXME(" D3DLIGHTSTATE_MATERIAL called with NULL material !!!\n");
2581 This->material = Value;
2583 else if (LightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */)
2588 ERR("DDCOLOR_MONO should not happen!\n");
2591 /* We are already in this mode */
2592 TRACE("Setting color model to RGB (no-op).\n");
2595 ERR("Unknown color model!\n");
2596 return DDERR_INVALIDPARAMS;
2601 D3DRENDERSTATETYPE rs;
2602 switch (LightStateType)
2604 case D3DLIGHTSTATE_AMBIENT: /* 2 */
2605 rs = D3DRENDERSTATE_AMBIENT;
2607 case D3DLIGHTSTATE_FOGMODE: /* 4 */
2608 rs = D3DRENDERSTATE_FOGVERTEXMODE;
2610 case D3DLIGHTSTATE_FOGSTART: /* 5 */
2611 rs = D3DRENDERSTATE_FOGSTART;
2613 case D3DLIGHTSTATE_FOGEND: /* 6 */
2614 rs = D3DRENDERSTATE_FOGEND;
2616 case D3DLIGHTSTATE_FOGDENSITY: /* 7 */
2617 rs = D3DRENDERSTATE_FOGDENSITY;
2619 case D3DLIGHTSTATE_COLORVERTEX: /* 8 */
2620 rs = D3DRENDERSTATE_COLORVERTEX;
2623 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType);
2624 return DDERR_INVALIDPARAMS;
2627 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This, IDirect3DDevice7),
2635 static HRESULT WINAPI
2636 Thunk_IDirect3DDeviceImpl_2_SetLightState(IDirect3DDevice2 *iface,
2637 D3DLIGHTSTATETYPE LightStateType,
2640 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2641 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x) thunking to IDirect3DDevice3 interface.\n", This, LightStateType, Value);
2642 return IDirect3DDevice3_SetLightState(ICOM_INTERFACE(This, IDirect3DDevice3),
2647 /*****************************************************************************
2648 * IDirect3DDevice3::GetLightState
2650 * Returns the current setting of a light state. The state is read from
2651 * the Direct3DDevice7 render state.
2656 * LightStateType: The light state to return
2657 * Value: The address to store the light state setting at
2661 * DDDERR_INVALIDPARAMS if the parameters were incorrect
2662 * Also see IDirect3DDevice7::GetRenderState
2664 *****************************************************************************/
2665 static HRESULT WINAPI
2666 IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3 *iface,
2667 D3DLIGHTSTATETYPE LightStateType,
2670 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
2672 TRACE("(%p)->(%08x,%p)\n", This, LightStateType, Value);
2674 if (!LightStateType && (LightStateType > D3DLIGHTSTATE_COLORVERTEX))
2676 TRACE("Unexpected Light State Type\n");
2677 return DDERR_INVALIDPARAMS;
2681 return DDERR_INVALIDPARAMS;
2683 if (LightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */)
2685 *Value = This->material;
2687 else if (LightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */)
2689 *Value = D3DCOLOR_RGB;
2693 D3DRENDERSTATETYPE rs;
2694 switch (LightStateType)
2696 case D3DLIGHTSTATE_AMBIENT: /* 2 */
2697 rs = D3DRENDERSTATE_AMBIENT;
2699 case D3DLIGHTSTATE_FOGMODE: /* 4 */
2700 rs = D3DRENDERSTATE_FOGVERTEXMODE;
2702 case D3DLIGHTSTATE_FOGSTART: /* 5 */
2703 rs = D3DRENDERSTATE_FOGSTART;
2705 case D3DLIGHTSTATE_FOGEND: /* 6 */
2706 rs = D3DRENDERSTATE_FOGEND;
2708 case D3DLIGHTSTATE_FOGDENSITY: /* 7 */
2709 rs = D3DRENDERSTATE_FOGDENSITY;
2711 case D3DLIGHTSTATE_COLORVERTEX: /* 8 */
2712 rs = D3DRENDERSTATE_COLORVERTEX;
2715 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType);
2716 return DDERR_INVALIDPARAMS;
2719 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This, IDirect3DDevice7),
2727 static HRESULT WINAPI
2728 Thunk_IDirect3DDeviceImpl_2_GetLightState(IDirect3DDevice2 *iface,
2729 D3DLIGHTSTATETYPE LightStateType,
2732 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2733 TRACE_(ddraw_thunk)("(%p)->(%08x,%p) thunking to IDirect3DDevice3 interface.\n", This, LightStateType, Value);
2734 return IDirect3DDevice3_GetLightState(ICOM_INTERFACE(This, IDirect3DDevice3),
2739 /*****************************************************************************
2740 * IDirect3DDevice7::SetTransform
2742 * Assigns a D3DMATRIX to a transform type. The transform types are defined
2743 * in include/d3dtypes.h.
2744 * The D3DTRANSFORMSTATE_WORLD (=1) is translated to D3DTS_WORLDMATRIX(0)
2745 * (=255) for wined3d, because the 1 transform state was removed in d3d8
2746 * and WineD3D already understands the replacement D3DTS_WORLDMATRIX(0)
2748 * Version 2, 3 and 7
2751 * TransformStateType: transform state to set
2752 * Matrix: Matrix to assign to the state
2756 * DDERR_INVALIDPARAMS if Matrix == NULL
2757 * For details see IWineD3DDevice::SetTransform
2759 *****************************************************************************/
2760 static HRESULT WINAPI
2761 IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7 *iface,
2762 D3DTRANSFORMSTATETYPE TransformStateType,
2765 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
2766 D3DTRANSFORMSTATETYPE type = TransformStateType;
2767 TRACE("(%p)->(%08x,%p): Relay\n", This, TransformStateType, Matrix);
2770 return DDERR_INVALIDPARAMS;
2772 switch(TransformStateType)
2774 case D3DTRANSFORMSTATE_WORLD : type = WINED3DTS_WORLDMATRIX(0); break;
2775 case D3DTRANSFORMSTATE_WORLD1: type = WINED3DTS_WORLDMATRIX(1); break;
2776 case D3DTRANSFORMSTATE_WORLD2: type = WINED3DTS_WORLDMATRIX(2); break;
2777 case D3DTRANSFORMSTATE_WORLD3: type = WINED3DTS_WORLDMATRIX(3); break;
2778 default: type = TransformStateType;
2781 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
2782 return IWineD3DDevice_SetTransform(This->wineD3DDevice,
2784 (WINED3DMATRIX*) Matrix);
2787 static HRESULT WINAPI
2788 Thunk_IDirect3DDeviceImpl_3_SetTransform(IDirect3DDevice3 *iface,
2789 D3DTRANSFORMSTATETYPE TransformStateType,
2790 D3DMATRIX *D3DMatrix)
2792 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
2793 TRACE_(ddraw_thunk)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This, TransformStateType, D3DMatrix);
2794 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This, IDirect3DDevice7),
2799 static HRESULT WINAPI
2800 Thunk_IDirect3DDeviceImpl_2_SetTransform(IDirect3DDevice2 *iface,
2801 D3DTRANSFORMSTATETYPE TransformStateType,
2802 D3DMATRIX *D3DMatrix)
2804 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2805 TRACE_(ddraw_thunk)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This, TransformStateType, D3DMatrix);
2806 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This, IDirect3DDevice7),
2811 /*****************************************************************************
2812 * IDirect3DDevice7::GetTransform
2814 * Returns the matrix assigned to a transform state
2815 * D3DTRANSFORMSTATE_WORLD is translated to D3DTS_WORLDMATRIX(0), see
2819 * TransformStateType: State to read the matrix from
2820 * Matrix: Address to store the matrix at
2824 * DDERR_INVALIDPARAMS if Matrix == NULL
2825 * For details, see IWineD3DDevice::GetTransform
2827 *****************************************************************************/
2828 static HRESULT WINAPI
2829 IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7 *iface,
2830 D3DTRANSFORMSTATETYPE TransformStateType,
2833 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
2834 D3DTRANSFORMSTATETYPE type = TransformStateType;
2835 TRACE("(%p)->(%08x,%p): Relay\n", This, TransformStateType, Matrix);
2838 return DDERR_INVALIDPARAMS;
2840 switch(TransformStateType)
2842 case D3DTRANSFORMSTATE_WORLD : type = WINED3DTS_WORLDMATRIX(0); break;
2843 case D3DTRANSFORMSTATE_WORLD1: type = WINED3DTS_WORLDMATRIX(1); break;
2844 case D3DTRANSFORMSTATE_WORLD2: type = WINED3DTS_WORLDMATRIX(2); break;
2845 case D3DTRANSFORMSTATE_WORLD3: type = WINED3DTS_WORLDMATRIX(3); break;
2846 default: type = TransformStateType;
2849 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
2850 return IWineD3DDevice_GetTransform(This->wineD3DDevice, type, (WINED3DMATRIX*) Matrix);
2853 static HRESULT WINAPI
2854 Thunk_IDirect3DDeviceImpl_3_GetTransform(IDirect3DDevice3 *iface,
2855 D3DTRANSFORMSTATETYPE TransformStateType,
2856 D3DMATRIX *D3DMatrix)
2858 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
2859 TRACE_(ddraw_thunk)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This, TransformStateType, D3DMatrix);
2860 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This, IDirect3DDevice7),
2865 static HRESULT WINAPI
2866 Thunk_IDirect3DDeviceImpl_2_GetTransform(IDirect3DDevice2 *iface,
2867 D3DTRANSFORMSTATETYPE TransformStateType,
2868 D3DMATRIX *D3DMatrix)
2870 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2871 TRACE_(ddraw_thunk)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This, TransformStateType, D3DMatrix);
2872 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This, IDirect3DDevice7),
2877 /*****************************************************************************
2878 * IDirect3DDevice7::MultiplyTransform
2880 * Multiplies the already-set transform matrix of a transform state
2881 * with another matrix. For the world matrix, see SetTransform
2883 * Version 2, 3 and 7
2886 * TransformStateType: Transform state to multiply
2887 * D3DMatrix Matrix to multiply with.
2891 * DDERR_INVALIDPARAMS if D3DMatrix is NULL
2892 * For details, see IWineD3DDevice::MultiplyTransform
2894 *****************************************************************************/
2895 static HRESULT WINAPI
2896 IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7 *iface,
2897 D3DTRANSFORMSTATETYPE TransformStateType,
2898 D3DMATRIX *D3DMatrix)
2900 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
2901 D3DTRANSFORMSTATETYPE type;
2902 TRACE("(%p)->(%08x,%p): Relay\n", This, TransformStateType, D3DMatrix);
2904 switch(TransformStateType)
2906 case D3DTRANSFORMSTATE_WORLD : type = WINED3DTS_WORLDMATRIX(0); break;
2907 case D3DTRANSFORMSTATE_WORLD1: type = WINED3DTS_WORLDMATRIX(1); break;
2908 case D3DTRANSFORMSTATE_WORLD2: type = WINED3DTS_WORLDMATRIX(2); break;
2909 case D3DTRANSFORMSTATE_WORLD3: type = WINED3DTS_WORLDMATRIX(3); break;
2910 default: type = TransformStateType;
2913 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
2914 return IWineD3DDevice_MultiplyTransform(This->wineD3DDevice,
2916 (WINED3DMATRIX*) D3DMatrix);
2919 static HRESULT WINAPI
2920 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(IDirect3DDevice3 *iface,
2921 D3DTRANSFORMSTATETYPE TransformStateType,
2922 D3DMATRIX *D3DMatrix)
2924 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
2925 TRACE_(ddraw_thunk)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This, TransformStateType, D3DMatrix);
2926 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This, IDirect3DDevice7),
2931 static HRESULT WINAPI
2932 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform(IDirect3DDevice2 *iface,
2933 D3DTRANSFORMSTATETYPE TransformStateType,
2934 D3DMATRIX *D3DMatrix)
2936 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
2937 TRACE_(ddraw_thunk)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This, TransformStateType, D3DMatrix);
2938 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This, IDirect3DDevice7),
2943 /*****************************************************************************
2944 * IDirect3DDevice7::DrawPrimitive
2946 * Draws primitives based on vertices in an application-provided pointer
2948 * Version 2, 3 and 7. The IDirect3DDevice2 thunk converts the fixed vertex type into
2949 * an FVF format for D3D7
2952 * PrimitiveType: The type of the primitives to draw
2953 * Vertex type: Flexible vertex format vertex description
2954 * Vertices: Pointer to the vertex array
2955 * VertexCount: The number of vertices to draw
2956 * Flags: As usual a few flags
2960 * DDERR_INVALIDPARAMS if Vertices is NULL
2961 * For details, see IWineD3DDevice::DrawPrimitiveUP
2963 *****************************************************************************/
2964 static HRESULT WINAPI
2965 IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface,
2966 D3DPRIMITIVETYPE PrimitiveType,
2972 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
2973 UINT PrimitiveCount, stride;
2975 TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): Relay!\n", This, PrimitiveType, VertexType, Vertices, VertexCount, Flags);
2978 return DDERR_INVALIDPARAMS;
2980 /* Get the vertex count */
2981 switch(PrimitiveType)
2983 case D3DPT_POINTLIST:
2984 PrimitiveCount = VertexCount;
2987 case D3DPT_LINELIST:
2988 PrimitiveCount = VertexCount / 2;
2991 case D3DPT_LINESTRIP:
2992 PrimitiveCount = VertexCount - 1;
2995 case D3DPT_TRIANGLELIST:
2996 PrimitiveCount = VertexCount / 3;
2999 case D3DPT_TRIANGLESTRIP:
3000 PrimitiveCount = VertexCount - 2;
3003 case D3DPT_TRIANGLEFAN:
3004 PrimitiveCount = VertexCount - 2;
3007 default: return DDERR_INVALIDPARAMS;
3010 /* Get the stride */
3011 stride = get_flexible_vertex_size(VertexType);
3014 hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
3015 IDirectDrawImpl_FindDecl(This->ddraw, VertexType));
3016 if(hr != D3D_OK) return hr;
3018 /* This method translates to the user pointer draw of WineD3D */
3019 return IWineD3DDevice_DrawPrimitiveUP(This->wineD3DDevice,
3026 static HRESULT WINAPI
3027 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(IDirect3DDevice3 *iface,
3028 D3DPRIMITIVETYPE PrimitiveType,
3034 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
3035 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, PrimitiveType, VertexType, Vertices, VertexCount, Flags);
3036 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This, IDirect3DDevice7),
3044 static HRESULT WINAPI
3045 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive(IDirect3DDevice2 *iface,
3046 D3DPRIMITIVETYPE PrimitiveType,
3047 D3DVERTEXTYPE VertexType,
3052 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
3054 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, PrimitiveType, VertexType, Vertices, VertexCount, Flags);
3058 case D3DVT_VERTEX: FVF = D3DFVF_VERTEX; break;
3059 case D3DVT_LVERTEX: FVF = D3DFVF_LVERTEX; break;
3060 case D3DVT_TLVERTEX: FVF = D3DFVF_TLVERTEX; break;
3062 ERR("Unexpected vertex type %d\n", VertexType);
3063 return DDERR_INVALIDPARAMS; /* Should never happen */
3066 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This, IDirect3DDevice7),
3074 /*****************************************************************************
3075 * IDirect3DDevice7::DrawIndexedPrimitive
3077 * Draws vertices from an application-provided pointer, based on the index
3078 * numbers in a WORD array.
3080 * Version 2, 3 and 7. The version 7 thunk translates the vertex type into
3081 * an FVF format for D3D7
3084 * PrimitiveType: The primitive type to draw
3085 * VertexType: The FVF vertex description
3086 * Vertices: Pointer to the vertex array
3088 * Indices: Pointer to the index array
3089 * IndexCount: Number of indices = Number of vertices to draw
3090 * Flags: As usual, some flags
3094 * DDERR_INVALIDPARAMS if Vertices or Indices is NULL
3095 * For details, see IWineD3DDevice::DrawIndexedPrimitiveUP
3097 *****************************************************************************/
3098 static HRESULT WINAPI
3099 IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
3100 D3DPRIMITIVETYPE PrimitiveType,
3108 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
3109 UINT PrimitiveCount = 0;
3111 TRACE("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): Relay!\n", This, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
3112 /* Get the primitive number */
3113 switch(PrimitiveType)
3115 case D3DPT_POINTLIST:
3116 PrimitiveCount = IndexCount;
3119 case D3DPT_LINELIST:
3120 PrimitiveCount = IndexCount / 2;
3123 case D3DPT_LINESTRIP:
3124 PrimitiveCount = IndexCount - 1;
3127 case D3DPT_TRIANGLELIST:
3128 PrimitiveCount = IndexCount / 3;
3131 case D3DPT_TRIANGLESTRIP:
3132 PrimitiveCount = IndexCount - 2;
3135 case D3DPT_TRIANGLEFAN:
3136 PrimitiveCount = IndexCount - 2;
3139 default: return DDERR_INVALIDPARAMS;
3142 /* Set the D3DDevice's FVF */
3143 hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
3144 IDirectDrawImpl_FindDecl(This->ddraw, VertexType));
3147 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
3151 return IWineD3DDevice_DrawIndexedPrimitiveUP(This->wineD3DDevice,
3153 0 /* MinVertexIndex */,
3154 VertexCount /* UINT NumVertexIndex */,
3159 get_flexible_vertex_size(VertexType));
3162 static HRESULT WINAPI
3163 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(IDirect3DDevice3 *iface,
3164 D3DPRIMITIVETYPE PrimitiveType,
3172 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
3173 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
3174 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This, IDirect3DDevice7),
3184 static HRESULT WINAPI
3185 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(IDirect3DDevice2 *iface,
3186 D3DPRIMITIVETYPE PrimitiveType,
3187 D3DVERTEXTYPE VertexType,
3195 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
3196 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
3200 case D3DVT_VERTEX: FVF = D3DFVF_VERTEX; break;
3201 case D3DVT_LVERTEX: FVF = D3DFVF_LVERTEX; break;
3202 case D3DVT_TLVERTEX: FVF = D3DFVF_TLVERTEX; break;
3204 ERR("Unexpected vertex type %d\n", VertexType);
3205 return DDERR_INVALIDPARAMS; /* Should never happen */
3208 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This, IDirect3DDevice7),
3218 /*****************************************************************************
3219 * IDirect3DDevice7::SetClipStatus
3221 * Sets the clip status. This defines things as clipping conditions and
3222 * the extents of the clipping region.
3224 * Version 2, 3 and 7
3230 * D3D_OK because it's a stub
3231 * (DDERR_INVALIDPARAMS if ClipStatus == NULL)
3233 *****************************************************************************/
3234 static HRESULT WINAPI
3235 IDirect3DDeviceImpl_7_SetClipStatus(IDirect3DDevice7 *iface,
3236 D3DCLIPSTATUS *ClipStatus)
3238 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
3239 FIXME("(%p)->(%p): Stub!\n", This, ClipStatus);
3241 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them
3242 * Perhaps this needs a new data type and an additional IWineD3DDevice method
3244 /* return IWineD3DDevice_SetClipStatus(This->wineD3DDevice, ClipStatus);*/
3248 static HRESULT WINAPI
3249 Thunk_IDirect3DDeviceImpl_3_SetClipStatus(IDirect3DDevice3 *iface,
3250 D3DCLIPSTATUS *ClipStatus)
3252 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
3253 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, ClipStatus);
3254 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This, IDirect3DDevice7),
3258 static HRESULT WINAPI
3259 Thunk_IDirect3DDeviceImpl_2_SetClipStatus(IDirect3DDevice2 *iface,
3260 D3DCLIPSTATUS *ClipStatus)
3262 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
3263 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, ClipStatus);
3264 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This, IDirect3DDevice7),
3268 /*****************************************************************************
3269 * IDirect3DDevice7::GetClipStatus
3271 * Returns the clip status
3274 * ClipStatus: Address to write the clip status to
3277 * D3D_OK because it's a stub
3279 *****************************************************************************/
3280 static HRESULT WINAPI
3281 IDirect3DDeviceImpl_7_GetClipStatus(IDirect3DDevice7 *iface,
3282 D3DCLIPSTATUS *ClipStatus)
3284 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
3285 FIXME("(%p)->(%p): Stub!\n", This, ClipStatus);
3287 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them */
3288 /* return IWineD3DDevice_GetClipStatus(This->wineD3DDevice, ClipStatus);*/
3292 static HRESULT WINAPI
3293 Thunk_IDirect3DDeviceImpl_3_GetClipStatus(IDirect3DDevice3 *iface,
3294 D3DCLIPSTATUS *ClipStatus)
3296 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
3297 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, ClipStatus);
3298 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This, IDirect3DDevice7),
3302 static HRESULT WINAPI
3303 Thunk_IDirect3DDeviceImpl_2_GetClipStatus(IDirect3DDevice2 *iface,
3304 D3DCLIPSTATUS *ClipStatus)
3306 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface);
3307 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, ClipStatus);
3308 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This, IDirect3DDevice7),
3312 /*****************************************************************************
3313 * IDirect3DDevice::DrawPrimitiveStrided
3315 * Draws vertices described by a D3DDRAWPRIMITIVESTRIDEDDATA structure.
3320 * PrimitiveType: The primitive type to draw
3321 * VertexType: The FVF description of the vertices to draw (for the stride??)
3322 * D3DDrawPrimStrideData: A D3DDRAWPRIMITIVESTRIDEDDATA structure describing
3323 * the vertex data locations
3324 * VertexCount: The number of vertices to draw
3328 * D3D_OK, because it's a stub
3329 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3330 * (For details, see IWineD3DDevice::DrawPrimitiveStrided)
3332 *****************************************************************************/
3333 static HRESULT WINAPI
3334 IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
3335 D3DPRIMITIVETYPE PrimitiveType,
3337 D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
3341 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
3342 WineDirect3DVertexStridedData WineD3DStrided;
3344 UINT PrimitiveCount;
3346 TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
3348 memset(&WineD3DStrided, 0, sizeof(WineD3DStrided));
3349 /* Get the strided data right. the wined3d structure is a bit bigger
3350 * Watch out: The contents of the strided data are determined by the fvf,
3351 * not by the members set in D3DDrawPrimStrideData. So it's valid
3352 * to have diffuse.lpvData set to 0xdeadbeef if the diffuse flag is
3353 * not set in the fvf.
3355 if(VertexType & D3DFVF_POSITION_MASK)
3357 WineD3DStrided.u.s.position.lpData = D3DDrawPrimStrideData->position.lpvData;
3358 WineD3DStrided.u.s.position.dwStride = D3DDrawPrimStrideData->position.dwStride;
3359 WineD3DStrided.u.s.position.dwType = WINED3DDECLTYPE_FLOAT3;
3360 if (VertexType & D3DFVF_XYZRHW)
3362 WineD3DStrided.u.s.position.dwType = WINED3DDECLTYPE_FLOAT4;
3363 WineD3DStrided.u.s.position_transformed = TRUE;
3365 WineD3DStrided.u.s.position_transformed = FALSE;
3368 if(VertexType & D3DFVF_NORMAL)
3370 WineD3DStrided.u.s.normal.lpData = D3DDrawPrimStrideData->normal.lpvData;
3371 WineD3DStrided.u.s.normal.dwStride = D3DDrawPrimStrideData->normal.dwStride;
3372 WineD3DStrided.u.s.normal.dwType = WINED3DDECLTYPE_FLOAT3;
3375 if(VertexType & D3DFVF_DIFFUSE)
3377 WineD3DStrided.u.s.diffuse.lpData = D3DDrawPrimStrideData->diffuse.lpvData;
3378 WineD3DStrided.u.s.diffuse.dwStride = D3DDrawPrimStrideData->diffuse.dwStride;
3379 WineD3DStrided.u.s.diffuse.dwType = WINED3DDECLTYPE_SHORT4;
3382 if(VertexType & D3DFVF_SPECULAR)
3384 WineD3DStrided.u.s.specular.lpData = D3DDrawPrimStrideData->specular.lpvData;
3385 WineD3DStrided.u.s.specular.dwStride = D3DDrawPrimStrideData->specular.dwStride;
3386 WineD3DStrided.u.s.specular.dwType = WINED3DDECLTYPE_SHORT4;
3389 for( i = 0; i < GET_TEXCOUNT_FROM_FVF(VertexType); i++)
3391 WineD3DStrided.u.s.texCoords[i].lpData = D3DDrawPrimStrideData->textureCoords[i].lpvData;
3392 WineD3DStrided.u.s.texCoords[i].dwStride = D3DDrawPrimStrideData->textureCoords[i].dwStride;
3393 switch(GET_TEXCOORD_SIZE_FROM_FVF(VertexType, i))
3395 case 1: WineD3DStrided.u.s.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT1; break;
3396 case 2: WineD3DStrided.u.s.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT2; break;
3397 case 3: WineD3DStrided.u.s.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT3; break;
3398 case 4: WineD3DStrided.u.s.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT4; break;
3399 default: ERR("Unexpected texture coordinate size %d\n",
3400 GET_TEXCOORD_SIZE_FROM_FVF(VertexType, i));
3404 /* Get the primitive count */
3405 switch(PrimitiveType)
3407 case D3DPT_POINTLIST:
3408 PrimitiveCount = VertexCount;
3411 case D3DPT_LINELIST:
3412 PrimitiveCount = VertexCount / 2;
3415 case D3DPT_LINESTRIP:
3416 PrimitiveCount = VertexCount - 1;
3419 case D3DPT_TRIANGLELIST:
3420 PrimitiveCount = VertexCount / 3;
3423 case D3DPT_TRIANGLESTRIP:
3424 PrimitiveCount = VertexCount - 2;
3427 case D3DPT_TRIANGLEFAN:
3428 PrimitiveCount = VertexCount - 2;
3431 default: return DDERR_INVALIDPARAMS;
3434 /* WineD3D doesn't need the FVF here */
3435 return IWineD3DDevice_DrawPrimitiveStrided(This->wineD3DDevice,
3441 static HRESULT WINAPI
3442 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided(IDirect3DDevice3 *iface,
3443 D3DPRIMITIVETYPE PrimitiveType,
3445 D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
3449 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
3450 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
3451 return IDirect3DDevice7_DrawPrimitiveStrided(ICOM_INTERFACE(This, IDirect3DDevice7),
3454 D3DDrawPrimStrideData,
3459 /*****************************************************************************
3460 * IDirect3DDevice7::DrawIndexedPrimitiveStrided
3462 * Draws primitives specified by strided data locations based on indices
3470 * D3D_OK, because it's a stub
3471 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3472 * (DDERR_INVALIDPARAMS if Indices is NULL)
3473 * (For more details, see IWineD3DDevice::DrawIndexedPrimitiveStrided)
3475 *****************************************************************************/
3476 static HRESULT WINAPI
3477 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
3478 D3DPRIMITIVETYPE PrimitiveType,
3480 D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
3486 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
3487 FIXME("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): stub!\n", This, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
3489 /* I'll implement it as soon as I find a app to test it.
3490 * This needs an additional method in IWineD3DDevice.
3495 static HRESULT WINAPI
3496 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(IDirect3DDevice3 *iface,
3497 D3DPRIMITIVETYPE PrimitiveType,
3499 D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
3505 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
3506 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
3507 return IDirect3DDevice7_DrawIndexedPrimitiveStrided(ICOM_INTERFACE(This, IDirect3DDevice7),
3510 D3DDrawPrimStrideData,
3517 /*****************************************************************************
3518 * IDirect3DDevice7::DrawPrimitiveVB
3520 * Draws primitives from a vertex buffer to the screen.
3525 * PrimitiveType: Type of primitive to be rendered.
3526 * D3DVertexBuf: Source Vertex Buffer
3527 * StartVertex: Index of the first vertex from the buffer to be rendered
3528 * NumVertices: Number of vertices to be rendered
3529 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3533 * DDERR_INVALIDPARAMS if D3DVertexBuf is NULL
3535 *****************************************************************************/
3536 static HRESULT WINAPI
3537 IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
3538 D3DPRIMITIVETYPE PrimitiveType,
3539 IDirect3DVertexBuffer7 *D3DVertexBuf,
3544 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
3545 IDirect3DVertexBufferImpl *vb = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, D3DVertexBuf);
3546 UINT PrimitiveCount;
3549 WINED3DVERTEXBUFFER_DESC Desc;
3551 TRACE("(%p)->(%08x,%p,%08x,%08x,%08x)\n", This, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
3556 ERR("(%p) No Vertex buffer specified\n", This);
3557 return DDERR_INVALIDPARAMS;
3560 /* Get the primitive count */
3561 switch(PrimitiveType)
3563 case D3DPT_POINTLIST:
3564 PrimitiveCount = NumVertices;
3567 case D3DPT_LINELIST:
3568 PrimitiveCount = NumVertices / 2;
3571 case D3DPT_LINESTRIP:
3572 PrimitiveCount = NumVertices - 1;
3575 case D3DPT_TRIANGLELIST:
3576 PrimitiveCount = NumVertices / 3;
3579 case D3DPT_TRIANGLESTRIP:
3580 PrimitiveCount = NumVertices - 2;
3583 case D3DPT_TRIANGLEFAN:
3584 PrimitiveCount = NumVertices - 2;
3587 default: return DDERR_INVALIDPARAMS;
3590 /* Get the FVF of the vertex buffer, and its stride */
3591 hr = IWineD3DVertexBuffer_GetDesc(vb->wineD3DVertexBuffer,
3595 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x\n", This, hr);
3598 stride = get_flexible_vertex_size(Desc.FVF);
3600 hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
3601 vb->wineD3DVertexDeclaration);
3604 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
3608 /* Set the vertex stream source */
3609 hr = IWineD3DDevice_SetStreamSource(This->wineD3DDevice,
3610 0 /* StreamNumber */,
3611 vb->wineD3DVertexBuffer,
3612 0 /* StartVertex - we pass this to DrawPrimitive */,
3616 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This, hr);
3620 /* Now draw the primitives */
3621 return IWineD3DDevice_DrawPrimitive(This->wineD3DDevice,
3627 static HRESULT WINAPI
3628 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3 *iface,
3629 D3DPRIMITIVETYPE PrimitiveType,
3630 IDirect3DVertexBuffer *D3DVertexBuf,
3635 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
3636 IDirect3DVertexBufferImpl *vb = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, D3DVertexBuf);
3637 TRACE_(ddraw_thunk)("(%p)->(%08x,%p,%08x,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, PrimitiveType, vb, StartVertex, NumVertices, Flags);
3638 return IDirect3DDevice7_DrawPrimitiveVB(ICOM_INTERFACE(This, IDirect3DDevice7),
3640 ICOM_INTERFACE(vb, IDirect3DVertexBuffer7),
3647 /*****************************************************************************
3648 * IDirect3DDevice7::DrawIndexedPrimitiveVB
3650 * Draws primitives from a vertex buffer to the screen
3653 * PrimitiveType: Type of primitive to be rendered.
3654 * D3DVertexBuf: Source Vertex Buffer
3655 * StartVertex: Index of the first vertex from the buffer to be rendered
3656 * NumVertices: Number of vertices to be rendered
3657 * Indices: Array of DWORDs used to index into the Vertices
3658 * IndexCount: Number of indices in Indices
3659 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3663 *****************************************************************************/
3664 static HRESULT WINAPI
3665 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
3666 D3DPRIMITIVETYPE PrimitiveType,
3667 IDirect3DVertexBuffer7 *D3DVertexBuf,
3674 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
3675 IDirect3DVertexBufferImpl *vb = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, D3DVertexBuf);
3677 UINT PrimitiveCount;
3678 WORD *LockedIndices;
3680 WINED3DVERTEXBUFFER_DESC Desc;
3682 TRACE("(%p)->(%08x,%p,%d,%d,%p,%d,%08x)\n", This, PrimitiveType, vb, StartVertex, NumVertices, Indices, IndexCount, Flags);
3685 * 1) Calculate some things: Vertex count -> Primitive count, stride, ...
3686 * 2) Upload the Indices to the index buffer
3687 * 3) Set the index source
3688 * 4) Set the Vertex Buffer as the Stream source
3689 * 5) Call IWineD3DDevice::DrawIndexedPrimitive
3692 /* Get the primitive count */
3693 switch(PrimitiveType)
3695 case D3DPT_POINTLIST:
3696 PrimitiveCount = IndexCount;
3699 case D3DPT_LINELIST:
3700 PrimitiveCount = IndexCount / 2;
3703 case D3DPT_LINESTRIP:
3704 PrimitiveCount = IndexCount - 1;
3707 case D3DPT_TRIANGLELIST:
3708 PrimitiveCount = IndexCount / 3;
3711 case D3DPT_TRIANGLESTRIP:
3712 PrimitiveCount = IndexCount - 2;
3715 case D3DPT_TRIANGLEFAN:
3716 PrimitiveCount = IndexCount - 2;
3719 default: return DDERR_INVALIDPARAMS;
3722 /* Get the FVF of the vertex buffer, and its stride */
3723 hr = IWineD3DVertexBuffer_GetDesc(vb->wineD3DVertexBuffer,
3727 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x\n", This, hr);
3730 stride = get_flexible_vertex_size(Desc.FVF);
3731 TRACE("Vertex buffer FVF = %08x, stride=%d\n", Desc.FVF, stride);
3733 hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
3734 vb->wineD3DVertexDeclaration);
3737 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
3741 /* copy the index stream into the index buffer.
3742 * A new IWineD3DDevice method could be created
3743 * which takes an user pointer containing the indices
3744 * or a SetData-Method for the index buffer, which
3745 * overrides the index buffer data with our pointer.
3747 hr = IWineD3DIndexBuffer_Lock(This->indexbuffer,
3748 0 /* OffSetToLock */,
3749 IndexCount * sizeof(WORD),
3750 (BYTE **) &LockedIndices,
3752 assert(IndexCount < 0x100000);
3755 ERR("(%p) IWineD3DIndexBuffer::Lock failed with hr = %08x\n", This, hr);
3758 memcpy(LockedIndices, Indices, IndexCount * sizeof(WORD));
3759 hr = IWineD3DIndexBuffer_Unlock(This->indexbuffer);
3762 ERR("(%p) IWineD3DIndexBuffer::Unlock failed with hr = %08x\n", This, hr);
3766 /* Set the index stream */
3767 hr = IWineD3DDevice_SetIndices(This->wineD3DDevice,
3771 /* Set the vertex stream source */
3772 hr = IWineD3DDevice_SetStreamSource(This->wineD3DDevice,
3773 0 /* StreamNumber */,
3774 vb->wineD3DVertexBuffer,
3775 0 /* offset, we pass this to DrawIndexedPrimitive */,
3779 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This, hr);
3784 hr = IWineD3DDevice_DrawIndexedPrimitive(This->wineD3DDevice,
3794 static HRESULT WINAPI
3795 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevice3 *iface,
3796 D3DPRIMITIVETYPE PrimitiveType,
3797 IDirect3DVertexBuffer *D3DVertexBuf,
3802 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
3803 IDirect3DVertexBufferImpl *VB = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, D3DVertexBuf);
3804 TRACE_(ddraw_thunk)("(%p)->(%08x,%p,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, PrimitiveType, VB, Indices, IndexCount, Flags);
3806 return IDirect3DDevice7_DrawIndexedPrimitiveVB(ICOM_INTERFACE(This, IDirect3DDevice7),
3808 ICOM_INTERFACE(VB, IDirect3DVertexBuffer7),
3816 /*****************************************************************************
3817 * IDirect3DDevice7::ComputeSphereVisibility
3819 * Calculates the visibility of spheres in the current viewport. The spheres
3820 * are passed in the Centers and Radii arrays, the results are passed back
3821 * in the ReturnValues array. Return values are either completely visible,
3822 * partially visible or completely invisible.
3823 * The return value consist of a combination of D3DCLIP_* flags, or it's
3824 * 0 if the sphere is completely visible(according to the SDK, not checked)
3826 * Sounds like an overdose of math ;)
3831 * Centers: Array containing the sphere centers
3832 * Radii: Array containing the sphere radii
3833 * NumSpheres: The number of centers and radii in the arrays
3835 * ReturnValues: Array to write the results to
3838 * D3D_OK because it's a stub
3839 * (DDERR_INVALIDPARAMS if Centers, Radii or ReturnValues are NULL)
3840 * (D3DERR_INVALIDMATRIX if the combined world, view and proj matrix
3843 *****************************************************************************/
3844 static HRESULT WINAPI
3845 IDirect3DDeviceImpl_7_ComputeSphereVisibility(IDirect3DDevice7 *iface,
3850 DWORD *ReturnValues)
3852 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
3853 FIXME("(%p)->(%p,%p,%08x,%08x,%p): stub!\n", This, Centers, Radii, NumSpheres, Flags, ReturnValues);
3855 /* the DirectX 7 sdk says that the visibility is computed by
3856 * back-transforming the viewing frustum to model space
3857 * using the inverse of the combined world, view and projection
3858 * matrix. If the matrix can't be reversed, D3DERR_INVALIDMATRIX
3861 * Basic implementation idea:
3862 * 1) Check if the center is in the viewing frustum
3863 * 2) Cut the sphere with the planes of the viewing
3866 * ->Center inside the frustum, no intersections:
3868 * ->Center outside the frustum, no intersections:
3870 * ->Some intersections: Partially visible
3872 * Implement this call in WineD3D. Either implement the
3873 * matrix and vector stuff in WineD3D, or use some external
3880 static HRESULT WINAPI
3881 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility(IDirect3DDevice3 *iface,
3886 DWORD *ReturnValues)
3888 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
3889 TRACE_(ddraw_thunk)("(%p)->(%p,%p,%08x,%08x,%p) thunking to IDirect3DDevice7 interface.\n", This, Centers, Radii, NumSpheres, Flags, ReturnValues);
3890 return IDirect3DDevice7_ComputeSphereVisibility(ICOM_INTERFACE(This, IDirect3DDevice7),
3898 /*****************************************************************************
3899 * IDirect3DDevice7::GetTexture
3901 * Returns the texture interface handle assigned to a texture stage.
3902 * The returned texture is AddRefed. This is taken from old ddraw,
3903 * not checked in Windows.
3908 * Stage: Texture stage to read the texture from
3909 * Texture: Address to store the interface pointer at
3913 * DDERR_INVALIDPARAMS if Texture is NULL
3914 * For details, see IWineD3DDevice::GetTexture
3916 *****************************************************************************/
3917 static HRESULT WINAPI
3918 IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7 *iface,
3920 IDirectDrawSurface7 **Texture)
3922 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
3923 IWineD3DBaseTexture *Surf;
3925 TRACE("(%p)->(%d,%p): Relay\n", This, Stage, Texture);
3929 TRACE("Texture == NULL, failing with DDERR_INVALIDPARAMS\n");
3930 return DDERR_INVALIDPARAMS;
3933 hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, Stage, (IWineD3DBaseTexture **) &Surf);
3934 if( (hr != D3D_OK) || (!Surf) )
3940 /* GetParent AddRef()s, which is perfectly OK.
3941 * We have passed the IDirectDrawSurface7 interface to WineD3D, so that's OK too.
3943 return IWineD3DBaseTexture_GetParent(Surf,
3944 (IUnknown **) Texture);
3947 static HRESULT WINAPI
3948 Thunk_IDirect3DDeviceImpl_3_GetTexture(IDirect3DDevice3 *iface,
3950 IDirect3DTexture2 **Texture2)
3952 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
3954 IDirectDrawSurface7 *ret_val;
3956 TRACE_(ddraw_thunk)("(%p)->(%d,%p) thunking to IDirect3DDevice7 interface.\n", This, Stage, Texture2);
3957 ret = IDirect3DDevice7_GetTexture(ICOM_INTERFACE(This, IDirect3DDevice7),
3961 *Texture2 = COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7, IDirect3DTexture2, ret_val);
3963 TRACE_(ddraw_thunk)(" returning interface %p.\n", *Texture2);
3968 /*****************************************************************************
3969 * IDirect3DDevice7::SetTexture
3971 * Assigns a texture to a texture stage. Is the texture AddRef-ed?
3976 * Stage: The stage to assign the texture to
3977 * Texture: Interface pointer to the texture surface
3981 * For details, see IWineD3DDevice::SetTexture
3983 *****************************************************************************/
3984 static HRESULT WINAPI
3985 IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7 *iface,
3987 IDirectDrawSurface7 *Texture)
3989 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
3990 IDirectDrawSurfaceImpl *surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Texture);
3991 TRACE("(%p)->(%08x,%p): Relay!\n", This, Stage, surf);
3993 /* Texture may be NULL here */
3994 return IWineD3DDevice_SetTexture(This->wineD3DDevice,
3996 surf ? surf->wineD3DTexture : NULL);
3999 static HRESULT WINAPI
4000 Thunk_IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
4002 IDirect3DTexture2 *Texture2)
4004 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
4005 IDirectDrawSurfaceImpl *tex = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture2, Texture2);
4006 TRACE_(ddraw_thunk)("(%p)->(%d,%p) thunking to IDirect3DDevice7 interface.\n", This, Stage, tex);
4007 return IDirect3DDevice7_SetTexture(ICOM_INTERFACE(This, IDirect3DDevice7),
4009 ICOM_INTERFACE(tex, IDirectDrawSurface7));
4012 /*****************************************************************************
4013 * IDirect3DDevice7::GetTextureStageState
4015 * Retrieves a state from a texture stage.
4020 * Stage: The stage to retrieve the state from
4021 * TexStageStateType: The state type to retrieve
4022 * State: Address to store the state's value at
4026 * DDERR_INVALIDPARAMS if State is NULL
4027 * For details, see IWineD3DDevice::GetTextureStageState
4029 *****************************************************************************/
4030 static HRESULT WINAPI
4031 IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
4033 D3DTEXTURESTAGESTATETYPE TexStageStateType,
4036 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4037 TRACE("(%p)->(%08x,%08x,%p): Relay!\n", This, Stage, TexStageStateType, State);
4040 return DDERR_INVALIDPARAMS;
4042 switch(TexStageStateType)
4044 /* Mipfilter is a sampler state with different values */
4045 case D3DTSS_MIPFILTER:
4048 WINED3DTEXTUREFILTERTYPE value;
4050 hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
4052 WINED3DSAMP_MIPFILTER,
4056 case WINED3DTEXF_NONE: *State = D3DTFP_NONE; break;
4057 case WINED3DTEXF_POINT: *State = D3DTFP_POINT; break;
4058 case WINED3DTEXF_LINEAR: *State = D3DTFP_LINEAR; break;
4060 ERR("Unexpected mipfilter value %d\n", value);
4061 *State = D3DTFP_NONE;
4066 /* Minfilter is a sampler state too, equal values */
4067 case D3DTSS_MINFILTER:
4068 return IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
4070 WINED3DSAMP_MINFILTER,
4072 /* Magfilter has slightly different values */
4073 case D3DTSS_MAGFILTER:
4076 WINED3DTEXTUREFILTERTYPE wined3dfilter;
4077 hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
4079 WINED3DSAMP_MAGFILTER,
4081 switch(wined3dfilter)
4083 case WINED3DTEXF_POINT: *State = D3DTFG_POINT; break;
4084 case WINED3DTEXF_LINEAR: *State = D3DTFG_LINEAR; break;
4085 case WINED3DTEXF_ANISOTROPIC: *State = D3DTFG_ANISOTROPIC; break;
4086 case WINED3DTEXF_FLATCUBIC: *State = D3DTFG_FLATCUBIC; break;
4087 case WINED3DTEXF_GAUSSIANCUBIC: *State = D3DTFG_GAUSSIANCUBIC; break;
4089 ERR("Unexpected wined3d mag filter value %d\n", wined3dfilter);
4090 *State = D3DTFG_POINT;
4095 case D3DTSS_ADDRESS:
4096 case D3DTSS_ADDRESSU:
4097 return IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
4099 WINED3DSAMP_ADDRESSU,
4101 case D3DTSS_ADDRESSV:
4102 return IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
4104 WINED3DSAMP_ADDRESSV,
4107 return IWineD3DDevice_GetTextureStageState(This->wineD3DDevice,
4114 static HRESULT WINAPI
4115 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState(IDirect3DDevice3 *iface,
4117 D3DTEXTURESTAGESTATETYPE TexStageStateType,
4120 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
4121 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%p) thunking to IDirect3DDevice7 interface.\n", This, Stage, TexStageStateType, State);
4122 return IDirect3DDevice7_GetTextureStageState(ICOM_INTERFACE(This, IDirect3DDevice7),
4128 /*****************************************************************************
4129 * IDirect3DDevice7::SetTextureStageState
4131 * Sets a texture stage state. Some stage types need to be handled specially,
4132 * because they do not exist in WineD3D and were moved to another place
4137 * Stage: The stage to modify
4138 * TexStageStateType: The state to change
4139 * State: The new value for the state
4143 * For details, see IWineD3DDevice::SetTextureStageState
4145 *****************************************************************************/
4146 static HRESULT WINAPI
4147 IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
4149 D3DTEXTURESTAGESTATETYPE TexStageStateType,
4152 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4153 TRACE("(%p)->(%08x,%08x,%08x): Relay!\n", This, Stage, TexStageStateType, State);
4154 switch(TexStageStateType)
4156 /* Mipfilter is a sampler state with different values */
4157 case D3DTSS_MIPFILTER:
4159 WINED3DTEXTUREFILTERTYPE value;
4162 case D3DTFP_NONE: value = WINED3DTEXF_NONE; break;
4163 case D3DTFP_POINT: value = WINED3DTEXF_POINT; break;
4164 case 0: /* Unchecked */
4165 case D3DTFP_LINEAR: value = WINED3DTEXF_LINEAR; break;
4167 ERR("Unexpected mipfilter value %d\n", State);
4168 value = WINED3DTEXF_NONE;
4170 return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
4172 WINED3DSAMP_MIPFILTER,
4176 /* Minfilter is a sampler state too, equal values */
4177 case D3DTSS_MINFILTER:
4178 return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
4180 WINED3DSAMP_MINFILTER,
4182 /* Magfilter has slightly different values */
4183 case D3DTSS_MAGFILTER:
4185 WINED3DTEXTUREFILTERTYPE wined3dfilter;
4186 switch((D3DTEXTUREMAGFILTER) State)
4188 case D3DTFG_POINT: wined3dfilter = WINED3DTEXF_POINT; break;
4189 case D3DTFG_LINEAR: wined3dfilter = WINED3DTEXF_LINEAR; break;
4190 case D3DTFG_FLATCUBIC: wined3dfilter = WINED3DTEXF_FLATCUBIC; break;
4191 case D3DTFG_GAUSSIANCUBIC: wined3dfilter = WINED3DTEXF_GAUSSIANCUBIC; break;
4192 case D3DTFG_ANISOTROPIC: wined3dfilter = WINED3DTEXF_ANISOTROPIC; break;
4194 ERR("Unexpected d3d7 mag filter type %d\n", State);
4195 wined3dfilter = WINED3DTEXF_POINT;
4197 return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
4199 WINED3DSAMP_MAGFILTER,
4203 case D3DTSS_ADDRESS:
4204 IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
4206 WINED3DSAMP_ADDRESSV,
4209 case D3DTSS_ADDRESSU:
4210 return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
4212 WINED3DSAMP_ADDRESSU,
4214 case D3DTSS_ADDRESSV:
4215 return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
4217 WINED3DSAMP_ADDRESSV,
4221 return IWineD3DDevice_SetTextureStageState(This->wineD3DDevice,
4228 static HRESULT WINAPI
4229 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState(IDirect3DDevice3 *iface,
4231 D3DTEXTURESTAGESTATETYPE TexStageStateType,
4234 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
4235 TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This, Stage, TexStageStateType, State);
4236 return IDirect3DDevice7_SetTextureStageState(ICOM_INTERFACE(This, IDirect3DDevice7),
4242 /*****************************************************************************
4243 * IDirect3DDevice7::ValidateDevice
4245 * SDK: "Reports the device's ability to render the currently set
4246 * texture-blending operations in a single pass". Whatever that means
4252 * NumPasses: Address to write the number of necessary passes for the
4253 * desired effect to.
4257 * See IWineD3DDevice::ValidateDevice for more details
4259 *****************************************************************************/
4260 static HRESULT WINAPI
4261 IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7 *iface,
4264 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4265 TRACE("(%p)->(%p): Relay\n", This, NumPasses);
4267 return IWineD3DDevice_ValidateDevice(This->wineD3DDevice, NumPasses);
4270 static HRESULT WINAPI
4271 Thunk_IDirect3DDeviceImpl_3_ValidateDevice(IDirect3DDevice3 *iface,
4274 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
4275 TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This, Passes);
4276 return IDirect3DDevice7_ValidateDevice(ICOM_INTERFACE(This, IDirect3DDevice7),
4280 /*****************************************************************************
4281 * IDirect3DDevice7::Clear
4283 * Fills the render target, the z buffer and the stencil buffer with a
4284 * clear color / value
4289 * Count: Number of rectangles in Rects must be 0 if Rects is NULL
4290 * Rects: Rectangles to clear. If NULL, the whole surface is cleared
4291 * Flags: Some flags, as usual
4292 * Color: Clear color for the render target
4293 * Z: Clear value for the Z buffer
4294 * Stencil: Clear value to store in each stencil buffer entry
4298 * For details, see IWineD3DDevice::Clear
4300 *****************************************************************************/
4301 static HRESULT WINAPI
4302 IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7 *iface,
4310 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4311 TRACE("(%p)->(%08x,%p,%08x,%08x,%f,%08x): Relay\n", This, Count, Rects, Flags, (DWORD) Color, Z, Stencil);
4313 /* Note; D3DRECT is compatible with WINED3DRECT */
4314 return IWineD3DDevice_Clear(This->wineD3DDevice, Count, (WINED3DRECT*) Rects, Flags, Color, Z, Stencil);
4317 /*****************************************************************************
4318 * IDirect3DDevice7::SetViewport
4320 * Sets the current viewport.
4322 * Version 7 only, but IDirect3DViewport uses this call for older
4326 * Data: The new viewport to set
4330 * DDERR_INVALIDPARAMS if Data is NULL
4331 * For more details, see IWineDDDevice::SetViewport
4333 *****************************************************************************/
4334 static HRESULT WINAPI
4335 IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7 *iface,
4338 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4339 TRACE("(%p)->(%p) Relay!\n", This, Data);
4342 return DDERR_INVALIDPARAMS;
4344 /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
4345 return IWineD3DDevice_SetViewport(This->wineD3DDevice,
4346 (WINED3DVIEWPORT*) Data);
4349 /*****************************************************************************
4350 * IDirect3DDevice::GetViewport
4352 * Returns the current viewport
4357 * Data: D3D7Viewport structure to write the viewport information to
4361 * DDERR_INVALIDPARAMS if Data is NULL
4362 * For more details, see IWineD3DDevice::GetViewport
4364 *****************************************************************************/
4365 static HRESULT WINAPI
4366 IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7 *iface,
4369 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4371 TRACE("(%p)->(%p) Relay!\n", This, Data);
4374 return DDERR_INVALIDPARAMS;
4376 /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
4377 hr = IWineD3DDevice_GetViewport(This->wineD3DDevice,
4378 (WINED3DVIEWPORT*) Data);
4380 return hr_ddraw_from_wined3d(hr);
4383 /*****************************************************************************
4384 * IDirect3DDevice7::SetMaterial
4391 * Mat: The material to set
4395 * DDERR_INVALIDPARAMS if Mat is NULL.
4396 * For more details, see IWineD3DDevice::SetMaterial
4398 *****************************************************************************/
4399 static HRESULT WINAPI
4400 IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7 *iface,
4403 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4405 TRACE("(%p)->(%p): Relay!\n", This, Mat);
4407 /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
4408 hr = IWineD3DDevice_SetMaterial(This->wineD3DDevice,
4409 (WINED3DMATERIAL*) Mat);
4411 return hr_ddraw_from_wined3d(hr);
4414 /*****************************************************************************
4415 * IDirect3DDevice7::GetMaterial
4417 * Returns the current material
4422 * Mat: D3DMATERIAL7 structure to write the material parameters to
4426 * DDERR_INVALIDPARAMS if Mat is NULL
4427 * For more details, see IWineD3DDevice::GetMaterial
4429 *****************************************************************************/
4430 static HRESULT WINAPI
4431 IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7 *iface,
4434 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4436 TRACE("(%p)->(%p): Relay!\n", This, Mat);
4438 /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
4439 hr = IWineD3DDevice_GetMaterial(This->wineD3DDevice,
4440 (WINED3DMATERIAL*) Mat);
4442 return hr_ddraw_from_wined3d(hr);
4445 /*****************************************************************************
4446 * IDirect3DDevice7::SetLight
4448 * Assigns a light to a light index, but doesn't activate it yet.
4450 * Version 7, IDirect3DLight uses this method for older versions
4453 * LightIndex: The index of the new light
4454 * Light: A D3DLIGHT7 structure describing the light
4458 * For more details, see IWineD3DDevice::SetLight
4460 *****************************************************************************/
4461 static HRESULT WINAPI
4462 IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7 *iface,
4466 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4468 TRACE("(%p)->(%08x,%p): Relay!\n", This, LightIndex, Light);
4470 /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
4471 hr = IWineD3DDevice_SetLight(This->wineD3DDevice,
4473 (WINED3DLIGHT*) Light);
4475 return hr_ddraw_from_wined3d(hr);
4478 /*****************************************************************************
4479 * IDirect3DDevice7::GetLight
4481 * Returns the light assigned to a light index
4484 * Light: Structure to write the light information to
4488 * DDERR_INVALIDPARAMS if Light is NULL
4489 * For details, see IWineD3DDevice::GetLight
4491 *****************************************************************************/
4492 static HRESULT WINAPI
4493 IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7 *iface,
4497 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4499 TRACE("(%p)->(%08x,%p): Relay!\n", This, LightIndex, Light);
4501 /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
4502 rc = IWineD3DDevice_GetLight(This->wineD3DDevice,
4504 (WINED3DLIGHT*) Light);
4506 /* Translate the result. WineD3D returns other values than D3D7 */
4507 return hr_ddraw_from_wined3d(rc);
4510 /*****************************************************************************
4511 * IDirect3DDevice7::BeginStateBlock
4513 * Begins recording to a stateblock
4519 * For details see IWineD3DDevice::BeginStateBlock
4521 *****************************************************************************/
4522 static HRESULT WINAPI
4523 IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7 *iface)
4525 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4527 TRACE("(%p)->(): Relay!\n", This);
4529 hr = IWineD3DDevice_BeginStateBlock(This->wineD3DDevice);
4530 return hr_ddraw_from_wined3d(hr);
4533 /*****************************************************************************
4534 * IDirect3DDevice7::EndStateBlock
4536 * Stops recording to a state block and returns the created stateblock
4542 * BlockHandle: Address to store the stateblock's handle to
4546 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4547 * See IWineD3DDevice::EndStateBlock for more details
4549 *****************************************************************************/
4550 static HRESULT WINAPI
4551 IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
4554 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4556 TRACE("(%p)->(%p): Relay!\n", This, BlockHandle);
4560 WARN("BlockHandle == NULL, returning DDERR_INVALIDPARAMS\n");
4561 return DDERR_INVALIDPARAMS;
4564 *BlockHandle = IDirect3DDeviceImpl_CreateHandle(This);
4567 ERR("Cannot get a handle number for the stateblock\n");
4568 return DDERR_OUTOFMEMORY;
4570 This->Handles[*BlockHandle - 1].type = DDrawHandle_StateBlock;
4571 hr = IWineD3DDevice_EndStateBlock(This->wineD3DDevice,
4572 (IWineD3DStateBlock **) &This->Handles[*BlockHandle - 1].ptr);
4573 return hr_ddraw_from_wined3d(hr);
4576 /*****************************************************************************
4577 * IDirect3DDevice7::PreLoad
4579 * Allows the app to signal that a texture will be used soon, to allow
4580 * the Direct3DDevice to load it to the video card in the meantime.
4585 * Texture: The texture to preload
4589 * DDERR_INVALIDPARAMS if Texture is NULL
4590 * See IWineD3DSurface::PreLoad for details
4592 *****************************************************************************/
4593 static HRESULT WINAPI
4594 IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7 *iface,
4595 IDirectDrawSurface7 *Texture)
4597 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4598 IDirectDrawSurfaceImpl *surf = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Texture);
4600 TRACE("(%p)->(%p): Relay!\n", This, surf);
4603 return DDERR_INVALIDPARAMS;
4605 IWineD3DSurface_PreLoad(surf->WineD3DSurface);
4609 /*****************************************************************************
4610 * IDirect3DDevice7::ApplyStateBlock
4612 * Activates the state stored in a state block handle.
4615 * BlockHandle: The stateblock handle to activate
4619 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4621 *****************************************************************************/
4622 static HRESULT WINAPI
4623 IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7 *iface,
4626 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4628 TRACE("(%p)->(%08x): Relay!\n", This, BlockHandle);
4630 if(!BlockHandle || BlockHandle > This->numHandles)
4632 WARN("Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle);
4633 return D3DERR_INVALIDSTATEBLOCK;
4635 if(This->Handles[BlockHandle - 1].type != DDrawHandle_StateBlock)
4637 WARN("Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle);
4638 return D3DERR_INVALIDSTATEBLOCK;
4641 hr = IWineD3DStateBlock_Apply((IWineD3DStateBlock *) This->Handles[BlockHandle - 1].ptr);
4642 return hr_ddraw_from_wined3d(hr);
4645 /*****************************************************************************
4646 * IDirect3DDevice7::CaptureStateBlock
4648 * Updates a stateblock's values to the values currently set for the device
4653 * BlockHandle: Stateblock to update
4657 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4658 * See IWineD3DDevice::CaptureStateBlock for more details
4660 *****************************************************************************/
4661 static HRESULT WINAPI
4662 IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7 *iface,
4665 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4667 TRACE("(%p)->(%08x): Relay!\n", This, BlockHandle);
4669 if(BlockHandle == 0 || BlockHandle > This->numHandles)
4671 WARN("Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle);
4672 return D3DERR_INVALIDSTATEBLOCK;
4674 if(This->Handles[BlockHandle - 1].type != DDrawHandle_StateBlock)
4676 WARN("Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle);
4677 return D3DERR_INVALIDSTATEBLOCK;
4680 hr = IWineD3DStateBlock_Capture((IWineD3DStateBlock *) This->Handles[BlockHandle - 1].ptr);
4681 return hr_ddraw_from_wined3d(hr);
4684 /*****************************************************************************
4685 * IDirect3DDevice7::DeleteStateBlock
4687 * Deletes a stateblock handle. This means releasing the WineD3DStateBlock
4692 * BlockHandle: Stateblock handle to delete
4696 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is 0
4698 *****************************************************************************/
4699 static HRESULT WINAPI
4700 IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7 *iface,
4703 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4705 TRACE("(%p)->(%08x): Relay!\n", This, BlockHandle);
4707 if(BlockHandle == 0 || BlockHandle > This->numHandles)
4709 WARN("Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle);
4710 return D3DERR_INVALIDSTATEBLOCK;
4712 if(This->Handles[BlockHandle - 1].type != DDrawHandle_StateBlock)
4714 WARN("Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle);
4715 return D3DERR_INVALIDSTATEBLOCK;
4718 ref = IWineD3DStateBlock_Release((IWineD3DStateBlock *) This->Handles[BlockHandle - 1].ptr);
4721 ERR("Something is still holding the stateblock %p(Handle %d). Ref = %d\n", This->Handles[BlockHandle - 1].ptr, BlockHandle, ref);
4723 This->Handles[BlockHandle - 1].ptr = NULL;
4724 This->Handles[BlockHandle - 1].type = DDrawHandle_Unknown;
4729 /*****************************************************************************
4730 * IDirect3DDevice7::CreateStateBlock
4732 * Creates a new state block handle.
4737 * Type: The state block type
4738 * BlockHandle: Address to write the created handle to
4742 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4744 *****************************************************************************/
4745 static HRESULT WINAPI
4746 IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
4747 D3DSTATEBLOCKTYPE Type,
4750 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4752 TRACE("(%p)->(%08x,%p)!\n", This, Type, BlockHandle);
4756 WARN("BlockHandle == NULL, returning DDERR_INVALIDPARAMS\n");
4757 return DDERR_INVALIDPARAMS;
4760 *BlockHandle = IDirect3DDeviceImpl_CreateHandle(This);
4763 ERR("Cannot get a handle number for the stateblock\n");
4764 return DDERR_OUTOFMEMORY;
4766 This->Handles[*BlockHandle - 1].type = DDrawHandle_StateBlock;
4768 /* The D3DSTATEBLOCKTYPE enum is fine here */
4769 hr = IWineD3DDevice_CreateStateBlock(This->wineD3DDevice,
4771 (IWineD3DStateBlock **) &This->Handles[*BlockHandle - 1].ptr,
4772 NULL /* Parent, hope that works */);
4773 return hr_ddraw_from_wined3d(hr);
4776 /*****************************************************************************
4777 * IDirect3DDevice7::Load
4779 * Loads a rectangular area from the source into the destination texture.
4780 * It can also copy the source to the faces of a cubic environment map
4785 * DestTex: Destination texture
4786 * DestPoint: Point in the destination where the source image should be
4788 * SrcTex: Source texture
4789 * SrcRect: Source rectangle
4794 * DDERR_INVALIDPARAMS if DestTex or SrcTex are NULL
4795 * See IDirect3DTexture2::Load for details
4797 *****************************************************************************/
4798 static HRESULT WINAPI
4799 IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
4800 IDirectDrawSurface7 *DestTex,
4802 IDirectDrawSurface7 *SrcTex,
4806 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4807 IDirectDrawSurfaceImpl *dest = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, DestTex);
4808 IDirectDrawSurfaceImpl *src = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, SrcTex);
4809 FIXME("(%p)->(%p,%p,%p,%p,%08x): Partially Implemented!\n", This, dest, DestPoint, src, SrcRect, Flags);
4811 if( (!src) || (!dest) )
4812 return DDERR_INVALIDPARAMS;
4814 IDirect3DTexture2_Load(ICOM_INTERFACE(dest, IDirect3DTexture2),
4815 ICOM_INTERFACE(src, IDirect3DTexture2));
4819 /*****************************************************************************
4820 * IDirect3DDevice7::LightEnable
4822 * Enables or disables a light
4824 * Version 7, IDirect3DLight uses this method too.
4827 * LightIndex: The index of the light to enable / disable
4828 * Enable: Enable or disable the light
4832 * For more details, see IWineD3DDevice::SetLightEnable
4834 *****************************************************************************/
4835 static HRESULT WINAPI
4836 IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7 *iface,
4840 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4842 TRACE("(%p)->(%08x,%d): Relay!\n", This, LightIndex, Enable);
4844 hr = IWineD3DDevice_SetLightEnable(This->wineD3DDevice, LightIndex, Enable);
4845 return hr_ddraw_from_wined3d(hr);
4848 /*****************************************************************************
4849 * IDirect3DDevice7::GetLightEnable
4851 * Retrieves if the light with the given index is enabled or not
4856 * LightIndex: Index of desired light
4857 * Enable: Pointer to a BOOL which contains the result
4861 * DDERR_INVALIDPARAMS if Enable is NULL
4862 * See IWineD3DDevice::GetLightEnable for more details
4864 *****************************************************************************/
4865 static HRESULT WINAPI
4866 IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7 *iface,
4870 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4872 TRACE("(%p)->(%08x,%p): Relay\n", This, LightIndex, Enable);
4875 return DDERR_INVALIDPARAMS;
4877 hr = IWineD3DDevice_GetLightEnable(This->wineD3DDevice, LightIndex, Enable);
4878 return hr_ddraw_from_wined3d(hr);
4881 /*****************************************************************************
4882 * IDirect3DDevice7::SetClipPlane
4884 * Sets custom clipping plane
4889 * Index: The index of the clipping plane
4890 * PlaneEquation: An equation defining the clipping plane
4894 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4895 * See IWineD3DDevice::SetClipPlane for more details
4897 *****************************************************************************/
4898 static HRESULT WINAPI
4899 IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7 *iface,
4901 D3DVALUE* PlaneEquation)
4903 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4904 TRACE("(%p)->(%08x,%p): Relay!\n", This, Index, PlaneEquation);
4907 return DDERR_INVALIDPARAMS;
4909 return IWineD3DDevice_SetClipPlane(This->wineD3DDevice, Index, PlaneEquation);
4912 /*****************************************************************************
4913 * IDirect3DDevice7::GetClipPlane
4915 * Returns the clipping plane with a specific index
4918 * Index: The index of the desired plane
4919 * PlaneEquation: Address to store the plane equation to
4923 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4924 * See IWineD3DDevice::GetClipPlane for more details
4926 *****************************************************************************/
4927 static HRESULT WINAPI
4928 IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7 *iface,
4930 D3DVALUE* PlaneEquation)
4932 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4933 TRACE("(%p)->(%d,%p): Relay!\n", This, Index, PlaneEquation);
4936 return DDERR_INVALIDPARAMS;
4938 return IWineD3DDevice_GetClipPlane(This->wineD3DDevice, Index, PlaneEquation);
4941 /*****************************************************************************
4942 * IDirect3DDevice7::GetInfo
4944 * Retrieves some information about the device. The DirectX sdk says that
4945 * this version returns S_FALSE for all retail builds of DirectX, that's what
4946 * this implementation does.
4949 * DevInfoID: Information type requested
4950 * DevInfoStruct: Pointer to a structure to store the info to
4951 * Size: Size of the structure
4954 * S_FALSE, because it's a non-debug driver
4956 *****************************************************************************/
4957 static HRESULT WINAPI
4958 IDirect3DDeviceImpl_7_GetInfo(IDirect3DDevice7 *iface,
4960 void *DevInfoStruct,
4963 ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
4964 TRACE("(%p)->(%08x,%p,%08x)\n", This, DevInfoID, DevInfoStruct, Size);
4968 TRACE(" info requested : ");
4971 case D3DDEVINFOID_TEXTUREMANAGER: TRACE("D3DDEVINFOID_TEXTUREMANAGER\n"); break;
4972 case D3DDEVINFOID_D3DTEXTUREMANAGER: TRACE("D3DDEVINFOID_D3DTEXTUREMANAGER\n"); break;
4973 case D3DDEVINFOID_TEXTURING: TRACE("D3DDEVINFOID_TEXTURING\n"); break;
4974 default: ERR(" invalid flag !!!\n"); return DDERR_INVALIDPARAMS;
4978 return S_FALSE; /* According to MSDN, this is valid for a non-debug driver */
4981 const IDirect3DDevice7Vtbl IDirect3DDevice7_Vtbl =
4983 /*** IUnknown Methods ***/
4984 IDirect3DDeviceImpl_7_QueryInterface,
4985 IDirect3DDeviceImpl_7_AddRef,
4986 IDirect3DDeviceImpl_7_Release,
4987 /*** IDirect3DDevice7 ***/
4988 IDirect3DDeviceImpl_7_GetCaps,
4989 IDirect3DDeviceImpl_7_EnumTextureFormats,
4990 IDirect3DDeviceImpl_7_BeginScene,
4991 IDirect3DDeviceImpl_7_EndScene,
4992 IDirect3DDeviceImpl_7_GetDirect3D,
4993 IDirect3DDeviceImpl_7_SetRenderTarget,
4994 IDirect3DDeviceImpl_7_GetRenderTarget,
4995 IDirect3DDeviceImpl_7_Clear,
4996 IDirect3DDeviceImpl_7_SetTransform,
4997 IDirect3DDeviceImpl_7_GetTransform,
4998 IDirect3DDeviceImpl_7_SetViewport,
4999 IDirect3DDeviceImpl_7_MultiplyTransform,
5000 IDirect3DDeviceImpl_7_GetViewport,
5001 IDirect3DDeviceImpl_7_SetMaterial,
5002 IDirect3DDeviceImpl_7_GetMaterial,
5003 IDirect3DDeviceImpl_7_SetLight,
5004 IDirect3DDeviceImpl_7_GetLight,
5005 IDirect3DDeviceImpl_7_SetRenderState,
5006 IDirect3DDeviceImpl_7_GetRenderState,
5007 IDirect3DDeviceImpl_7_BeginStateBlock,
5008 IDirect3DDeviceImpl_7_EndStateBlock,
5009 IDirect3DDeviceImpl_7_PreLoad,
5010 IDirect3DDeviceImpl_7_DrawPrimitive,
5011 IDirect3DDeviceImpl_7_DrawIndexedPrimitive,
5012 IDirect3DDeviceImpl_7_SetClipStatus,
5013 IDirect3DDeviceImpl_7_GetClipStatus,
5014 IDirect3DDeviceImpl_7_DrawPrimitiveStrided,
5015 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided,
5016 IDirect3DDeviceImpl_7_DrawPrimitiveVB,
5017 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB,
5018 IDirect3DDeviceImpl_7_ComputeSphereVisibility,
5019 IDirect3DDeviceImpl_7_GetTexture,
5020 IDirect3DDeviceImpl_7_SetTexture,
5021 IDirect3DDeviceImpl_7_GetTextureStageState,
5022 IDirect3DDeviceImpl_7_SetTextureStageState,
5023 IDirect3DDeviceImpl_7_ValidateDevice,
5024 IDirect3DDeviceImpl_7_ApplyStateBlock,
5025 IDirect3DDeviceImpl_7_CaptureStateBlock,
5026 IDirect3DDeviceImpl_7_DeleteStateBlock,
5027 IDirect3DDeviceImpl_7_CreateStateBlock,
5028 IDirect3DDeviceImpl_7_Load,
5029 IDirect3DDeviceImpl_7_LightEnable,
5030 IDirect3DDeviceImpl_7_GetLightEnable,
5031 IDirect3DDeviceImpl_7_SetClipPlane,
5032 IDirect3DDeviceImpl_7_GetClipPlane,
5033 IDirect3DDeviceImpl_7_GetInfo
5036 const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl =
5038 /*** IUnknown Methods ***/
5039 Thunk_IDirect3DDeviceImpl_3_QueryInterface,
5040 Thunk_IDirect3DDeviceImpl_3_AddRef,
5041 Thunk_IDirect3DDeviceImpl_3_Release,
5042 /*** IDirect3DDevice3 ***/
5043 IDirect3DDeviceImpl_3_GetCaps,
5044 IDirect3DDeviceImpl_3_GetStats,
5045 IDirect3DDeviceImpl_3_AddViewport,
5046 IDirect3DDeviceImpl_3_DeleteViewport,
5047 IDirect3DDeviceImpl_3_NextViewport,
5048 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats,
5049 Thunk_IDirect3DDeviceImpl_3_BeginScene,
5050 Thunk_IDirect3DDeviceImpl_3_EndScene,
5051 Thunk_IDirect3DDeviceImpl_3_GetDirect3D,
5052 IDirect3DDeviceImpl_3_SetCurrentViewport,
5053 IDirect3DDeviceImpl_3_GetCurrentViewport,
5054 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget,
5055 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget,
5056 IDirect3DDeviceImpl_3_Begin,
5057 IDirect3DDeviceImpl_3_BeginIndexed,
5058 IDirect3DDeviceImpl_3_Vertex,
5059 IDirect3DDeviceImpl_3_Index,
5060 IDirect3DDeviceImpl_3_End,
5061 Thunk_IDirect3DDeviceImpl_3_GetRenderState,
5062 Thunk_IDirect3DDeviceImpl_3_SetRenderState,
5063 IDirect3DDeviceImpl_3_GetLightState,
5064 IDirect3DDeviceImpl_3_SetLightState,
5065 Thunk_IDirect3DDeviceImpl_3_SetTransform,
5066 Thunk_IDirect3DDeviceImpl_3_GetTransform,
5067 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform,
5068 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive,
5069 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive,
5070 Thunk_IDirect3DDeviceImpl_3_SetClipStatus,
5071 Thunk_IDirect3DDeviceImpl_3_GetClipStatus,
5072 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided,
5073 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided,
5074 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB,
5075 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB,
5076 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility,
5077 Thunk_IDirect3DDeviceImpl_3_GetTexture,
5078 Thunk_IDirect3DDeviceImpl_3_SetTexture,
5079 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState,
5080 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState,
5081 Thunk_IDirect3DDeviceImpl_3_ValidateDevice
5084 const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl =
5086 /*** IUnknown Methods ***/
5087 Thunk_IDirect3DDeviceImpl_2_QueryInterface,
5088 Thunk_IDirect3DDeviceImpl_2_AddRef,
5089 Thunk_IDirect3DDeviceImpl_2_Release,
5090 /*** IDirect3DDevice2 ***/
5091 Thunk_IDirect3DDeviceImpl_2_GetCaps,
5092 IDirect3DDeviceImpl_2_SwapTextureHandles,
5093 Thunk_IDirect3DDeviceImpl_2_GetStats,
5094 Thunk_IDirect3DDeviceImpl_2_AddViewport,
5095 Thunk_IDirect3DDeviceImpl_2_DeleteViewport,
5096 Thunk_IDirect3DDeviceImpl_2_NextViewport,
5097 IDirect3DDeviceImpl_2_EnumTextureFormats,
5098 Thunk_IDirect3DDeviceImpl_2_BeginScene,
5099 Thunk_IDirect3DDeviceImpl_2_EndScene,
5100 Thunk_IDirect3DDeviceImpl_2_GetDirect3D,
5101 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport,
5102 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport,
5103 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget,
5104 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget,
5105 Thunk_IDirect3DDeviceImpl_2_Begin,
5106 Thunk_IDirect3DDeviceImpl_2_BeginIndexed,
5107 Thunk_IDirect3DDeviceImpl_2_Vertex,
5108 Thunk_IDirect3DDeviceImpl_2_Index,
5109 Thunk_IDirect3DDeviceImpl_2_End,
5110 Thunk_IDirect3DDeviceImpl_2_GetRenderState,
5111 Thunk_IDirect3DDeviceImpl_2_SetRenderState,
5112 Thunk_IDirect3DDeviceImpl_2_GetLightState,
5113 Thunk_IDirect3DDeviceImpl_2_SetLightState,
5114 Thunk_IDirect3DDeviceImpl_2_SetTransform,
5115 Thunk_IDirect3DDeviceImpl_2_GetTransform,
5116 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform,
5117 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive,
5118 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive,
5119 Thunk_IDirect3DDeviceImpl_2_SetClipStatus,
5120 Thunk_IDirect3DDeviceImpl_2_GetClipStatus
5123 const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl =
5125 /*** IUnknown Methods ***/
5126 Thunk_IDirect3DDeviceImpl_1_QueryInterface,
5127 Thunk_IDirect3DDeviceImpl_1_AddRef,
5128 Thunk_IDirect3DDeviceImpl_1_Release,
5129 /*** IDirect3DDevice1 ***/
5130 IDirect3DDeviceImpl_1_Initialize,
5131 Thunk_IDirect3DDeviceImpl_1_GetCaps,
5132 Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles,
5133 IDirect3DDeviceImpl_1_CreateExecuteBuffer,
5134 Thunk_IDirect3DDeviceImpl_1_GetStats,
5135 IDirect3DDeviceImpl_1_Execute,
5136 Thunk_IDirect3DDeviceImpl_1_AddViewport,
5137 Thunk_IDirect3DDeviceImpl_1_DeleteViewport,
5138 Thunk_IDirect3DDeviceImpl_1_NextViewport,
5139 IDirect3DDeviceImpl_1_Pick,
5140 IDirect3DDeviceImpl_1_GetPickRecords,
5141 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats,
5142 IDirect3DDeviceImpl_1_CreateMatrix,
5143 IDirect3DDeviceImpl_1_SetMatrix,
5144 IDirect3DDeviceImpl_1_GetMatrix,
5145 IDirect3DDeviceImpl_1_DeleteMatrix,
5146 Thunk_IDirect3DDeviceImpl_1_EndScene,
5147 Thunk_IDirect3DDeviceImpl_1_BeginScene,
5148 Thunk_IDirect3DDeviceImpl_1_GetDirect3D
5151 /*****************************************************************************
5152 * IDirect3DDeviceImpl_CreateHandle
5154 * Not called from the VTable
5156 * Some older interface versions operate with handles, which are basically
5157 * DWORDs which identify an interface, for example
5158 * IDirect3DDevice::SetRenderState with DIRECT3DRENDERSTATE_TEXTUREHANDLE
5160 * Those handle could be just casts to the interface pointers or vice versa,
5161 * but that is not 64 bit safe and would mean blindly derefering a DWORD
5162 * passed by the app. Instead there is a dynamic array in the device which
5163 * keeps a DWORD to pointer information and a type for the handle.
5165 * Basically this array only grows, when a handle is freed its pointer is
5166 * just set to NULL. There will be much more reads from the array than
5167 * insertion operations, so a dynamic array is fine.
5170 * This: D3DDevice implementation for which this handle should be created
5173 * A free handle on success
5176 *****************************************************************************/
5178 IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl *This)
5181 struct HandleEntry *oldHandles = This->Handles;
5183 TRACE("(%p)\n", This);
5185 for(i = 0; i < This->numHandles; i++)
5187 if(This->Handles[i].ptr == NULL &&
5188 This->Handles[i].type == DDrawHandle_Unknown)
5190 TRACE("Reusing freed handle %d\n", i + 1);
5195 TRACE("Growing the handle array\n");
5198 This->Handles = HeapAlloc(GetProcessHeap(), 0, sizeof(struct HandleEntry) * This->numHandles);
5201 ERR("Out of memory\n");
5202 This->Handles = oldHandles;
5208 memcpy(This->Handles, oldHandles, (This->numHandles - 1) * sizeof(struct HandleEntry));
5209 HeapFree(GetProcessHeap(), 0, oldHandles);
5212 TRACE("Returning %d\n", This->numHandles);
5213 return This->numHandles;
5216 /*****************************************************************************
5217 * IDirect3DDeviceImpl_UpdateDepthStencil
5219 * Checks the current render target for attached depth stencils and sets the
5220 * WineD3D depth stencil accordingly.
5223 * The depth stencil state to set if creating the device
5225 *****************************************************************************/
5227 IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This)
5229 IDirectDrawSurface7 *depthStencil = NULL;
5230 IDirectDrawSurfaceImpl *dsi;
5231 static DDSCAPS2 depthcaps = { DDSCAPS_ZBUFFER, 0, 0, 0 };
5233 IDirectDrawSurface7_GetAttachedSurface(ICOM_INTERFACE(This->target, IDirectDrawSurface7),
5238 TRACE("Setting wined3d depth stencil to NULL\n");
5239 IWineD3DDevice_SetDepthStencilSurface(This->wineD3DDevice,
5241 return WINED3DZB_FALSE;
5244 dsi = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, depthStencil);
5245 TRACE("Setting wined3d depth stencil to %p (wined3d %p)\n", dsi, dsi->WineD3DSurface);
5246 IWineD3DDevice_SetDepthStencilSurface(This->wineD3DDevice,
5247 dsi->WineD3DSurface);
5249 IDirectDrawSurface7_Release(depthStencil);
5250 return WINED3DZB_TRUE;