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"
45 #include "wine/exception.h"
51 #include "ddraw_private.h"
53 WINE_DEFAULT_DEBUG_CHANNEL(d3d7
);
54 WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk
);
57 const GUID IID_D3DDEVICE_WineD3D
= {
61 { 0xb7,0x98,0xc6,0x8a,0x77,0x2d,0x72,0x2a }
64 /*****************************************************************************
65 * IUnknown Methods. Common for Version 1, 2, 3 and 7
66 *****************************************************************************/
68 /*****************************************************************************
69 * IDirect3DDevice7::QueryInterface
71 * Used to query other interfaces from a Direct3DDevice interface.
72 * It can return interface pointers to all Direct3DDevice versions as well
73 * as IDirectDraw and IDirect3D. For a link to QueryInterface
74 * rules see ddraw.c, IDirectDraw7::QueryInterface
76 * Exists in Version 1, 2, 3 and 7
79 * refiid: Interface ID queried for
80 * obj: Used to return the interface pointer
83 * D3D_OK or E_NOINTERFACE
85 *****************************************************************************/
87 IDirect3DDeviceImpl_7_QueryInterface(IDirect3DDevice7
*iface
,
91 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
92 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(refiid
), obj
);
94 /* According to COM docs, if the QueryInterface fails, obj should be set to NULL */
98 return DDERR_INVALIDPARAMS
;
100 if ( IsEqualGUID( &IID_IUnknown
, refiid
) )
102 *obj
= ICOM_INTERFACE(This
, IDirect3DDevice7
);
105 /* Check DirectDraw Interfac\x01s */
106 else if( IsEqualGUID( &IID_IDirectDraw7
, refiid
) )
108 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirectDraw7
);
109 TRACE("(%p) Returning IDirectDraw7 interface at %p\n", This
, *obj
);
111 else if ( IsEqualGUID( &IID_IDirectDraw4
, refiid
) )
113 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirectDraw4
);
114 TRACE("(%p) Returning IDirectDraw4 interface at %p\n", This
, *obj
);
116 else if ( IsEqualGUID( &IID_IDirectDraw2
, refiid
) )
118 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirectDraw2
);
119 TRACE("(%p) Returning IDirectDraw2 interface at %p\n", This
, *obj
);
121 else if( IsEqualGUID( &IID_IDirectDraw
, refiid
) )
123 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirectDraw
);
124 TRACE("(%p) Returning IDirectDraw interface at %p\n", This
, *obj
);
128 else if ( IsEqualGUID( &IID_IDirect3D
, refiid
) )
130 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirect3D
);
131 TRACE("(%p) Returning IDirect3D interface at %p\n", This
, *obj
);
133 else if ( IsEqualGUID( &IID_IDirect3D2
, refiid
) )
135 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirect3D2
);
136 TRACE("(%p) Returning IDirect3D2 interface at %p\n", This
, *obj
);
138 else if ( IsEqualGUID( &IID_IDirect3D3
, refiid
) )
140 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirect3D3
);
141 TRACE("(%p) Returning IDirect3D3 interface at %p\n", This
, *obj
);
143 else if ( IsEqualGUID( &IID_IDirect3D7
, refiid
) )
145 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirect3D7
);
146 TRACE("(%p) Returning IDirect3D7 interface at %p\n", This
, *obj
);
150 else if ( IsEqualGUID( &IID_IDirect3DDevice
, refiid
) )
152 *obj
= ICOM_INTERFACE(This
, IDirect3DDevice
);
153 TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This
, *obj
);
155 else if ( IsEqualGUID( &IID_IDirect3DDevice2
, refiid
) ) {
156 *obj
= ICOM_INTERFACE(This
, IDirect3DDevice2
);
157 TRACE("(%p) Returning IDirect3DDevice2 interface at %p\n", This
, *obj
);
159 else if ( IsEqualGUID( &IID_IDirect3DDevice3
, refiid
) ) {
160 *obj
= ICOM_INTERFACE(This
, IDirect3DDevice3
);
161 TRACE("(%p) Returning IDirect3DDevice3 interface at %p\n", This
, *obj
);
163 else if ( IsEqualGUID( &IID_IDirect3DDevice7
, refiid
) ) {
164 *obj
= ICOM_INTERFACE(This
, IDirect3DDevice7
);
165 TRACE("(%p) Returning IDirect3DDevice7 interface at %p\n", This
, *obj
);
168 /* Unknown interface */
171 ERR("(%p)->(%s, %p): No interface found", This
, debugstr_guid(refiid
), obj
);
172 return E_NOINTERFACE
;
175 /* AddRef the returned interface */
176 IUnknown_AddRef( (IUnknown
*) *obj
);
180 static HRESULT WINAPI
181 Thunk_IDirect3DDeviceImpl_3_QueryInterface(IDirect3DDevice3
*iface
,
185 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
186 TRACE_(ddraw_thunk
)("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", This
, debugstr_guid(riid
), obj
);
187 return IDirect3DDevice7_QueryInterface(ICOM_INTERFACE(This
, IDirect3DDevice7
),
192 static HRESULT WINAPI
193 Thunk_IDirect3DDeviceImpl_2_QueryInterface(IDirect3DDevice2
*iface
,
197 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
198 TRACE_(ddraw_thunk
)("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", This
, debugstr_guid(riid
), obj
);
199 return IDirect3DDevice7_QueryInterface(ICOM_INTERFACE(This
, IDirect3DDevice7
),
204 static HRESULT WINAPI
205 Thunk_IDirect3DDeviceImpl_1_QueryInterface(IDirect3DDevice
*iface
,
209 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
210 TRACE_(ddraw_thunk
)("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", This
, debugstr_guid(riid
), obp
);
211 return IDirect3DDevice7_QueryInterface(ICOM_INTERFACE(This
, IDirect3DDevice7
),
216 /*****************************************************************************
217 * IDirect3DDevice7::AddRef
219 * Increases the refcount....
220 * The most exciting Method, definitely
222 * Exists in Version 1, 2, 3 and 7
227 *****************************************************************************/
229 IDirect3DDeviceImpl_7_AddRef(IDirect3DDevice7
*iface
)
231 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
232 ULONG ref
= InterlockedIncrement(&This
->ref
);
234 TRACE("(%p) : incrementing from %lu.\n", This
, ref
-1);
240 Thunk_IDirect3DDeviceImpl_3_AddRef(IDirect3DDevice3
*iface
)
242 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
243 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
244 return IDirect3DDevice7_AddRef(ICOM_INTERFACE(This
, IDirect3DDevice7
));
248 Thunk_IDirect3DDeviceImpl_2_AddRef(IDirect3DDevice2
*iface
)
250 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
251 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
252 return IDirect3DDevice7_AddRef(ICOM_INTERFACE(This
, IDirect3DDevice7
));
256 Thunk_IDirect3DDeviceImpl_1_AddRef(IDirect3DDevice
*iface
)
258 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface
);
259 return IDirect3DDevice7_AddRef(COM_INTERFACE_CAST(IDirect3DDeviceImpl
, IDirect3DDevice
, IDirect3DDevice7
, iface
));
262 /*****************************************************************************
263 * IDirect3DDevice7::Release
265 * Decreases the refcount of the interface
266 * When the refcount is reduced to 0, the object is destroyed.
268 * Exists in Version 1, 2, 3 and 7
273 *****************************************************************************/
275 IDirect3DDeviceImpl_7_Release(IDirect3DDevice7
*iface
)
277 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
278 ULONG ref
= InterlockedDecrement(&This
->ref
);
280 TRACE("(%p)->() decrementing from %lu.\n", This
, ref
+1);
282 /* This method doesn't destroy the WineD3DDevice, because it's still in use for
283 * 2D rendering. IDirectDrawSurface7::Release will destroy the WineD3DDevice
284 * when the render target is released
288 IParent
*IndexBufferParent
;
291 /* Free the index buffer */
292 IWineD3DDevice_SetIndices(This
->wineD3DDevice
,
295 IWineD3DIndexBuffer_GetParent(This
->indexbuffer
,
296 (IUnknown
**) &IndexBufferParent
);
297 IParent_Release(IndexBufferParent
); /* Once for the getParent */
298 if( IParent_Release(IndexBufferParent
) != 0) /* And now to destroy it */
300 ERR(" (%p) Something is still holding the index buffer parent %p\n", This
, IndexBufferParent
);
303 /* Restore the render targets */
304 if(This
->OffScreenTarget
)
306 /* This->target is the offscreen target.
307 * This->ddraw->d3d_target is the target used by DDraw
309 TRACE("(%p) Release: Using %p as front buffer, %p as back buffer\n", This
, This
->ddraw
->d3d_target
, NULL
);
310 IWineD3DDevice_SetFrontBackBuffers(This
->wineD3DDevice
,
311 This
->ddraw
->d3d_target
->WineD3DSurface
,
315 /* Release the WineD3DDevice. This won't destroy it */
316 if(IWineD3DDevice_Release(This
->wineD3DDevice
) <= 0)
318 ERR(" (%p) The wineD3D device %p was destroyed unexpectadely. Prepare for trouble\n", This
, This
->wineD3DDevice
);
321 /* The texture handles should be unset by now, but there might be some bits
322 * missing in our reference counting(needs test). Do a sanity check
324 for(i
= 0; i
< This
->numHandles
; i
++)
326 if(This
->Handles
[i
].ptr
)
328 switch(This
->Handles
[i
].type
)
330 case DDrawHandle_Texture
:
332 IDirectDrawSurfaceImpl
*surf
= (IDirectDrawSurfaceImpl
*) This
->Handles
[i
].ptr
;
333 FIXME("Texture Handle %ld not unset properly\n", i
+ 1);
338 case DDrawHandle_Material
:
340 IDirect3DMaterialImpl
*mat
= (IDirect3DMaterialImpl
*) This
->Handles
[i
].ptr
;
341 FIXME("Material handle %ld not unset properly\n", i
+ 1);
346 case DDrawHandle_Matrix
:
348 /* No fixme here because this might happen because of sloppy apps */
349 WARN("Leftover matrix handle %ld, deleting\n", i
+ 1);
350 IDirect3DDevice_DeleteMatrix(ICOM_INTERFACE(This
, IDirect3DDevice
),
356 FIXME("Unknown handle %ld not unset properly\n", i
+ 1);
361 HeapFree(GetProcessHeap(), 0, This
->Handles
);
363 /* Release the render target and the WineD3D render target
364 * (See IDirect3D7::CreateDevice for more comments on this)
366 IDirectDrawSurface7_Release(ICOM_INTERFACE(This
->target
, IDirectDrawSurface7
));
367 IDirectDrawSurface7_Release(ICOM_INTERFACE(This
->ddraw
->d3d_target
,IDirectDrawSurface7
));
369 This
->ddraw
->d3ddevice
= NULL
;
371 /* Now free the structure */
372 HeapFree(GetProcessHeap(), 0, This
);
379 Thunk_IDirect3DDeviceImpl_3_Release(IDirect3DDevice3
*iface
)
381 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
382 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
383 return IDirect3DDevice7_Release(ICOM_INTERFACE(This
, IDirect3DDevice7
));
387 Thunk_IDirect3DDeviceImpl_2_Release(IDirect3DDevice2
*iface
)
389 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
390 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
391 return IDirect3DDevice7_Release(ICOM_INTERFACE(This
, IDirect3DDevice7
));
395 Thunk_IDirect3DDeviceImpl_1_Release(IDirect3DDevice
*iface
)
397 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
398 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
399 return IDirect3DDevice7_Release(ICOM_INTERFACE(This
, IDirect3DDevice7
));
402 /*****************************************************************************
403 * IDirect3DDevice Methods
404 *****************************************************************************/
406 /*****************************************************************************
407 * IDirect3DDevice::Initialize
409 * Initializes a Direct3DDevice. This implementation is a no-op, as all
410 * initialization is done at create time.
412 * Exists in Version 1
415 * No idea what they mean, as the MSDN page is gone
419 *****************************************************************************/
420 static HRESULT WINAPI
421 IDirect3DDeviceImpl_1_Initialize(IDirect3DDevice
*iface
,
422 IDirect3D
*Direct3D
, GUID
*guid
,
425 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
427 /* It shouldn't be crucial, but print a FIXME, I'm interested if
428 * any game calls it and when
430 FIXME("(%p)->(%p,%p,%p): No-op!\n", This
, Direct3D
, guid
, Desc
);
435 /*****************************************************************************
436 * IDirect3DDevice7::GetCaps
438 * Retrieves the device's capabilities
440 * This implementation is used for Version 7 only, the older versions have
441 * their own implementation.
444 * Desc: Pointer to a D3DDEVICEDESC7 structure to fill
448 * D3DERR_* if a problem occurs. See WineD3D
450 *****************************************************************************/
451 static HRESULT WINAPI
452 IDirect3DDeviceImpl_7_GetCaps(IDirect3DDevice7
*iface
,
453 D3DDEVICEDESC7
*Desc
)
455 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
456 D3DDEVICEDESC OldDesc
;
457 TRACE("(%p)->(%p)\n", This
, Desc
);
459 /* Call the same function used by IDirect3D, this saves code */
460 return IDirect3DImpl_GetCaps(This
->ddraw
->wineD3D
, &OldDesc
, Desc
);
463 /*****************************************************************************
464 * IDirect3DDevice3::GetCaps
466 * Retrieves the capabilities of the hardware device and the emulation
467 * device. For Wine, hardware and emulation are the same (it's all HW).
469 * This implementation is used for Version 1, 2, and 3. Version 7 has its own
472 * HWDesc: Structure to fill with the HW caps
473 * HelDesc: Structure to fill with the hardare emulation caps
477 * D3DERR_* if a problem occurs. See WineD3D
479 *****************************************************************************/
480 static HRESULT WINAPI
481 IDirect3DDeviceImpl_3_GetCaps(IDirect3DDevice3
*iface
,
482 D3DDEVICEDESC
*HWDesc
,
483 D3DDEVICEDESC
*HelDesc
)
485 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
486 D3DDEVICEDESC7 newDesc
;
488 TRACE("(%p)->(%p,%p)\n", iface
, HWDesc
, HelDesc
);
490 hr
= IDirect3DImpl_GetCaps(This
->ddraw
->wineD3D
, HWDesc
, &newDesc
);
491 if(hr
!= D3D_OK
) return hr
;
497 static HRESULT WINAPI
498 Thunk_IDirect3DDeviceImpl_2_GetCaps(IDirect3DDevice2
*iface
,
499 D3DDEVICEDESC
*D3DHWDevDesc
,
500 D3DDEVICEDESC
*D3DHELDevDesc
)
502 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
503 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice3 interface.\n", This
, D3DHWDevDesc
, D3DHELDevDesc
);
504 return IDirect3DDevice3_GetCaps(ICOM_INTERFACE(This
, IDirect3DDevice3
),
509 static HRESULT WINAPI
510 Thunk_IDirect3DDeviceImpl_1_GetCaps(IDirect3DDevice
*iface
,
511 D3DDEVICEDESC
*D3DHWDevDesc
,
512 D3DDEVICEDESC
*D3DHELDevDesc
)
514 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
515 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice3 interface.\n", This
, D3DHWDevDesc
, D3DHELDevDesc
);
516 return IDirect3DDevice3_GetCaps(ICOM_INTERFACE(This
, IDirect3DDevice3
),
521 /*****************************************************************************
522 * IDirect3DDevice2::SwapTextureHandles
524 * Swaps the texture handles of 2 Texture interfaces. Version 1 and 2
527 * Tex1, Tex2: The 2 Textures to swap
532 *****************************************************************************/
533 static HRESULT WINAPI
534 IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2
*iface
,
535 IDirect3DTexture2
*Tex1
,
536 IDirect3DTexture2
*Tex2
)
538 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
540 IDirectDrawSurfaceImpl
*surf1
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Tex1
);
541 IDirectDrawSurfaceImpl
*surf2
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Tex2
);
542 TRACE("(%p)->(%p,%p)\n", This
, surf1
, surf2
);
544 This
->Handles
[surf1
->Handle
- 1].ptr
= surf2
;
545 This
->Handles
[surf2
->Handle
- 1].ptr
= surf1
;
547 swap
= surf2
->Handle
;
548 surf2
->Handle
= surf1
->Handle
;
549 surf1
->Handle
= swap
;
554 static HRESULT WINAPI
555 Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles(IDirect3DDevice
*iface
,
556 IDirect3DTexture
*D3DTex1
,
557 IDirect3DTexture
*D3DTex2
)
559 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
560 IDirectDrawSurfaceImpl
*surf1
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture
, D3DTex1
);
561 IDirectDrawSurfaceImpl
*surf2
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture
, D3DTex2
);
562 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", This
, surf1
, surf2
);
563 return IDirect3DDevice2_SwapTextureHandles(ICOM_INTERFACE(This
, IDirect3DDevice2
),
564 ICOM_INTERFACE(surf1
, IDirect3DTexture2
),
565 ICOM_INTERFACE(surf2
, IDirect3DTexture2
));
568 /*****************************************************************************
569 * IDirect3DDevice3::GetStats
571 * This method seems to retrieve some stats from the device.
572 * The MSDN documentation doesn't exist any more, but the D3DSTATS
573 * structure suggests that the amout of drawn primitives and processed
574 * vertices is returned.
576 * Exists in Version 1, 2 and 3
579 * Stats: Pointer to a D3DSTATS structure to be filled
583 * DDERR_INVALIDPARAMS if Stats == NULL
585 *****************************************************************************/
586 static HRESULT WINAPI
587 IDirect3DDeviceImpl_3_GetStats(IDirect3DDevice3
*iface
,
590 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
591 FIXME("(%p)->(%p): Stub!\n", This
, Stats
);
594 return DDERR_INVALIDPARAMS
;
596 /* Fill the Stats with 0 */
597 Stats
->dwTrianglesDrawn
= 0;
598 Stats
->dwLinesDrawn
= 0;
599 Stats
->dwPointsDrawn
= 0;
600 Stats
->dwSpansDrawn
= 0;
601 Stats
->dwVerticesProcessed
= 0;
606 static HRESULT WINAPI
607 Thunk_IDirect3DDeviceImpl_2_GetStats(IDirect3DDevice2
*iface
,
610 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
611 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Stats
);
612 return IDirect3DDevice3_GetStats(ICOM_INTERFACE(This
, IDirect3DDevice3
),
616 static HRESULT WINAPI
617 Thunk_IDirect3DDeviceImpl_1_GetStats(IDirect3DDevice
*iface
,
620 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
621 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Stats
);
622 return IDirect3DDevice3_GetStats(ICOM_INTERFACE(This
, IDirect3DDevice3
),
626 /*****************************************************************************
627 * IDirect3DDevice::CreateExecuteBuffer
629 * Creates an IDirect3DExecuteBuffer, used for rendering with a
635 * Desc: Buffer description
636 * ExecuteBuffer: Address to return the Interface pointer at
637 * UnkOuter: Must be NULL. Basically for aggregation, which ddraw doesn't
641 * CLASS_E_NOAGGREGATION if UnkOuter != NULL
642 * DDERR_OUTOFMEMORY if we ran out of memory
645 *****************************************************************************/
646 static HRESULT WINAPI
647 IDirect3DDeviceImpl_1_CreateExecuteBuffer(IDirect3DDevice
*iface
,
648 D3DEXECUTEBUFFERDESC
*Desc
,
649 IDirect3DExecuteBuffer
**ExecuteBuffer
,
652 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
653 IDirect3DExecuteBufferImpl
* object
;
654 TRACE("(%p)->(%p,%p,%p)!\n", This
, Desc
, ExecuteBuffer
, UnkOuter
);
657 return CLASS_E_NOAGGREGATION
;
659 /* Allocate the new Execute Buffer */
660 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DExecuteBufferImpl
));
663 ERR("Out of memory when allocating a IDirect3DExecuteBufferImpl structure\n");
664 return DDERR_OUTOFMEMORY
;
667 ICOM_INIT_INTERFACE(object
, IDirect3DExecuteBuffer
, IDirect3DExecuteBuffer_Vtbl
);
670 object
->d3ddev
= This
;
672 /* Initializes memory */
673 memcpy(&object
->desc
, Desc
, Desc
->dwSize
);
675 /* No buffer given */
676 if ((object
->desc
.dwFlags
& D3DDEB_LPDATA
) == 0)
677 object
->desc
.lpData
= NULL
;
679 /* No buffer size given */
680 if ((object
->desc
.dwFlags
& D3DDEB_BUFSIZE
) == 0)
681 object
->desc
.dwBufferSize
= 0;
683 /* Create buffer if asked */
684 if ((object
->desc
.lpData
== NULL
) && (object
->desc
.dwBufferSize
> 0))
686 object
->need_free
= TRUE
;
687 object
->desc
.lpData
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,object
->desc
.dwBufferSize
);
688 if(!object
->desc
.lpData
)
690 ERR("Out of memory when allocating the execute buffer data\n");
691 HeapFree(GetProcessHeap(), 0, object
);
692 return DDERR_OUTOFMEMORY
;
697 object
->need_free
= FALSE
;
700 /* No vertices for the moment */
701 object
->vertex_data
= NULL
;
703 object
->desc
.dwFlags
|= D3DDEB_LPDATA
;
705 object
->indices
= NULL
;
706 object
->nb_indices
= 0;
708 *ExecuteBuffer
= ICOM_INTERFACE(object
, IDirect3DExecuteBuffer
);
710 TRACE(" Returning IDirect3DExecuteBuffer at %p, implementation is at %p\n", *ExecuteBuffer
, object
);
715 /*****************************************************************************
716 * IDirect3DDevice::Execute
718 * Executes all the stuff in an execute buffer.
721 * ExecuteBuffer: The buffer to execute
722 * Viewport: The viewport used for rendering
726 * DDERR_INVALIDPARAMS if ExecuteBuffer == NULL
729 *****************************************************************************/
730 static HRESULT WINAPI
731 IDirect3DDeviceImpl_1_Execute(IDirect3DDevice
*iface
,
732 IDirect3DExecuteBuffer
*ExecuteBuffer
,
733 IDirect3DViewport
*Viewport
,
736 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
737 IDirect3DExecuteBufferImpl
*Direct3DExecuteBufferImpl
= ICOM_OBJECT(IDirect3DExecuteBufferImpl
, IDirect3DExecuteBuffer
, ExecuteBuffer
);
738 IDirect3DViewportImpl
*Direct3DViewportImpl
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
740 TRACE("(%p)->(%p,%p,%08lx)\n", This
, Direct3DExecuteBufferImpl
, Direct3DViewportImpl
, Flags
);
742 if(!Direct3DExecuteBufferImpl
)
743 return DDERR_INVALIDPARAMS
;
746 IDirect3DExecuteBufferImpl_Execute(Direct3DExecuteBufferImpl
, This
, Direct3DViewportImpl
);
751 /*****************************************************************************
752 * IDirect3DDevice3::AddViewport
754 * Add a Direct3DViewport to the device's viewport list. These viewports
755 * are wrapped to IDirect3DDevice7 viewports in viewport.c
757 * Exists in Version 1, 2 and 3. Note that IDirect3DViewport 1, 2 and 3
758 * are the same interfaces.
761 * Viewport: The viewport to add
764 * DDERR_INVALIDPARAMS if Viewport == NULL
767 *****************************************************************************/
768 static HRESULT WINAPI
769 IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3
*iface
,
770 IDirect3DViewport3
*Viewport
)
772 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
773 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
775 TRACE("(%p)->(%p)\n", This
, vp
);
779 return DDERR_INVALIDPARAMS
;
781 vp
->next
= This
->viewport_list
;
782 This
->viewport_list
= vp
;
787 static HRESULT WINAPI
788 Thunk_IDirect3DDeviceImpl_2_AddViewport(IDirect3DDevice2
*iface
,
789 IDirect3DViewport2
*Direct3DViewport2
)
791 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
792 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
793 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
794 return IDirect3DDevice3_AddViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
795 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
798 static HRESULT WINAPI
799 Thunk_IDirect3DDeviceImpl_1_AddViewport(IDirect3DDevice
*iface
,
800 IDirect3DViewport
*Direct3DViewport
)
802 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
803 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport
);
804 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
805 return IDirect3DDevice3_AddViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
806 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
809 /*****************************************************************************
810 * IDirect3DDevice3::DeleteViewport
812 * Deletes a Direct3DViewport from the device's viewport list.
814 * Exists in Version 1, 2 and 3. Note that all Viewport interface versions
818 * Viewport: The viewport to delete
822 * DDERR_INVALIDPARAMS if the viewport wasn't found in the list
824 *****************************************************************************/
825 static HRESULT WINAPI
826 IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3
*iface
,
827 IDirect3DViewport3
*Viewport
)
829 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
830 IDirect3DViewportImpl
*vp
= (IDirect3DViewportImpl
*) Viewport
;
831 IDirect3DViewportImpl
*cur_viewport
, *prev_viewport
= NULL
;
833 TRACE("(%p)->(%p)\n", This
, vp
);
835 cur_viewport
= This
->viewport_list
;
836 while (cur_viewport
!= NULL
)
838 if (cur_viewport
== vp
)
840 if (prev_viewport
== NULL
) This
->viewport_list
= cur_viewport
->next
;
841 else prev_viewport
->next
= cur_viewport
->next
;
842 /* TODO : add desactivate of the viewport and all associated lights... */
845 prev_viewport
= cur_viewport
;
846 cur_viewport
= cur_viewport
->next
;
849 return DDERR_INVALIDPARAMS
;
852 static HRESULT WINAPI
853 Thunk_IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2
*iface
,
854 IDirect3DViewport2
*Direct3DViewport2
)
856 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
857 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
858 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
859 return IDirect3DDevice3_DeleteViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
860 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
863 static HRESULT WINAPI
864 Thunk_IDirect3DDeviceImpl_1_DeleteViewport(IDirect3DDevice
*iface
,
865 IDirect3DViewport
*Direct3DViewport2
)
867 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
868 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
869 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
870 return IDirect3DDevice3_DeleteViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
871 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
874 /*****************************************************************************
875 * IDirect3DDevice3::NextViewport
877 * Returns a viewport from the viewport list, depending on the
878 * passed viewport and the flags.
880 * Exists in Version 1, 2 and 3. Note that all Viewport interface versions
884 * Viewport: Viewport to use for beginning the search
885 * Flags: D3DNEXT_NEXT, D3DNEXT_HEAD or D3DNEXT_TAIL
889 * DDERR_INVALIDPARAMS if the flags were wrong, or Viewport was NULL
891 *****************************************************************************/
892 static HRESULT WINAPI
893 IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3
*iface
,
894 IDirect3DViewport3
*Viewport3
,
895 IDirect3DViewport3
**lplpDirect3DViewport3
,
898 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
899 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport3
);
900 IDirect3DViewportImpl
*res
= NULL
;
902 TRACE("(%p)->(%p,%p,%08lx)\n", This
, vp
, lplpDirect3DViewport3
, Flags
);
906 return DDERR_INVALIDPARAMS
;
907 *lplpDirect3DViewport3
= NULL
;
920 res
= This
->viewport_list
;
925 IDirect3DViewportImpl
*cur_viewport
= This
->viewport_list
;
926 if (cur_viewport
!= NULL
)
928 while (cur_viewport
->next
!= NULL
) cur_viewport
= cur_viewport
->next
;
934 *lplpDirect3DViewport3
= NULL
;
935 return DDERR_INVALIDPARAMS
;
938 *lplpDirect3DViewport3
= ICOM_INTERFACE(res
, IDirect3DViewport3
);
942 static HRESULT WINAPI
943 Thunk_IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2
*iface
,
944 IDirect3DViewport2
*Viewport2
,
945 IDirect3DViewport2
**lplpDirect3DViewport2
,
948 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
949 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport2
);
950 IDirect3DViewport3
*res
;
952 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08lx) thunking to IDirect3DDevice3 interface.\n", This
, vp
, lplpDirect3DViewport2
, Flags
);
953 hr
= IDirect3DDevice3_NextViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
954 ICOM_INTERFACE(vp
, IDirect3DViewport3
),
957 *lplpDirect3DViewport2
= (IDirect3DViewport2
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, res
);
961 static HRESULT WINAPI
962 Thunk_IDirect3DDeviceImpl_1_NextViewport(IDirect3DDevice
*iface
,
963 IDirect3DViewport
*Viewport
,
964 IDirect3DViewport
**lplpDirect3DViewport
,
967 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
968 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
969 IDirect3DViewport3
*res
;
971 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08lx) thunking to IDirect3DDevice3 interface.\n", This
, vp
, lplpDirect3DViewport
, Flags
);
972 hr
= IDirect3DDevice3_NextViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
973 ICOM_INTERFACE(vp
, IDirect3DViewport3
),
976 *lplpDirect3DViewport
= (IDirect3DViewport
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, res
);
980 /*****************************************************************************
981 * IDirect3DDevice::Pick
983 * Executes an execute buffer without performing rendering. Instead, a
984 * list of primitives that intersect with (x1,y1) of the passed rectangle
985 * is created. IDirect3DDevice::GetPickRecords can be used to retrieve
991 * ExecuteBuffer: Buffer to execute
992 * Viewport: Viewport to use for execution
993 * Flags: None are defined, according to the SDK
994 * Rect: Specifies the coordinates to be picked. Only x1 and y2 are used,
995 * x2 and y2 are ignored.
998 * D3D_OK because it's a stub
1000 *****************************************************************************/
1001 static HRESULT WINAPI
1002 IDirect3DDeviceImpl_1_Pick(IDirect3DDevice
*iface
,
1003 IDirect3DExecuteBuffer
*ExecuteBuffer
,
1004 IDirect3DViewport
*Viewport
,
1008 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1009 IDirect3DExecuteBufferImpl
*execbuf
= ICOM_OBJECT(IDirect3DExecuteBufferImpl
, IDirect3DExecuteBuffer
, ExecuteBuffer
);
1010 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
1011 FIXME("(%p)->(%p,%p,%08lx,%p): stub!\n", This
, execbuf
, vp
, Flags
, Rect
);
1016 /*****************************************************************************
1017 * IDirect3DDevice::GetPickRecords
1019 * Retrieves the pick records generated by IDirect3DDevice::GetPickRecords
1024 * Count: Pointer to a DWORD containing the numbers of pick records to
1026 * D3DPickRec: Address to store the resulting D3DPICKRECORD arry.
1029 * D3D_OK, because it's a stub
1031 *****************************************************************************/
1032 static HRESULT WINAPI
1033 IDirect3DDeviceImpl_1_GetPickRecords(IDirect3DDevice
*iface
,
1035 D3DPICKRECORD
*D3DPickRec
)
1037 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1038 FIXME("(%p)->(%p,%p): stub!\n", This
, Count
, D3DPickRec
);
1043 /*****************************************************************************
1044 * EnumTextureFormatsCB
1046 * Callback called by WineD3D for each enumerated Texture format. It
1047 * translates the WineD3DFormat into a ddraw pixel format and calls
1048 * the application callback
1051 * Device: The WineD3DDevice's parents = The IDirect3DDevice7 interface
1053 * fmt: An enumerated pixel format
1054 * Context: Data pointer passed to WineD3D by
1055 * IDirect3DDevice7::EnumTexureformats
1058 * The return value of the application-provided callback
1060 *****************************************************************************/
1061 static HRESULT WINAPI
1062 EnumTextureFormatsCB(IUnknown
*Device
,
1066 struct EnumTextureFormatsCBS
*cbs
= (struct EnumTextureFormatsCBS
*) Context
;
1068 DDSURFACEDESC sdesc
;
1069 DDPIXELFORMAT
*pformat
;
1071 memset(&sdesc
, 0, sizeof(DDSURFACEDESC
));
1072 sdesc
.dwSize
= sizeof(DDSURFACEDESC
);
1073 sdesc
.dwFlags
= DDSD_PIXELFORMAT
| DDSD_CAPS
;
1074 sdesc
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
;
1075 pformat
= &(sdesc
.ddpfPixelFormat
);
1076 pformat
->dwSize
= sizeof(DDPIXELFORMAT
);
1078 PixelFormat_WineD3DtoDD(pformat
, fmt
);
1080 if( ( fmt
== WINED3DFMT_UYVY
) ||
1081 ( fmt
== WINED3DFMT_YUY2
) ||
1082 ( fmt
== WINED3DFMT_DXT1
) ||
1083 ( fmt
== WINED3DFMT_DXT2
) ||
1084 ( fmt
== WINED3DFMT_DXT3
) ||
1085 ( fmt
== WINED3DFMT_DXT4
) ||
1086 ( fmt
== WINED3DFMT_DXT5
) ||
1087 ( fmt
== WINED3DFMT_MULTI2_ARGB
) ||
1088 ( fmt
== WINED3DFMT_G8R8_G8B8
) ||
1089 ( fmt
== WINED3DFMT_R8G8_B8G8
) ||
1090 ( fmt
== WINED3DFMT_L8
) ||
1091 ( fmt
== WINED3DFMT_A8L8
) ||
1092 ( fmt
== WINED3DFMT_A4L4
) ||
1093 ( fmt
== WINED3DFMT_V8U8
) ||
1094 ( fmt
== WINED3DFMT_L6V5U5
) )
1096 /* These formats exist in D3D3 and D3D7 only,
1097 * so do not call the older callback
1099 if(cbs
->cbv7
) return cbs
->cbv7(pformat
, cbs
->Context
);
1103 /* Only one of these should be passed */
1104 if(cbs
->cbv2
) return cbs
->cbv2(&sdesc
, cbs
->Context
);
1105 if(cbs
->cbv7
) return cbs
->cbv7(pformat
, cbs
->Context
);
1108 return DDENUMRET_OK
;
1111 /*****************************************************************************
1112 * IDirect3DDevice7::EnumTextureformats
1114 * Enumerates the supported texture formats. This is relayed to WineD3D,
1115 * and a EnumTextureFormatsCB translated the WineD3DFormats to DDraw
1116 * formats and calls the application callback.
1118 * This is for Version 7 and 3, older versions have a different
1119 * callback function and their own implementation
1122 * Callback: Callback to call for each enumerated format
1123 * Arg: Argument to pass to the callback
1127 * DDERR_INVALIDPARAMS if Callback == NULL
1129 *****************************************************************************/
1130 static HRESULT WINAPI
1131 IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7
*iface
,
1132 LPD3DENUMPIXELFORMATSCALLBACK Callback
,
1135 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1137 struct EnumTextureFormatsCBS cbs
= { NULL
, Callback
, Arg
};
1138 TRACE("(%p)->(%p,%p): Relay\n", This
, Callback
, Arg
);
1141 return DDERR_INVALIDPARAMS
;
1143 hr
= IWineD3DDevice_EnumTextureFormats(This
->wineD3DDevice
,
1144 EnumTextureFormatsCB
,
1146 return hr_ddraw_from_wined3d(hr
);
1149 static HRESULT WINAPI
1150 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats(IDirect3DDevice3
*iface
,
1151 LPD3DENUMPIXELFORMATSCALLBACK Callback
,
1154 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1155 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice7 interface.\n", This
, Callback
, Arg
);
1156 return IDirect3DDevice7_EnumTextureFormats(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1161 /*****************************************************************************
1162 * IDirect3DDevice2::EnumTextureformats
1164 * EnumTextureFormats for Version 1 and 2, see
1165 * IDirect3DDevice7::EnumTexureFormats for a more detailed description
1167 *****************************************************************************/
1168 static HRESULT WINAPI
1169 IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2
*iface
,
1170 LPD3DENUMTEXTUREFORMATSCALLBACK Callback
,
1173 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1175 struct EnumTextureFormatsCBS cbs
= { Callback
, NULL
, Arg
};
1176 TRACE("(%p)->(%p,%p): Relay\n", This
, Callback
, Arg
);
1178 hr
= IWineD3DDevice_EnumTextureFormats(This
->wineD3DDevice
,
1179 EnumTextureFormatsCB
,
1181 return hr_ddraw_from_wined3d(hr
);
1184 static HRESULT WINAPI
1185 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats(IDirect3DDevice
*iface
,
1186 LPD3DENUMTEXTUREFORMATSCALLBACK Callback
,
1189 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1190 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", This
, Callback
, Arg
);
1191 return IDirect3DDevice2_EnumTextureFormats(ICOM_INTERFACE(This
, IDirect3DDevice2
),
1196 /*****************************************************************************
1197 * IDirect3DDevice::CreateMatrix
1199 * Creates a matrix handle. A handle is created and memory for a D3DMATRIX is
1200 * allocated for the handle.
1205 * D3DMatHandle: Address to return the handle at
1209 * DDERR_INVALIDPARAMS if D3DMatHandle = NULL
1211 *****************************************************************************/
1212 static HRESULT WINAPI
1213 IDirect3DDeviceImpl_1_CreateMatrix(IDirect3DDevice
*iface
, D3DMATRIXHANDLE
*D3DMatHandle
)
1215 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1217 TRACE("(%p)->(%p)\n", This
, D3DMatHandle
);
1220 return DDERR_INVALIDPARAMS
;
1222 Matrix
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(D3DMATRIX
));
1225 ERR("Out of memory when allocating a D3DMATRIX\n");
1226 return DDERR_OUTOFMEMORY
;
1228 *D3DMatHandle
= IDirect3DDeviceImpl_CreateHandle(This
);
1229 if(!(*D3DMatHandle
))
1231 ERR("Failed to create a matrix handle\n");
1232 HeapFree(GetProcessHeap(), 0, Matrix
);
1233 return DDERR_OUTOFMEMORY
;
1235 This
->Handles
[(DWORD
) *D3DMatHandle
- 1].ptr
= Matrix
;
1236 This
->Handles
[(DWORD
) *D3DMatHandle
- 1].type
= DDrawHandle_Matrix
;
1237 TRACE(" returning matrix handle %ld\n", *D3DMatHandle
);
1242 /*****************************************************************************
1243 * IDirect3DDevice::SetMatrix
1245 * Sets a matrix for a matrix handle. The matrix is copied into the memory
1246 * allocated for the handle
1251 * D3DMatHandle: Handle to set the matrix to
1252 * D3DMatrix: Matrix to set
1256 * DDERR_INVALIDPARAMS if the handle of the matrix is invalid or the matrix
1259 *****************************************************************************/
1260 static HRESULT WINAPI
1261 IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice
*iface
,
1262 D3DMATRIXHANDLE D3DMatHandle
,
1263 D3DMATRIX
*D3DMatrix
)
1265 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1266 TRACE("(%p)->(%08lx,%p)\n", This
, (DWORD
) D3DMatHandle
, D3DMatrix
);
1268 if( (!D3DMatHandle
) || (!D3DMatrix
) )
1269 return DDERR_INVALIDPARAMS
;
1271 if(D3DMatHandle
> This
->numHandles
)
1273 ERR("Handle %ld out of range\n", D3DMatHandle
);
1274 return DDERR_INVALIDPARAMS
;
1276 else if(This
->Handles
[D3DMatHandle
- 1].type
!= DDrawHandle_Matrix
)
1278 ERR("Handle %ld is not a matrix handle\n", D3DMatHandle
);
1279 return DDERR_INVALIDPARAMS
;
1283 dump_D3DMATRIX(D3DMatrix
);
1285 *((D3DMATRIX
*) This
->Handles
[D3DMatHandle
- 1].ptr
) = *D3DMatrix
;
1290 /*****************************************************************************
1291 * IDirect3DDevice::SetMatrix
1293 * Returns the content of a D3DMATRIX handle
1298 * D3DMatHandle: Matrix handle to read the content from
1299 * D3DMatrix: Address to store the content at
1303 * DDERR_INVALIDPARAMS if D3DMatHandle is invalid or D3DMatrix is NULL
1305 *****************************************************************************/
1306 static HRESULT WINAPI
1307 IDirect3DDeviceImpl_1_GetMatrix(IDirect3DDevice
*iface
,
1308 D3DMATRIXHANDLE D3DMatHandle
,
1309 D3DMATRIX
*D3DMatrix
)
1311 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1312 TRACE("(%p)->(%08lx,%p)\n", This
, (DWORD
) D3DMatHandle
, D3DMatrix
);
1315 return DDERR_INVALIDPARAMS
;
1317 return DDERR_INVALIDPARAMS
;
1319 if(D3DMatHandle
> This
->numHandles
)
1321 ERR("Handle %ld out of range\n", D3DMatHandle
);
1322 return DDERR_INVALIDPARAMS
;
1324 else if(This
->Handles
[D3DMatHandle
- 1].type
!= DDrawHandle_Matrix
)
1326 ERR("Handle %ld is not a matrix handle\n", D3DMatHandle
);
1327 return DDERR_INVALIDPARAMS
;
1330 /* The handle is simply a pointer to a D3DMATRIX structure */
1331 *D3DMatrix
= *((D3DMATRIX
*) This
->Handles
[D3DMatHandle
- 1].ptr
);
1336 /*****************************************************************************
1337 * IDirect3DDevice::DeleteMatrix
1339 * Destroys a Matrix handle. Frees the memory and unsets the handle data
1344 * D3DMatHandle: Handle to destroy
1348 * DDERR_INVALIDPARAMS if D3DMatHandle is invalid
1350 *****************************************************************************/
1351 static HRESULT WINAPI
1352 IDirect3DDeviceImpl_1_DeleteMatrix(IDirect3DDevice
*iface
,
1353 D3DMATRIXHANDLE D3DMatHandle
)
1355 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1356 TRACE("(%p)->(%08lx)\n", This
, (DWORD
) D3DMatHandle
);
1359 return DDERR_INVALIDPARAMS
;
1361 if(D3DMatHandle
> This
->numHandles
)
1363 ERR("Handle %ld out of range\n", D3DMatHandle
);
1364 return DDERR_INVALIDPARAMS
;
1366 else if(This
->Handles
[D3DMatHandle
- 1].type
!= DDrawHandle_Matrix
)
1368 ERR("Handle %ld is not a matrix handle\n", D3DMatHandle
);
1369 return DDERR_INVALIDPARAMS
;
1372 HeapFree(GetProcessHeap(), 0, This
->Handles
[D3DMatHandle
- 1].ptr
);
1373 This
->Handles
[D3DMatHandle
- 1].ptr
= NULL
;
1374 This
->Handles
[D3DMatHandle
- 1].type
= DDrawHandle_Unknown
;
1379 /*****************************************************************************
1380 * IDirect3DDevice7::BeginScene
1382 * This method must be called before any rendering is performed.
1383 * IDirect3DDevice::EndScene has to be called after the scene is complete
1385 * Version 1, 2, 3 and 7
1388 * D3D_OK on success, for details see IWineD3DDevice::BeginScene
1390 *****************************************************************************/
1391 static HRESULT WINAPI
1392 IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7
*iface
)
1394 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1395 TRACE("(%p): Relay\n", This
);
1397 return IWineD3DDevice_BeginScene(This
->wineD3DDevice
);
1400 static HRESULT WINAPI
1401 Thunk_IDirect3DDeviceImpl_3_BeginScene(IDirect3DDevice3
*iface
)
1403 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1404 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1405 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1408 static HRESULT WINAPI
1409 Thunk_IDirect3DDeviceImpl_2_BeginScene(IDirect3DDevice2
*iface
)
1411 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1412 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1413 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1416 static HRESULT WINAPI
1417 Thunk_IDirect3DDeviceImpl_1_BeginScene(IDirect3DDevice
*iface
)
1419 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1420 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1421 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1424 /*****************************************************************************
1425 * IDirect3DDevice7::EndScene
1427 * Ends a scene that has been begun with IDirect3DDevice7::BeginScene.
1428 * This method must be called after rendering is finished.
1430 * Version 1, 2, 3 and 7
1433 * D3D_OK on success, for details see IWineD3DDevice::EndScene
1435 *****************************************************************************/
1436 static HRESULT WINAPI
1437 IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7
*iface
)
1439 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1440 TRACE("(%p): Relay\n", This
);
1442 IWineD3DDevice_EndScene(This
->wineD3DDevice
);
1446 static HRESULT WINAPI
1447 Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3
*iface
)
1449 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1450 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1451 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1454 static HRESULT WINAPI
1455 Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2
*iface
)
1457 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1458 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1459 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1462 static HRESULT WINAPI
1463 Thunk_IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice
*iface
)
1465 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1466 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1467 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1470 /*****************************************************************************
1471 * IDirect3DDevice7::GetDirect3D
1473 * Returns the IDirect3D(= interface to the DirectDraw object) used to create
1477 * Direct3D7: Address to store the interface pointer at
1481 * DDERR_INVALIDPARAMS if Direct3D7 == NULL
1483 *****************************************************************************/
1484 static HRESULT WINAPI
1485 IDirect3DDeviceImpl_7_GetDirect3D(IDirect3DDevice7
*iface
,
1486 IDirect3D7
**Direct3D7
)
1488 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1489 TRACE("(%p)->(%p)\n", This
, Direct3D7
);
1492 return DDERR_INVALIDPARAMS
;
1494 *Direct3D7
= ICOM_INTERFACE(This
->ddraw
, IDirect3D7
);
1495 IDirect3D7_AddRef(*Direct3D7
);
1497 TRACE(" returning interface %p\n", *Direct3D7
);
1501 static HRESULT WINAPI
1502 Thunk_IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3
*iface
,
1503 IDirect3D3
**Direct3D3
)
1505 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1507 IDirect3D7
*ret_ptr
;
1509 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D3
);
1510 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1514 *Direct3D3
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D3
, ret_ptr
);
1515 TRACE(" returning interface %p\n", *Direct3D3
);
1519 static HRESULT WINAPI
1520 Thunk_IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2
*iface
,
1521 IDirect3D2
**Direct3D2
)
1523 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1525 IDirect3D7
*ret_ptr
;
1527 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D2
);
1528 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1532 *Direct3D2
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D2
, ret_ptr
);
1533 TRACE(" returning interface %p\n", *Direct3D2
);
1537 static HRESULT WINAPI
1538 Thunk_IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice
*iface
,
1539 IDirect3D
**Direct3D
)
1541 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1543 IDirect3D7
*ret_ptr
;
1545 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D
);
1546 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1550 *Direct3D
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D
, ret_ptr
);
1551 TRACE(" returning interface %p\n", *Direct3D
);
1555 /*****************************************************************************
1556 * IDirect3DDevice3::SetCurrentViewport
1558 * Sets a Direct3DViewport as the current viewport.
1559 * For the thunks note that all viewport interface versions are equal
1562 * Direct3DViewport3: The viewport to set
1568 * (Is a NULL viewport valid?)
1570 *****************************************************************************/
1571 static HRESULT WINAPI
1572 IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3
*iface
,
1573 IDirect3DViewport3
*Direct3DViewport3
)
1575 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1576 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport3
);
1577 TRACE("(%p)->(%p)\n", This
, Direct3DViewport3
);
1579 /* Do nothing if the specified viewport is the same as the current one */
1580 if (This
->current_viewport
== vp
)
1583 /* Should check if the viewport was added or not */
1585 /* Release previous viewport and AddRef the new one */
1586 if (This
->current_viewport
)
1588 TRACE("ViewportImpl is at %p, interface is at %p\n", This
->current_viewport
, ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
));
1589 IDirect3DViewport3_Release( ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
) );
1591 IDirect3DViewport3_AddRef(Direct3DViewport3
);
1593 /* Set this viewport as the current viewport */
1594 This
->current_viewport
= vp
;
1596 /* Activate this viewport */
1597 This
->current_viewport
->active_device
= This
;
1598 This
->current_viewport
->activate(This
->current_viewport
);
1603 static HRESULT WINAPI
1604 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2
*iface
,
1605 IDirect3DViewport2
*Direct3DViewport2
)
1607 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1608 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
1609 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
1610 return IDirect3DDevice3_SetCurrentViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1611 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
1614 /*****************************************************************************
1615 * IDirect3DDevice3::GetCurrentViewport
1617 * Returns the currently active viewport.
1622 * Direct3DViewport3: Address to return the interface pointer at
1626 * DDERR_INVALIDPARAMS if Direct3DViewport == NULL
1628 *****************************************************************************/
1629 static HRESULT WINAPI
1630 IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3
*iface
,
1631 IDirect3DViewport3
**Direct3DViewport3
)
1633 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1634 TRACE("(%p)->(%p)\n", This
, Direct3DViewport3
);
1636 if(!Direct3DViewport3
)
1637 return DDERR_INVALIDPARAMS
;
1639 *Direct3DViewport3
= ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
);
1641 /* AddRef the returned viewport */
1642 if(*Direct3DViewport3
) IDirect3DViewport3_AddRef(*Direct3DViewport3
);
1644 TRACE(" returning interface %p\n", *Direct3DViewport3
);
1649 static HRESULT WINAPI
1650 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(IDirect3DDevice2
*iface
,
1651 IDirect3DViewport2
**Direct3DViewport2
)
1653 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1655 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Direct3DViewport2
);
1656 hr
= IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1657 (IDirect3DViewport3
**) Direct3DViewport2
);
1658 if(hr
!= D3D_OK
) return hr
;
1659 *Direct3DViewport2
= (IDirect3DViewport2
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, Direct3DViewport2
);
1663 /*****************************************************************************
1664 * IDirect3DDevice7::SetRenderTarget
1666 * Sets the render target for the Direct3DDevice.
1667 * For the thunks note that IDirectDrawSurface7 == IDirectDrawSurface4 and
1668 * IDirectDrawSurface3 == IDirectDrawSurface
1670 * Version 2, 3 and 7
1673 * NewTarget: Pointer to an IDirectDrawSurface7 interface to set as the new
1678 * D3D_OK on success, for details see IWineD3DDevice::SetRenderTarget
1680 *****************************************************************************/
1681 static HRESULT WINAPI
1682 IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7
*iface
,
1683 IDirectDrawSurface7
*NewTarget
,
1686 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1687 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, NewTarget
);
1688 TRACE("(%p)->(%p,%08lx): Relay\n", This
, NewTarget
, Flags
);
1690 /* Flags: Not used */
1692 return IWineD3DDevice_SetRenderTarget(This
->wineD3DDevice
,
1694 Target
? Target
->WineD3DSurface
: NULL
);
1697 static HRESULT WINAPI
1698 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3
*iface
,
1699 IDirectDrawSurface4
*NewRenderTarget
,
1702 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1703 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, NewRenderTarget
);
1704 TRACE_(ddraw_thunk
)("(%p)->(%p,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, Target
, Flags
);
1705 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1706 ICOM_INTERFACE(Target
, IDirectDrawSurface7
),
1710 static HRESULT WINAPI
1711 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2
*iface
,
1712 IDirectDrawSurface
*NewRenderTarget
,
1715 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1716 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface3
, NewRenderTarget
);
1717 TRACE_(ddraw_thunk
)("(%p)->(%p,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, Target
, Flags
);
1718 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1719 ICOM_INTERFACE(Target
, IDirectDrawSurface7
),
1723 /*****************************************************************************
1724 * IDirect3DDevice7::GetRenderTarget
1726 * Returns the current render target.
1727 * This is handled locally, because the WineD3D render target's parent
1730 * Version 2, 3 and 7
1733 * RenderTarget: Address to store the surface interface pointer
1737 * DDERR_INVALIDPARAMS if RenderTarget == NULL
1739 *****************************************************************************/
1740 static HRESULT WINAPI
1741 IDirect3DDeviceImpl_7_GetRenderTarget(IDirect3DDevice7
*iface
,
1742 IDirectDrawSurface7
**RenderTarget
)
1744 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1745 TRACE("(%p)->(%p): Relay\n", This
, RenderTarget
);
1748 return DDERR_INVALIDPARAMS
;
1750 *RenderTarget
= ICOM_INTERFACE(This
->target
, IDirectDrawSurface7
);
1751 IDirectDrawSurface7_AddRef(*RenderTarget
);
1756 static HRESULT WINAPI
1757 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3
*iface
,
1758 IDirectDrawSurface4
**RenderTarget
)
1760 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1762 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, RenderTarget
);
1763 hr
= IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1764 (IDirectDrawSurface7
**) RenderTarget
);
1765 if(hr
!= D3D_OK
) return hr
;
1766 *RenderTarget
= (IDirectDrawSurface4
*) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirectDrawSurface7
, RenderTarget
);
1770 static HRESULT WINAPI
1771 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(IDirect3DDevice2
*iface
,
1772 IDirectDrawSurface
**RenderTarget
)
1774 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1776 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, RenderTarget
);
1777 hr
= IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1778 (IDirectDrawSurface7
**) RenderTarget
);
1779 if(hr
!= D3D_OK
) return hr
;
1780 *RenderTarget
= (IDirectDrawSurface
*) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirectDrawSurface3
, RenderTarget
);
1784 /*****************************************************************************
1785 * IDirect3DDevice3::Begin
1787 * Begins a description block of vertices. This is similar to glBegin()
1788 * and glEnd(). After a call to IDirect3DDevice3::End, the vertices
1789 * described with IDirect3DDevice::Vertex are drawn.
1794 * PrimitiveType: The type of primitives to draw
1795 * VertexTypeDesc: A flexible vertex format description of the vertices
1796 * Flags: Some flags..
1801 *****************************************************************************/
1802 static HRESULT WINAPI
1803 IDirect3DDeviceImpl_3_Begin(IDirect3DDevice3
*iface
,
1804 D3DPRIMITIVETYPE PrimitiveType
,
1805 DWORD VertexTypeDesc
,
1808 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1809 TRACE("(%p)->(%d,%ld,%08lx)\n", This
, PrimitiveType
, VertexTypeDesc
, Flags
);
1811 This
->primitive_type
= PrimitiveType
;
1812 This
->vertex_type
= VertexTypeDesc
;
1813 This
->render_flags
= Flags
;
1814 This
->vertex_size
= get_flexible_vertex_size(This
->vertex_type
);
1815 This
->nb_vertices
= 0;
1820 static HRESULT WINAPI
1821 Thunk_IDirect3DDeviceImpl_2_Begin(IDirect3DDevice2
*iface
,
1822 D3DPRIMITIVETYPE d3dpt
,
1823 D3DVERTEXTYPE dwVertexTypeDesc
,
1827 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1828 TRACE_(ddraw_thunk
)("(%p/%p)->(%08x,%08x,%08lx): Thunking to IDirect3DDevice3\n", This
, iface
, d3dpt
, dwVertexTypeDesc
, dwFlags
);
1830 switch(dwVertexTypeDesc
)
1832 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
1833 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
1834 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
1836 ERR("Unexpected vertex type %d\n", dwVertexTypeDesc
);
1837 return DDERR_INVALIDPARAMS
; /* Should never happen */
1840 return IDirect3DDevice3_Begin(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1846 /*****************************************************************************
1847 * IDirect3DDevice3::BeginIndexed
1849 * Draws primitives based on vertices in a vertex array which are specified
1855 * PrimitiveType: Primitive type to draw
1856 * VertexType: A FVF description of the vertex format
1857 * Vertices: pointer to an array containing the vertices
1858 * NumVertices: The number of vertices in the vertex array
1859 * Flags: Some flags ...
1862 * D3D_OK, because it's a stub
1864 *****************************************************************************/
1865 static HRESULT WINAPI
1866 IDirect3DDeviceImpl_3_BeginIndexed(IDirect3DDevice3
*iface
,
1867 D3DPRIMITIVETYPE PrimitiveType
,
1873 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1874 FIXME("(%p)->(%08x,%08lx,%p,%08lx,%08lx): stub!\n", This
, PrimitiveType
, VertexType
, Vertices
, NumVertices
, Flags
);
1879 static HRESULT WINAPI
1880 Thunk_IDirect3DDeviceImpl_2_BeginIndexed(IDirect3DDevice2
*iface
,
1881 D3DPRIMITIVETYPE d3dptPrimitiveType
,
1882 D3DVERTEXTYPE d3dvtVertexType
,
1884 DWORD dwNumVertices
,
1888 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1889 TRACE_(ddraw_thunk
)("(%p/%p)->(%08x,%08x,%p,%08lx,%08lx): Thunking to IDirect3DDevice3\n", This
, iface
, d3dptPrimitiveType
, d3dvtVertexType
, lpvVertices
, dwNumVertices
, dwFlags
);
1891 switch(d3dvtVertexType
)
1893 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
1894 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
1895 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
1897 ERR("Unexpected vertex type %d\n", d3dvtVertexType
);
1898 return DDERR_INVALIDPARAMS
; /* Should never happen */
1901 return IDirect3DDevice3_BeginIndexed(ICOM_INTERFACE(This
,IDirect3DDevice3
),
1909 /*****************************************************************************
1910 * IDirect3DDevice3::Vertex
1912 * Draws a vertex as described by IDirect3DDevice3::Begin. It places all
1913 * drawn vertices in a vertex buffer. If the buffer is too small, its
1914 * size is increased.
1919 * Vertex: Pointer to the vertex
1922 * D3D_OK, on success
1923 * DDERR_INVALIDPARAMS if Vertex is NULL
1925 *****************************************************************************/
1926 static HRESULT WINAPI
1927 IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3
*iface
,
1930 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1931 TRACE("(%p)->(%p)\n", This
, Vertex
);
1934 return DDERR_INVALIDPARAMS
;
1936 if ((This
->nb_vertices
+1)*This
->vertex_size
> This
->buffer_size
)
1939 This
->buffer_size
= This
->buffer_size
? This
->buffer_size
* 2 : This
->vertex_size
* 3;
1940 old_buffer
= This
->vertex_buffer
;
1941 This
->vertex_buffer
= HeapAlloc(GetProcessHeap(), 0, This
->buffer_size
);
1944 CopyMemory(This
->vertex_buffer
, old_buffer
, This
->nb_vertices
* This
->vertex_size
);
1945 HeapFree(GetProcessHeap(), 0, old_buffer
);
1949 CopyMemory(This
->vertex_buffer
+ This
->nb_vertices
++ * This
->vertex_size
, Vertex
, This
->vertex_size
);
1954 static HRESULT WINAPI
1955 Thunk_IDirect3DDeviceImpl_2_Vertex(IDirect3DDevice2
*iface
,
1958 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1959 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, lpVertexType
);
1960 return IDirect3DDevice3_Vertex(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1964 /*****************************************************************************
1965 * IDirect3DDevice3::Index
1967 * Specifies an index to a vertex to be drawn. The vertex array has to
1968 * be specified with BeginIndexed first.
1971 * VertexIndex: The index of the vertex to draw
1974 * D3D_OK because it's a stub
1976 *****************************************************************************/
1977 static HRESULT WINAPI
1978 IDirect3DDeviceImpl_3_Index(IDirect3DDevice3
*iface
,
1981 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1982 FIXME("(%p)->(%04x): stub!\n", This
, VertexIndex
);
1986 static HRESULT WINAPI
1987 Thunk_IDirect3DDeviceImpl_2_Index(IDirect3DDevice2
*iface
,
1990 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1991 TRACE_(ddraw_thunk
)("(%p)->(%04x) thunking to IDirect3DDevice3 interface.\n", This
, wVertexIndex
);
1992 return IDirect3DDevice3_Index(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1996 /*****************************************************************************
1997 * IDirect3DDevice3::End
1999 * Ends a draw begun with IDirect3DDevice3::Begin or
2000 * IDirect3DDevice::BeginIndexed. The vertices specified with
2001 * IDirect3DDevice::Vertex or IDirect3DDevice::Index are drawn using
2002 * the IDirect3DDevice7::DrawPrimitive method. So far only
2003 * non-indexed mode is supported
2008 * Flags: Some flags, as usual. Don't know which are defined
2011 * The return value of IDirect3DDevice7::DrawPrimitive
2013 *****************************************************************************/
2014 static HRESULT WINAPI
2015 IDirect3DDeviceImpl_3_End(IDirect3DDevice3
*iface
,
2018 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2019 TRACE("(%p)->(%08lx)\n", This
, Flags
);
2021 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2022 This
->primitive_type
, This
->vertex_type
,
2023 This
->vertex_buffer
, This
->nb_vertices
,
2024 This
->render_flags
);
2027 static HRESULT WINAPI
2028 Thunk_IDirect3DDeviceImpl_2_End(IDirect3DDevice2
*iface
,
2031 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2032 TRACE_(ddraw_thunk
)("(%p)->(%08lx) thunking to IDirect3DDevice3 interface.\n", This
, dwFlags
);
2033 return IDirect3DDevice3_End(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2037 /*****************************************************************************
2038 * IDirect3DDevice7::GetRenderState
2040 * Returns the value of a render state. The possible render states are
2041 * defined in include/d3dtypes.h
2043 * Version 2, 3 and 7
2046 * RenderStateType: Render state to return the current setting of
2047 * Value: Address to store the value at
2050 * D3D_OK on success, for details see IWineD3DDevice::GetRenderState
2051 * DDERR_INVALIDPARAMS if Value == NULL
2053 *****************************************************************************/
2054 static HRESULT WINAPI
2055 IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7
*iface
,
2056 D3DRENDERSTATETYPE RenderStateType
,
2059 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2060 TRACE("(%p)->(%08x,%p): Relay\n", This
, RenderStateType
, Value
);
2063 return DDERR_INVALIDPARAMS
;
2065 return IWineD3DDevice_GetRenderState(This
->wineD3DDevice
,
2070 static HRESULT WINAPI
2071 Thunk_IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3
*iface
,
2072 D3DRENDERSTATETYPE dwRenderStateType
,
2073 DWORD
*lpdwRenderState
)
2075 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2076 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, dwRenderStateType
, lpdwRenderState
);
2077 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2082 static HRESULT WINAPI
2083 Thunk_IDirect3DDeviceImpl_2_GetRenderState(IDirect3DDevice2
*iface
,
2084 D3DRENDERSTATETYPE dwRenderStateType
,
2085 DWORD
*lpdwRenderState
)
2087 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2088 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, dwRenderStateType
, lpdwRenderState
);
2089 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2094 /*****************************************************************************
2095 * IDirect3DDevice7::SetRenderState
2097 * Sets a render state. The possible render states are defined in
2098 * include/d3dtypes.h
2100 * Version 2, 3 and 7
2103 * RenderStateType: State to set
2104 * Value: Value to assign to that state
2107 * D3D_OK on success,
2108 * for details see IWineD3DDevice::SetRenderState
2110 *****************************************************************************/
2111 static HRESULT WINAPI
2112 IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7
*iface
,
2113 D3DRENDERSTATETYPE RenderStateType
,
2116 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2117 TRACE("(%p)->(%08x,%ld): Relay\n", This
, RenderStateType
, Value
);
2119 /* Some render states need special care */
2120 switch(RenderStateType
)
2122 case D3DRENDERSTATE_TEXTUREHANDLE
:
2126 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
2131 if(Value
> This
->numHandles
)
2133 FIXME("Specified handle %ld out of range\n", Value
);
2134 return DDERR_INVALIDPARAMS
;
2136 if(This
->Handles
[Value
- 1].type
!= DDrawHandle_Texture
)
2138 FIXME("Handle %ld isn't a texture handle\n", Value
);
2139 return DDERR_INVALIDPARAMS
;
2143 IDirectDrawSurfaceImpl
*surf
= (IDirectDrawSurfaceImpl
*) This
->Handles
[Value
- 1].ptr
;
2144 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
2146 (IWineD3DBaseTexture
*) surf
->wineD3DTexture
);
2150 case D3DRENDERSTATE_TEXTUREMAG
:
2152 WINED3DTEXTUREFILTERTYPE tex_mag
= WINED3DTEXF_NONE
;
2154 switch ((D3DTEXTUREFILTER
) Value
)
2156 case D3DFILTER_NEAREST
:
2157 tex_mag
= WINED3DTEXF_POINT
;
2159 case D3DFILTER_LINEAR
:
2160 tex_mag
= WINED3DTEXF_LINEAR
;
2163 ERR("Unhandled texture mag %ld !\n",Value
);
2166 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
2167 0, WINED3DSAMP_MAGFILTER
,
2171 case D3DRENDERSTATE_TEXTUREMIN
:
2173 WINED3DTEXTUREFILTERTYPE tex_min
= WINED3DTEXF_NONE
;
2175 switch ((D3DTEXTUREFILTER
) Value
)
2177 case D3DFILTER_NEAREST
:
2178 tex_min
= WINED3DTEXF_POINT
;
2180 case D3DFILTER_LINEAR
:
2181 tex_min
= WINED3DTEXF_LINEAR
;
2184 ERR("Unhandled texture mag %ld !\n",Value
);
2187 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
2188 0, WINED3DSAMP_MINFILTER
,
2192 case D3DRENDERSTATE_TEXTUREADDRESSU
:
2193 case D3DRENDERSTATE_TEXTUREADDRESSV
:
2194 case D3DRENDERSTATE_TEXTUREADDRESS
:
2196 WINED3DTEXTURESTAGESTATETYPE TexStageStateType
;
2198 if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESS
)
2200 TexStageStateType
= WINED3DTSS_ADDRESS
;
2202 else if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESSU
)
2204 TexStageStateType
= WINED3DTSS_ADDRESSU
;
2208 TexStageStateType
= WINED3DTSS_ADDRESSV
;
2211 return IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
,
2212 0, TexStageStateType
,
2217 return IWineD3DDevice_SetRenderState(This
->wineD3DDevice
,
2223 static HRESULT WINAPI
2224 Thunk_IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3
*iface
,
2225 D3DRENDERSTATETYPE RenderStateType
,
2228 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2229 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, RenderStateType
, Value
);
2230 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2235 static HRESULT WINAPI
2236 Thunk_IDirect3DDeviceImpl_2_SetRenderState(IDirect3DDevice2
*iface
,
2237 D3DRENDERSTATETYPE RenderStateType
,
2240 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2241 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, RenderStateType
, Value
);
2242 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2247 /*****************************************************************************
2248 * Direct3DDevice3::SetLightState
2250 * Sets a light state for Direct3DDevice3 and Direct3DDevice2. The
2251 * light states are forwarded to Direct3DDevice7 render states
2256 * LightStateType: The light state to change
2257 * Value: The value to assign to that light state
2261 * DDERR_INVALIDPARAMS if the parameters were incorrect
2262 * Also check IDirect3DDevice7::SetRenderState
2264 *****************************************************************************/
2265 static HRESULT WINAPI
2266 IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3
*iface
,
2267 D3DLIGHTSTATETYPE LightStateType
,
2270 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2272 TRACE("(%p)->(%08x,%08lx)\n", This
, LightStateType
, Value
);
2274 if (!LightStateType
&& (LightStateType
> D3DLIGHTSTATE_COLORVERTEX
))
2276 TRACE("Unexpected Light State Type\n");
2277 return DDERR_INVALIDPARAMS
;
2280 if (LightStateType
== D3DLIGHTSTATE_MATERIAL
/* 1 */)
2282 IDirect3DMaterialImpl
*mat
;
2284 if(Value
== 0) mat
= NULL
;
2285 else if(Value
> This
->numHandles
)
2287 ERR("Material handle out of range(%ld)\n", Value
);
2288 return DDERR_INVALIDPARAMS
;
2290 else if(This
->Handles
[Value
- 1].type
!= DDrawHandle_Material
)
2292 ERR("Invalid handle %ld\n", Value
);
2293 return DDERR_INVALIDPARAMS
;
2297 mat
= (IDirect3DMaterialImpl
*) This
->Handles
[Value
- 1].ptr
;
2302 TRACE(" activating material %p.\n", mat
);
2307 FIXME(" D3DLIGHTSTATE_MATERIAL called with NULL material !!!\n");
2309 This
->material
= Value
;
2311 else if (LightStateType
== D3DLIGHTSTATE_COLORMODEL
/* 3 */)
2316 ERR("DDCOLOR_MONO should not happen!\n");
2319 /* We are already in this mode */
2320 TRACE("Setting color model to RGB (no-op).\n");
2323 ERR("Unknown color model!\n");
2324 return DDERR_INVALIDPARAMS
;
2329 D3DRENDERSTATETYPE rs
;
2330 switch (LightStateType
)
2332 case D3DLIGHTSTATE_AMBIENT
: /* 2 */
2333 rs
= D3DRENDERSTATE_AMBIENT
;
2335 case D3DLIGHTSTATE_FOGMODE
: /* 4 */
2336 rs
= D3DRENDERSTATE_FOGVERTEXMODE
;
2338 case D3DLIGHTSTATE_FOGSTART
: /* 5 */
2339 rs
= D3DRENDERSTATE_FOGSTART
;
2341 case D3DLIGHTSTATE_FOGEND
: /* 6 */
2342 rs
= D3DRENDERSTATE_FOGEND
;
2344 case D3DLIGHTSTATE_FOGDENSITY
: /* 7 */
2345 rs
= D3DRENDERSTATE_FOGDENSITY
;
2347 case D3DLIGHTSTATE_COLORVERTEX
: /* 8 */
2348 rs
= D3DRENDERSTATE_COLORVERTEX
;
2351 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType
);
2352 return DDERR_INVALIDPARAMS
;
2355 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2363 static HRESULT WINAPI
2364 Thunk_IDirect3DDeviceImpl_2_SetLightState(IDirect3DDevice2
*iface
,
2365 D3DLIGHTSTATETYPE LightStateType
,
2368 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2369 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx) thunking to IDirect3DDevice3 interface.\n", This
, LightStateType
, Value
);
2370 return IDirect3DDevice3_SetLightState(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2375 /*****************************************************************************
2376 * IDirect3DDevice3::GetLightState
2378 * Returns the current setting of a light state. The state is read from
2379 * the Direct3DDevice7 render state.
2384 * LightStateType: The light state to return
2385 * Value: The address to store the light state setting at
2389 * DDDERR_INVALIDPARAMS if the parameters were incorrect
2390 * Also see IDirect3DDevice7::GetRenderState
2392 *****************************************************************************/
2393 static HRESULT WINAPI
2394 IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3
*iface
,
2395 D3DLIGHTSTATETYPE LightStateType
,
2398 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2400 TRACE("(%p)->(%08x,%p)\n", This
, LightStateType
, Value
);
2402 if (!LightStateType
&& (LightStateType
> D3DLIGHTSTATE_COLORVERTEX
))
2404 TRACE("Unexpected Light State Type\n");
2405 return DDERR_INVALIDPARAMS
;
2409 return DDERR_INVALIDPARAMS
;
2411 if (LightStateType
== D3DLIGHTSTATE_MATERIAL
/* 1 */)
2413 *Value
= This
->material
;
2415 else if (LightStateType
== D3DLIGHTSTATE_COLORMODEL
/* 3 */)
2417 *Value
= D3DCOLOR_RGB
;
2421 D3DRENDERSTATETYPE rs
;
2422 switch (LightStateType
)
2424 case D3DLIGHTSTATE_AMBIENT
: /* 2 */
2425 rs
= D3DRENDERSTATE_AMBIENT
;
2427 case D3DLIGHTSTATE_FOGMODE
: /* 4 */
2428 rs
= D3DRENDERSTATE_FOGVERTEXMODE
;
2430 case D3DLIGHTSTATE_FOGSTART
: /* 5 */
2431 rs
= D3DRENDERSTATE_FOGSTART
;
2433 case D3DLIGHTSTATE_FOGEND
: /* 6 */
2434 rs
= D3DRENDERSTATE_FOGEND
;
2436 case D3DLIGHTSTATE_FOGDENSITY
: /* 7 */
2437 rs
= D3DRENDERSTATE_FOGDENSITY
;
2439 case D3DLIGHTSTATE_COLORVERTEX
: /* 8 */
2440 rs
= D3DRENDERSTATE_COLORVERTEX
;
2443 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType
);
2444 return DDERR_INVALIDPARAMS
;
2447 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2455 static HRESULT WINAPI
2456 Thunk_IDirect3DDeviceImpl_2_GetLightState(IDirect3DDevice2
*iface
,
2457 D3DLIGHTSTATETYPE LightStateType
,
2460 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2461 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice3 interface.\n", This
, LightStateType
, Value
);
2462 return IDirect3DDevice3_GetLightState(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2467 /*****************************************************************************
2468 * IDirect3DDevice7::SetTransform
2470 * Assigns a D3DMATRIX to a transform type. The transform types are defined
2471 * in include/d3dtypes.h.
2472 * The D3DTRANSFORMSTATE_WORLD (=1) is translated to D3DTS_WORLDMATRIX(0)
2473 * (=255) for wined3d, because the 1 transform state was removed in d3d8
2474 * and WineD3D already understands the replacement D3DTS_WORLDMATRIX(0)
2476 * Version 2, 3 and 7
2479 * TransformStateType: transform state to set
2480 * Matrix: Matrix to assign to the state
2484 * DDERR_INVALIDPARAMS if Matrix == NULL
2485 * For details see IWineD3DDevice::SetTransform
2487 *****************************************************************************/
2488 static HRESULT WINAPI
2489 IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7
*iface
,
2490 D3DTRANSFORMSTATETYPE TransformStateType
,
2493 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2494 D3DTRANSFORMSTATETYPE type
= TransformStateType
;
2495 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, Matrix
);
2498 return DDERR_INVALIDPARAMS
;
2500 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2501 * use D3DTS_WORLDMATRIX(0) instead
2502 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2504 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2505 type
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2507 return IWineD3DDevice_SetTransform(This
->wineD3DDevice
,
2512 static HRESULT WINAPI
2513 Thunk_IDirect3DDeviceImpl_3_SetTransform(IDirect3DDevice3
*iface
,
2514 D3DTRANSFORMSTATETYPE TransformStateType
,
2515 D3DMATRIX
*D3DMatrix
)
2517 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2518 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2519 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2524 static HRESULT WINAPI
2525 Thunk_IDirect3DDeviceImpl_2_SetTransform(IDirect3DDevice2
*iface
,
2526 D3DTRANSFORMSTATETYPE TransformStateType
,
2527 D3DMATRIX
*D3DMatrix
)
2529 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2530 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2531 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2536 /*****************************************************************************
2537 * IDirect3DDevice7::GetTransform
2539 * Returns the matrix assigned to a transform state
2540 * D3DTRANSFORMSTATE_WORLD is translated to D3DTS_WORLDMATRIX(0), see
2544 * TransformStateType: State to read the matrix from
2545 * Matrix: Address to store the matrix at
2549 * DDERR_INVALIDPARAMS if Matrix == NULL
2550 * For details, see IWineD3DDevice::GetTransform
2552 *****************************************************************************/
2553 static HRESULT WINAPI
2554 IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7
*iface
,
2555 D3DTRANSFORMSTATETYPE TransformStateType
,
2558 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2559 D3DTRANSFORMSTATETYPE type
= TransformStateType
;
2560 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, Matrix
);
2563 return DDERR_INVALIDPARAMS
;
2565 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2566 * use D3DTS_WORLDMATRIX(0) instead
2567 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2569 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2570 type
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2572 return IWineD3DDevice_GetTransform(This
->wineD3DDevice
, type
, Matrix
);
2575 static HRESULT WINAPI
2576 Thunk_IDirect3DDeviceImpl_3_GetTransform(IDirect3DDevice3
*iface
,
2577 D3DTRANSFORMSTATETYPE TransformStateType
,
2578 D3DMATRIX
*D3DMatrix
)
2580 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2581 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2582 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2587 static HRESULT WINAPI
2588 Thunk_IDirect3DDeviceImpl_2_GetTransform(IDirect3DDevice2
*iface
,
2589 D3DTRANSFORMSTATETYPE TransformStateType
,
2590 D3DMATRIX
*D3DMatrix
)
2592 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2593 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2594 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2599 /*****************************************************************************
2600 * IDirect3DDevice7::MultiplyTransform
2602 * Multiplies the already-set transform matrix of a transform state
2603 * with another matrix. For the world matrix, see SetTransform
2605 * Version 2, 3 and 7
2608 * TransformStateType: Transform state to multiply
2609 * D3DMatrix Matrix to multiply with.
2613 * DDERR_INVALIDPARAMS if D3DMatrix is NULL
2614 * For details, see IWineD3DDevice::MultiplyTransform
2616 *****************************************************************************/
2617 static HRESULT WINAPI
2618 IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7
*iface
,
2619 D3DTRANSFORMSTATETYPE TransformStateType
,
2620 D3DMATRIX
*D3DMatrix
)
2622 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2623 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, D3DMatrix
);
2625 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2626 * use D3DTS_WORLDMATRIX(0) instead
2627 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2629 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2630 TransformStateType
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2632 return IWineD3DDevice_MultiplyTransform(This
->wineD3DDevice
,
2637 static HRESULT WINAPI
2638 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(IDirect3DDevice3
*iface
,
2639 D3DTRANSFORMSTATETYPE TransformStateType
,
2640 D3DMATRIX
*D3DMatrix
)
2642 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2643 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2644 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2649 static HRESULT WINAPI
2650 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform(IDirect3DDevice2
*iface
,
2651 D3DTRANSFORMSTATETYPE TransformStateType
,
2652 D3DMATRIX
*D3DMatrix
)
2654 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2655 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2656 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2661 /*****************************************************************************
2662 * IDirect3DDevice7::DrawPrimitive
2664 * Draws primitives based on vertices in an application-provided pointer
2666 * Version 2, 3 and 7. The IDirect3DDevice2 thunk converts the fixed vertex type into
2667 * an FVF format for D3D7
2670 * PrimitiveType: The type of the primitives to draw
2671 * Vertex type: Flexible vertex format vertex description
2672 * Vertices: Pointer to the vertex array
2673 * VertexCount: The number of vertices to draw
2674 * Flags: As usual a few flags
2678 * DDERR_INVALIDPARAMS if Vertices is NULL
2679 * For details, see IWineD3DDevice::DrawPrimitiveUP
2681 *****************************************************************************/
2682 static HRESULT WINAPI
2683 IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7
*iface
,
2684 D3DPRIMITIVETYPE PrimitiveType
,
2690 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2691 UINT PrimitiveCount
, stride
;
2693 TRACE("(%p)->(%08x,%08lx,%p,%08lx,%08lx): Relay!\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2696 return DDERR_INVALIDPARAMS
;
2698 /* Get the vertex count */
2699 switch(PrimitiveType
)
2701 case D3DPT_POINTLIST
:
2702 PrimitiveCount
= VertexCount
;
2705 case D3DPT_LINELIST
:
2706 PrimitiveCount
= VertexCount
/ 2;
2709 case D3DPT_LINESTRIP
:
2710 PrimitiveCount
= VertexCount
- 1;
2713 case D3DPT_TRIANGLELIST
:
2714 PrimitiveCount
= VertexCount
/ 3;
2717 case D3DPT_TRIANGLESTRIP
:
2718 PrimitiveCount
= VertexCount
- 2;
2721 case D3DPT_TRIANGLEFAN
:
2722 PrimitiveCount
= VertexCount
- 2;
2725 default: return DDERR_INVALIDPARAMS
;
2728 /* Get the stride */
2729 stride
= get_flexible_vertex_size(VertexType
);
2732 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, VertexType
);
2733 if(hr
!= D3D_OK
) return hr
;
2735 /* This method translates to the user pointer draw of WineD3D */
2736 return IWineD3DDevice_DrawPrimitiveUP(This
->wineD3DDevice
,
2743 static HRESULT WINAPI
2744 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(IDirect3DDevice3
*iface
,
2745 D3DPRIMITIVETYPE PrimitiveType
,
2751 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2752 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2753 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2761 static HRESULT WINAPI
2762 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive(IDirect3DDevice2
*iface
,
2763 D3DPRIMITIVETYPE PrimitiveType
,
2764 D3DVERTEXTYPE VertexType
,
2769 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2771 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2775 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
2776 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
2777 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
2779 ERR("Unexpected vertex type %d\n", VertexType
);
2780 return DDERR_INVALIDPARAMS
; /* Should never happen */
2783 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2791 /*****************************************************************************
2792 * IDirect3DDevice7::DrawIndexedPrimitive
2794 * Draws vertices from an application-provided pointer, based on the index
2795 * numbers in a WORD array.
2797 * Version 2, 3 and 7. The version 7 thunk translates the vertex type into
2798 * an FVF format for D3D7
2801 * PrimitiveType: The primitive type to draw
2802 * VertexType: The FVF vertex description
2803 * Vertices: Pointer to the vertex array
2805 * Indices: Pointer to the index array
2806 * IndexCount: Number of indices = Number of vertices to draw
2807 * Flags: As usual, some flags
2811 * DDERR_INVALIDPARAMS if Vertices or Indices is NULL
2812 * For details, see IWineD3DDevice::DrawIndexedPrimitiveUP
2814 *****************************************************************************/
2815 static HRESULT WINAPI
2816 IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7
*iface
,
2817 D3DPRIMITIVETYPE PrimitiveType
,
2825 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2826 UINT PrimitiveCount
= 0;
2828 TRACE("(%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx): Relay!\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
2829 /* Get the primitive number */
2830 switch(PrimitiveType
)
2832 case D3DPT_POINTLIST
:
2833 PrimitiveCount
= IndexCount
;
2836 case D3DPT_LINELIST
:
2837 PrimitiveCount
= IndexCount
/ 2;
2840 case D3DPT_LINESTRIP
:
2841 PrimitiveCount
= IndexCount
- 1;
2844 case D3DPT_TRIANGLELIST
:
2845 PrimitiveCount
= IndexCount
/ 3;
2848 case D3DPT_TRIANGLESTRIP
:
2849 PrimitiveCount
= IndexCount
- 2;
2852 case D3DPT_TRIANGLEFAN
:
2853 PrimitiveCount
= IndexCount
- 2;
2856 default: return DDERR_INVALIDPARAMS
;
2859 /* Set the D3DDevice's FVF */
2860 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, VertexType
);
2863 ERR(" (%p) Setting the FVF failed, hr = %lx!\n", This
, hr
);
2867 return IWineD3DDevice_DrawIndexedPrimitiveUP(This
->wineD3DDevice
,
2869 0 /* MinVertexIndex */,
2870 VertexCount
/* UINT NumVertexIndex */,
2875 get_flexible_vertex_size(VertexType
));
2878 static HRESULT WINAPI
2879 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(IDirect3DDevice3
*iface
,
2880 D3DPRIMITIVETYPE PrimitiveType
,
2888 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2889 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
2890 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2900 static HRESULT WINAPI
2901 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(IDirect3DDevice2
*iface
,
2902 D3DPRIMITIVETYPE PrimitiveType
,
2903 D3DVERTEXTYPE VertexType
,
2911 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2912 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
2916 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
2917 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
2918 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
2920 ERR("Unexpected vertex type %d\n", VertexType
);
2921 return DDERR_INVALIDPARAMS
; /* Should never happen */
2924 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2934 /*****************************************************************************
2935 * IDirect3DDevice7::SetClipStatus
2937 * Sets the clip status. This defines things as clipping conditions and
2938 * the extents of the clipping region.
2940 * Version 2, 3 and 7
2946 * D3D_OK because it's a stub
2947 * (DDERR_INVALIDPARAMS if ClipStatus == NULL)
2949 *****************************************************************************/
2950 static HRESULT WINAPI
2951 IDirect3DDeviceImpl_7_SetClipStatus(IDirect3DDevice7
*iface
,
2952 D3DCLIPSTATUS
*ClipStatus
)
2954 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2955 FIXME("(%p)->(%p): Stub!\n", This
, ClipStatus
);
2957 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them
2958 * Perhaps this needs a new data type and an additional IWineD3DDevice method
2960 /* return IWineD3DDevice_SetClipStatus(This->wineD3DDevice, ClipStatus);*/
2964 static HRESULT WINAPI
2965 Thunk_IDirect3DDeviceImpl_3_SetClipStatus(IDirect3DDevice3
*iface
,
2966 D3DCLIPSTATUS
*ClipStatus
)
2968 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2969 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
2970 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2974 static HRESULT WINAPI
2975 Thunk_IDirect3DDeviceImpl_2_SetClipStatus(IDirect3DDevice2
*iface
,
2976 D3DCLIPSTATUS
*ClipStatus
)
2978 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2979 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
2980 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2984 /*****************************************************************************
2985 * IDirect3DDevice7::GetClipStatus
2987 * Returns the clip status
2990 * ClipStatus: Address to write the clip status to
2993 * D3D_OK because it's a stub
2995 *****************************************************************************/
2996 static HRESULT WINAPI
2997 IDirect3DDeviceImpl_7_GetClipStatus(IDirect3DDevice7
*iface
,
2998 D3DCLIPSTATUS
*ClipStatus
)
3000 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3001 FIXME("(%p)->(%p): Stub!\n", This
, ClipStatus
);
3003 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them */
3004 /* return IWineD3DDevice_GetClipStatus(This->wineD3DDevice, ClipStatus);*/
3008 static HRESULT WINAPI
3009 Thunk_IDirect3DDeviceImpl_3_GetClipStatus(IDirect3DDevice3
*iface
,
3010 D3DCLIPSTATUS
*ClipStatus
)
3012 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3013 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3014 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3018 static HRESULT WINAPI
3019 Thunk_IDirect3DDeviceImpl_2_GetClipStatus(IDirect3DDevice2
*iface
,
3020 D3DCLIPSTATUS
*ClipStatus
)
3022 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3023 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3024 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3028 /*****************************************************************************
3029 * IDirect3DDevice::DrawPrimitiveStrided
3031 * Draws vertices described by a D3DDRAWPRIMITIVESTRIDEDDATA structure.
3036 * PrimitiveType: The primitive type to draw
3037 * VertexType: The FVF description of the vertices to draw (for the stride??)
3038 * D3DDrawPrimStrideData: A D3DDRAWPRIMITIVESTRIDEDDATA structure describing
3039 * the vertex data locations
3040 * VertexCount: The number of vertices to draw
3044 * D3D_OK, because it's a stub
3045 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3046 * (For details, see IWineD3DDevice::DrawPrimitiveStrided)
3048 *****************************************************************************/
3049 static HRESULT WINAPI
3050 IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7
*iface
,
3051 D3DPRIMITIVETYPE PrimitiveType
,
3053 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3057 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3058 WineDirect3DVertexStridedData WineD3DStrided
;
3060 UINT PrimitiveCount
;
3062 TRACE("(%p)->(%08x,%08lx,%p,%08lx,%08lx): stub!\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Flags
);
3064 /* Get the strided data right. the wined3d structure is a bit bigger
3065 * Watch out: The contents of the strided data are determined by the fvf,
3066 * not by the members set in D3DDrawPrimStrideData. So it's valid
3067 * to have diffuse.lpvData set to 0xdeadbeef if the diffuse flag is
3068 * not set in the fvf.
3070 if(VertexType
& D3DFVF_POSITION_MASK
)
3072 memset(&WineD3DStrided
, 0, sizeof(WineD3DStrided
));
3073 WineD3DStrided
.u
.s
.position
.lpData
= D3DDrawPrimStrideData
->position
.lpvData
;
3074 WineD3DStrided
.u
.s
.position
.dwStride
= D3DDrawPrimStrideData
->position
.dwStride
;
3075 WineD3DStrided
.u
.s
.position
.dwType
= WINED3DDECLTYPE_FLOAT3
;
3076 if (VertexType
& D3DFVF_XYZRHW
)
3078 WineD3DStrided
.u
.s
.position
.dwType
= WINED3DDECLTYPE_FLOAT4
;
3082 if(VertexType
& D3DFVF_NORMAL
)
3084 WineD3DStrided
.u
.s
.normal
.lpData
= D3DDrawPrimStrideData
->normal
.lpvData
;
3085 WineD3DStrided
.u
.s
.normal
.dwStride
= D3DDrawPrimStrideData
->normal
.dwStride
;
3086 WineD3DStrided
.u
.s
.normal
.dwType
= WINED3DDECLTYPE_FLOAT3
;
3089 if(VertexType
& D3DFVF_DIFFUSE
)
3091 WineD3DStrided
.u
.s
.diffuse
.lpData
= D3DDrawPrimStrideData
->diffuse
.lpvData
;
3092 WineD3DStrided
.u
.s
.diffuse
.dwStride
= D3DDrawPrimStrideData
->diffuse
.dwStride
;
3093 WineD3DStrided
.u
.s
.diffuse
.dwType
= WINED3DDECLTYPE_SHORT4
;
3096 if(VertexType
& D3DFVF_SPECULAR
)
3098 WineD3DStrided
.u
.s
.specular
.lpData
= D3DDrawPrimStrideData
->specular
.lpvData
;
3099 WineD3DStrided
.u
.s
.specular
.dwStride
= D3DDrawPrimStrideData
->specular
.dwStride
;
3100 WineD3DStrided
.u
.s
.specular
.dwType
= WINED3DDECLTYPE_SHORT4
;
3103 for( i
= 0; i
< GET_TEXCOUNT_FROM_FVF(VertexType
); i
++)
3105 WineD3DStrided
.u
.s
.texCoords
[i
].lpData
= D3DDrawPrimStrideData
->textureCoords
[i
].lpvData
;
3106 WineD3DStrided
.u
.s
.texCoords
[i
].dwStride
= D3DDrawPrimStrideData
->textureCoords
[i
].dwStride
;
3107 switch(GET_TEXCOORD_SIZE_FROM_FVF(VertexType
, i
))
3109 case 1: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT1
; break;
3110 case 2: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT2
; break;
3111 case 3: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT3
; break;
3112 case 4: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT4
; break;
3113 default: ERR("Unexpected texture coordinate size %ld\n",
3114 GET_TEXCOORD_SIZE_FROM_FVF(VertexType
, i
));
3118 /* Get the primitive count */
3119 switch(PrimitiveType
)
3121 case D3DPT_POINTLIST
:
3122 PrimitiveCount
= VertexCount
;
3125 case D3DPT_LINELIST
:
3126 PrimitiveCount
= VertexCount
/ 2;
3129 case D3DPT_LINESTRIP
:
3130 PrimitiveCount
= VertexCount
- 1;
3133 case D3DPT_TRIANGLELIST
:
3134 PrimitiveCount
= VertexCount
/ 3;
3137 case D3DPT_TRIANGLESTRIP
:
3138 PrimitiveCount
= VertexCount
- 2;
3141 case D3DPT_TRIANGLEFAN
:
3142 PrimitiveCount
= VertexCount
- 2;
3145 default: return DDERR_INVALIDPARAMS
;
3148 IWineD3DDevice_SetFVF(This
->wineD3DDevice
,
3151 return IWineD3DDevice_DrawPrimitiveStrided(This
->wineD3DDevice
,
3157 static HRESULT WINAPI
3158 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided(IDirect3DDevice3
*iface
,
3159 D3DPRIMITIVETYPE PrimitiveType
,
3161 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3165 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3166 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Flags
);
3167 return IDirect3DDevice7_DrawPrimitiveStrided(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3170 D3DDrawPrimStrideData
,
3175 /*****************************************************************************
3176 * IDirect3DDevice7::DrawIndexedPrimitiveStrided
3178 * Draws primitives specified by strided data locations based on indices
3186 * D3D_OK, because it's a stub
3187 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3188 * (DDERR_INVALIDPARAMS if Indices is NULL)
3189 * (For more details, see IWineD3DDevice::DrawIndexedPrimitiveStrided)
3191 *****************************************************************************/
3192 static HRESULT WINAPI
3193 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7
*iface
,
3194 D3DPRIMITIVETYPE PrimitiveType
,
3196 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3202 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3203 FIXME("(%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx): stub!\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Indices
, IndexCount
, Flags
);
3205 /* I'll implement it as soon as I find a app to test it.
3206 * This needs an additional method in IWineD3DDevice.
3211 static HRESULT WINAPI
3212 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(IDirect3DDevice3
*iface
,
3213 D3DPRIMITIVETYPE PrimitiveType
,
3215 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3221 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3222 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", iface
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Indices
, IndexCount
, Flags
);
3223 return IDirect3DDevice7_DrawIndexedPrimitiveStrided(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3226 D3DDrawPrimStrideData
,
3233 /*****************************************************************************
3234 * IDirect3DDevice7::DrawPrimitiveVB
3236 * Draws primitives from a vertex buffer to the screen.
3241 * PrimitiveType: Type of primitive to be rendered.
3242 * D3DVertexBuf: Source Vertex Buffer
3243 * StartVertex: Index of the first vertex from the buffer to be rendered
3244 * NumVertices: Number of vertices to be rendered
3245 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3249 * DDERR_INVALIDPARAMS if D3DVertexBuf is NULL
3251 *****************************************************************************/
3252 static HRESULT WINAPI
3253 IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7
*iface
,
3254 D3DPRIMITIVETYPE PrimitiveType
,
3255 IDirect3DVertexBuffer7
*D3DVertexBuf
,
3260 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3261 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer7
, D3DVertexBuf
);
3262 UINT PrimitiveCount
;
3265 WINED3DVERTEXBUFFER_DESC Desc
;
3267 TRACE("(%p)->(%08x,%p,%08lx,%08lx,%08lx)\n", This
, PrimitiveType
, D3DVertexBuf
, StartVertex
, NumVertices
, Flags
);
3272 ERR("(%p) No Vertex buffer specified\n", This
);
3273 return DDERR_INVALIDPARAMS
;
3276 /* Get the primitive count */
3277 switch(PrimitiveType
)
3279 case D3DPT_POINTLIST
:
3280 PrimitiveCount
= NumVertices
;
3283 case D3DPT_LINELIST
:
3284 PrimitiveCount
= NumVertices
/ 2;
3287 case D3DPT_LINESTRIP
:
3288 PrimitiveCount
= NumVertices
- 1;
3291 case D3DPT_TRIANGLELIST
:
3292 PrimitiveCount
= NumVertices
/ 3;
3295 case D3DPT_TRIANGLESTRIP
:
3296 PrimitiveCount
= NumVertices
- 2;
3299 case D3DPT_TRIANGLEFAN
:
3300 PrimitiveCount
= NumVertices
- 2;
3303 default: return DDERR_INVALIDPARAMS
;
3306 /* Get the FVF of the vertex buffer, and its stride */
3307 hr
= IWineD3DVertexBuffer_GetDesc(vb
->wineD3DVertexBuffer
,
3311 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08lx\n", This
, hr
);
3314 stride
= get_flexible_vertex_size(Desc
.FVF
);
3316 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, Desc
.FVF
);
3319 ERR(" (%p) Setting the FVF failed, hr = %lx!\n", This
, hr
);
3323 /* Set the vertex stream source */
3324 hr
= IWineD3DDevice_SetStreamSource(This
->wineD3DDevice
,
3325 0 /* StreamNumber */,
3326 vb
->wineD3DVertexBuffer
,
3327 0 /* StartVertex - we pass this to DrawPrimitive */,
3331 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08lx\n", This
, hr
);
3335 /* Now draw the primitives */
3336 return IWineD3DDevice_DrawPrimitive(This
->wineD3DDevice
,
3342 static HRESULT WINAPI
3343 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3
*iface
,
3344 D3DPRIMITIVETYPE PrimitiveType
,
3345 IDirect3DVertexBuffer
*D3DVertexBuf
,
3350 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3351 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer
, D3DVertexBuf
);
3352 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p,%08lx,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, vb
, StartVertex
, NumVertices
, Flags
);
3353 return IDirect3DDevice7_DrawPrimitiveVB(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3355 ICOM_INTERFACE(vb
, IDirect3DVertexBuffer7
),
3362 /*****************************************************************************
3363 * IDirect3DDevice7::DrawIndexedPrimitiveVB
3365 * Draws primitives from a vertex buffer to the screen
3368 * PrimitiveType: Type of primitive to be rendered.
3369 * D3DVertexBuf: Source Vertex Buffer
3370 * StartVertex: Index of the first vertex from the buffer to be rendered
3371 * NumVertices: Number of vertices to be rendered
3372 * Indices: Array of DWORDs used to index into the Vertices
3373 * IndexCount: Number of indices in Indices
3374 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3378 *****************************************************************************/
3379 static HRESULT WINAPI
3380 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7
*iface
,
3381 D3DPRIMITIVETYPE PrimitiveType
,
3382 IDirect3DVertexBuffer7
*D3DVertexBuf
,
3389 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3390 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer7
, D3DVertexBuf
);
3392 UINT PrimitiveCount
;
3393 WORD
*LockedIndices
;
3395 WINED3DVERTEXBUFFER_DESC Desc
;
3397 TRACE("(%p)->(%08x,%p,%ld,%ld,%p,%ld,%08lx)\n", This
, PrimitiveType
, vb
, StartVertex
, NumVertices
, Indices
, IndexCount
, Flags
);
3400 * 1) Calculate some things: Vertex count -> Primitive count, stride, ...
3401 * 2) Upload the Indices to the index buffer
3402 * 3) Set the index source
3403 * 4) Set the Vertex Buffer as the Stream source
3404 * 5) Call IWineD3DDevice::DrawIndexedPrimitive
3407 /* Get the primitive count */
3408 switch(PrimitiveType
)
3410 case D3DPT_POINTLIST
:
3411 PrimitiveCount
= IndexCount
;
3414 case D3DPT_LINELIST
:
3415 PrimitiveCount
= IndexCount
/ 2;
3418 case D3DPT_LINESTRIP
:
3419 PrimitiveCount
= IndexCount
- 1;
3422 case D3DPT_TRIANGLELIST
:
3423 PrimitiveCount
= IndexCount
/ 3;
3426 case D3DPT_TRIANGLESTRIP
:
3427 PrimitiveCount
= IndexCount
- 2;
3430 case D3DPT_TRIANGLEFAN
:
3431 PrimitiveCount
= IndexCount
- 2;
3434 default: return DDERR_INVALIDPARAMS
;
3437 /* Get the FVF of the vertex buffer, and its stride */
3438 hr
= IWineD3DVertexBuffer_GetDesc(vb
->wineD3DVertexBuffer
,
3442 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08lx\n", This
, hr
);
3445 stride
= get_flexible_vertex_size(Desc
.FVF
);
3446 TRACE("Vertex buffer FVF = %08lx, stride=%ld\n", Desc
.FVF
, stride
);
3448 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, Desc
.FVF
);
3451 ERR(" (%p) Setting the FVF failed, hr = %lx!\n", This
, hr
);
3455 /* copy the index stream into the index buffer.
3456 * A new IWineD3DDevice method could be created
3457 * which takes an user pointer containing the indices
3458 * or a SetData-Method for the index buffer, which
3459 * overrides the index buffer data with our pointer.
3461 hr
= IWineD3DIndexBuffer_Lock(This
->indexbuffer
,
3462 0 /* OffSetToLock */,
3463 0 /* SizeToLock - doesn't matter */,
3464 (BYTE
**) &LockedIndices
,
3466 assert(IndexCount
< 0x100000);
3469 ERR("(%p) IWineD3DIndexBuffer::Lock failed with hr = %08lx\n", This
, hr
);
3472 memcpy(LockedIndices
, Indices
, IndexCount
* sizeof(WORD
));
3473 hr
= IWineD3DIndexBuffer_Unlock(This
->indexbuffer
);
3476 ERR("(%p) IWineD3DIndexBuffer::Unlock failed with hr = %08lx\n", This
, hr
);
3480 /* Set the index stream */
3481 hr
= IWineD3DDevice_SetIndices(This
->wineD3DDevice
,
3485 /* Set the vertex stream source */
3486 hr
= IWineD3DDevice_SetStreamSource(This
->wineD3DDevice
,
3487 0 /* StreamNumber */,
3488 vb
->wineD3DVertexBuffer
,
3489 0 /* offset, we pass this to DrawIndexedPrimitive */,
3493 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08lx\n", This
, hr
);
3498 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->wineD3DDevice
,
3509 static HRESULT WINAPI
3510 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevice3
*iface
,
3511 D3DPRIMITIVETYPE PrimitiveType
,
3512 IDirect3DVertexBuffer
*D3DVertexBuf
,
3517 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3518 IDirect3DVertexBufferImpl
*VB
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer
, D3DVertexBuf
);
3519 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VB
, Indices
, IndexCount
, Flags
);
3521 return IDirect3DDevice7_DrawIndexedPrimitiveVB(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3523 ICOM_INTERFACE(VB
, IDirect3DVertexBuffer7
),
3531 /*****************************************************************************
3532 * IDirect3DDevice7::ComputeSphereVisibility
3534 * Calculates the visibility of spheres in the current viewport. The spheres
3535 * are passed in the Centers and Radii arrays, the results are passed back
3536 * in the ReturnValues array. Return values are either completely visible,
3537 * partially visible or completely invisible.
3538 * The return value consist of a combination of D3DCLIP_* flags, or it's
3539 * 0 if the sphere is completely visible(according to the SDK, not checked)
3541 * Sounds like an overdose of math ;)
3546 * Centers: Array containing the sphere centers
3547 * Radii: Array containing the sphere radii
3548 * NumSpheres: The number of centers and radii in the arrays
3550 * ReturnValues: Array to write the results to
3553 * D3D_OK because it's a stub
3554 * (DDERR_INVALIDPARAMS if Centers, Radii or ReturnValues are NULL)
3555 * (D3DERR_INVALIDMATRIX if the combined world, view and proj matrix
3558 *****************************************************************************/
3559 static HRESULT WINAPI
3560 IDirect3DDeviceImpl_7_ComputeSphereVisibility(IDirect3DDevice7
*iface
,
3565 DWORD
*ReturnValues
)
3567 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3568 FIXME("(%p)->(%p,%p,%08lx,%08lx,%p): stub!\n", This
, Centers
, Radii
, NumSpheres
, Flags
, ReturnValues
);
3570 /* the DirectX 7 sdk says that the visibility is computed by
3571 * back-transforming the viewing frustum to model space
3572 * using the inverse of the combined world, view and projection
3573 * matrix. If the matrix can't be reversed, D3DERR_INVALIDMATRIX
3576 * Basic implementation idea:
3577 * 1) Check if the center is in the viewing frustum
3578 * 2) Cut the sphere with the planes of the viewing
3581 * ->Center inside the frustum, no intersections:
3583 * ->Center outside the frustum, no intersections:
3585 * ->Some intersections: Partially visible
3587 * Implement this call in WineD3D. Either implement the
3588 * matrix and vector stuff in WineD3D, or use some external
3595 static HRESULT WINAPI
3596 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility(IDirect3DDevice3
*iface
,
3601 DWORD
*ReturnValues
)
3603 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3604 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08lx,%08lx,%p) thunking to IDirect3DDevice7 interface.\n", This
, Centers
, Radii
, NumSpheres
, Flags
, ReturnValues
);
3605 return IDirect3DDevice7_ComputeSphereVisibility(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3613 /*****************************************************************************
3614 * IDirect3DDevice7::GetTexture
3616 * Returns the texture interface handle assigned to a texture stage.
3617 * The returned texture is AddRefed. This is taken from old ddraw,
3618 * not checked in Windows.
3623 * Stage: Texture stage to read the texture from
3624 * Texture: Address to store the interface pointer at
3628 * DDERR_INVALIDPARAMS if Texture is NULL
3629 * For details, see IWineD3DDevice::GetTexture
3631 *****************************************************************************/
3632 static HRESULT WINAPI
3633 IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7
*iface
,
3635 IDirectDrawSurface7
**Texture
)
3637 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3638 IWineD3DBaseTexture
*Surf
;
3640 TRACE("(%p)->(%ld,%p): Relay\n", This
, Stage
, Texture
);
3644 TRACE("Texture == NULL, failing with DDERR_INVALIDPARAMS\n");
3645 return DDERR_INVALIDPARAMS
;
3648 hr
= IWineD3DDevice_GetTexture(This
->wineD3DDevice
, Stage
, (IWineD3DBaseTexture
**) &Surf
);
3649 if( (hr
!= D3D_OK
) || (!Surf
) )
3655 /* GetParent AddRef()s, which is perfectly OK.
3656 * We have passed the IDirectDrawSurface7 interface to WineD3D, so that's OK too.
3658 return IWineD3DBaseTexture_GetParent(Surf
,
3659 (IUnknown
**) Texture
);
3662 static HRESULT WINAPI
3663 Thunk_IDirect3DDeviceImpl_3_GetTexture(IDirect3DDevice3
*iface
,
3665 IDirect3DTexture2
**Texture2
)
3667 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3669 IDirectDrawSurface7
*ret_val
;
3671 TRACE_(ddraw_thunk
)("(%p)->(%ld,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, Texture2
);
3672 ret
= IDirect3DDevice7_GetTexture(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3676 *Texture2
= COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirect3DTexture2
, ret_val
);
3678 TRACE_(ddraw_thunk
)(" returning interface %p.\n", *Texture2
);
3683 /*****************************************************************************
3684 * IDirect3DDevice7::SetTexture
3686 * Assigns a texture to a texture stage. Is the texture AddRef-ed?
3691 * Stage: The stage to assign the texture to
3692 * Texture: Interface pointer to the texture surface
3696 * For details, see IWineD3DDevice::SetTexture
3698 *****************************************************************************/
3699 static HRESULT WINAPI
3700 IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7
*iface
,
3702 IDirectDrawSurface7
*Texture
)
3704 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3705 IDirectDrawSurfaceImpl
*surf
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, Texture
);
3706 TRACE("(%p)->(%08lx,%p): Relay!\n", This
, Stage
, surf
);
3708 /* Texture may be NULL here */
3709 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
3711 surf
? (IWineD3DBaseTexture
* ) surf
->wineD3DTexture
: NULL
);
3714 static HRESULT WINAPI
3715 Thunk_IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3
*iface
,
3717 IDirect3DTexture2
*Texture2
)
3719 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3720 IDirectDrawSurfaceImpl
*tex
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Texture2
);
3721 TRACE_(ddraw_thunk
)("(%p)->(%ld,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, tex
);
3722 return IDirect3DDevice7_SetTexture(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3724 ICOM_INTERFACE(tex
, IDirectDrawSurface7
));
3727 /*****************************************************************************
3728 * IDirect3DDevice7::GetTextureStageState
3730 * Retrieves a state from a texture stage.
3735 * Stage: The stage to retrieve the state from
3736 * TexStageStateType: The state type to retrieve
3737 * State: Address to store the state's value at
3741 * DDERR_INVALIDPARAMS if State is NULL
3742 * For details, see IWineD3DDevice::GetTextureStageState
3744 *****************************************************************************/
3745 static HRESULT WINAPI
3746 IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7
*iface
,
3748 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3751 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3752 TRACE("(%p)->(%08lx,%08x,%p): Relay!\n", This
, Stage
, TexStageStateType
, State
);
3755 return DDERR_INVALIDPARAMS
;
3757 return IWineD3DDevice_GetTextureStageState(This
->wineD3DDevice
,
3763 static HRESULT WINAPI
3764 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState(IDirect3DDevice3
*iface
,
3766 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3769 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3770 TRACE_(ddraw_thunk
)("(%p)->(%08lx,%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, TexStageStateType
, State
);
3771 return IDirect3DDevice7_GetTextureStageState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3777 /*****************************************************************************
3778 * IDirect3DDevice7::SetTextureStageState
3780 * Sets a texture stage state. Some stage types need to be handled specially,
3781 * because they do not exist in WineD3D and were moved to another place
3786 * Stage: The stage to modify
3787 * TexStageStateType: The state to change
3788 * State: The new value for the state
3792 * For details, see IWineD3DDevice::SetTextureStageState
3794 *****************************************************************************/
3795 static HRESULT WINAPI
3796 IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7
*iface
,
3798 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3801 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3802 TRACE("(%p)->(%08lx,%08x,%08lx): Relay!\n", This
, Stage
, TexStageStateType
, State
);
3803 switch(TexStageStateType
)
3805 /* Mipfilter is a sampler state with different values */
3806 case D3DTSS_MIPFILTER
:
3808 WINED3DTEXTUREFILTERTYPE value
;
3811 case D3DTFP_NONE
: value
= WINED3DTEXF_NONE
; break;
3812 case D3DTFP_POINT
: value
= WINED3DTEXF_POINT
; break;
3813 case 0: /* Unchecked */
3814 case D3DTFP_LINEAR
: value
= WINED3DTEXF_LINEAR
; break;
3816 ERR("Unexpected mipfilter value %ld\n", State
);
3817 value
= WINED3DTEXF_NONE
;
3819 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
3821 WINED3DSAMP_MIPFILTER
,
3825 /* Minfilter is a sampler state too, equal values */
3826 case D3DTSS_MINFILTER
:
3827 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
3829 WINED3DSAMP_MINFILTER
,
3831 /* Same for MAGFILTER */
3832 case D3DTSS_MAGFILTER
:
3833 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
3835 WINED3DSAMP_MAGFILTER
,
3840 return IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
,
3847 static HRESULT WINAPI
3848 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState(IDirect3DDevice3
*iface
,
3850 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3853 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3854 TRACE_(ddraw_thunk
)("(%p)->(%08lx,%08x,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, TexStageStateType
, State
);
3855 return IDirect3DDevice7_SetTextureStageState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3861 /*****************************************************************************
3862 * IDirect3DDevice7::ValidateDevice
3864 * SDK: "Reports the device's ability to render the currently set
3865 * texture-blending operations in a single pass". Whatever that means
3871 * NumPasses: Address to write the number of necessary passes for the
3872 * desired effect to.
3876 * See IWineD3DDevice::ValidateDevice for more details
3878 *****************************************************************************/
3879 static HRESULT WINAPI
3880 IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7
*iface
,
3883 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3884 TRACE("(%p)->(%p): Relay\n", This
, NumPasses
);
3886 return IWineD3DDevice_ValidateDevice(This
->wineD3DDevice
, NumPasses
);
3889 static HRESULT WINAPI
3890 Thunk_IDirect3DDeviceImpl_3_ValidateDevice(IDirect3DDevice3
*iface
,
3893 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3894 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Passes
);
3895 return IDirect3DDevice7_ValidateDevice(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3899 /*****************************************************************************
3900 * IDirect3DDevice7::Clear
3902 * Fills the render target, the z buffer and the stencil buffer with a
3903 * clear color / value
3908 * Count: Number of rectangles in Rects must be 0 if Rects is NULL
3909 * Rects: Rectangles to clear. If NULL, the whole surface is cleared
3910 * Flags: Some flags, as usual
3911 * Color: Clear color for the render target
3912 * Z: Clear value for the Z buffer
3913 * Stencil: Clear value to store in each stencil buffer entry
3917 * For details, see IWineD3DDevice::Clear
3919 *****************************************************************************/
3920 static HRESULT WINAPI
3921 IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7
*iface
,
3929 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3930 TRACE("(%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx): Relay\n", This
, Count
, Rects
, Flags
, (DWORD
) Color
, Z
, Stencil
);
3932 return IWineD3DDevice_Clear(This
->wineD3DDevice
, Count
, Rects
, Flags
, Color
, Z
, Stencil
);
3935 /*****************************************************************************
3936 * IDirect3DDevice7::SetViewport
3938 * Sets the current viewport.
3940 * Version 7 only, but IDirect3DViewport uses this call for older
3944 * Data: The new viewport to set
3948 * DDERR_INVALIDPARAMS if Data is NULL
3949 * For more details, see IWineDDDevice::SetViewport
3951 *****************************************************************************/
3952 static HRESULT WINAPI
3953 IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7
*iface
,
3956 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3957 TRACE("(%p)->(%p) Relay!\n", This
, Data
);
3960 return DDERR_INVALIDPARAMS
;
3962 return IWineD3DDevice_SetViewport(This
->wineD3DDevice
,
3966 /*****************************************************************************
3967 * IDirect3DDevice::GetViewport
3969 * Returns the current viewport
3974 * Data: D3D7Viewport structure to write the viewport information to
3978 * DDERR_INVALIDPARAMS if Data is NULL
3979 * For more details, see IWineD3DDevice::GetViewport
3981 *****************************************************************************/
3982 static HRESULT WINAPI
3983 IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7
*iface
,
3986 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3988 TRACE("(%p)->(%p) Relay!\n", This
, Data
);
3991 return DDERR_INVALIDPARAMS
;
3993 hr
= IWineD3DDevice_GetViewport(This
->wineD3DDevice
,
3995 return hr_ddraw_from_wined3d(hr
);
3998 /*****************************************************************************
3999 * IDirect3DDevice7::SetMaterial
4006 * Mat: The material to set
4010 * DDERR_INVALIDPARAMS if Mat is NULL.
4011 * For more details, see IWineD3DDevice::SetMaterial
4013 *****************************************************************************/
4014 static HRESULT WINAPI
4015 IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7
*iface
,
4018 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4020 TRACE("(%p)->(%p): Relay!\n", This
, Mat
);
4022 hr
= IWineD3DDevice_SetMaterial(This
->wineD3DDevice
,
4024 return hr_ddraw_from_wined3d(hr
);
4027 /*****************************************************************************
4028 * IDirect3DDevice7::GetMaterial
4030 * Returns the current material
4035 * Mat: D3DMATERIAL7 structure to write the material parameters to
4039 * DDERR_INVALIDPARAMS if Mat is NULL
4040 * For more details, see IWineD3DDevice::GetMaterial
4042 *****************************************************************************/
4043 static HRESULT WINAPI
4044 IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7
*iface
,
4047 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4049 TRACE("(%p)->(%p): Relay!\n", This
, Mat
);
4051 hr
= IWineD3DDevice_GetMaterial(This
->wineD3DDevice
,
4053 return hr_ddraw_from_wined3d(hr
);
4056 /*****************************************************************************
4057 * IDirect3DDevice7::SetLight
4059 * Assigns a light to a light index, but doesn't activate it yet.
4061 * Version 7, IDirect3DLight uses this method for older versions
4064 * LightIndex: The index of the new light
4065 * Light: A D3DLIGHT7 structure describing the light
4069 * For more details, see IWineD3DDevice::SetLight
4071 *****************************************************************************/
4072 static HRESULT WINAPI
4073 IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7
*iface
,
4077 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4079 TRACE("(%p)->(%08lx,%p): Relay!\n", This
, LightIndex
, Light
);
4081 hr
= IWineD3DDevice_SetLight(This
->wineD3DDevice
,
4084 return hr_ddraw_from_wined3d(hr
);
4087 /*****************************************************************************
4088 * IDirect3DDevice7::GetLight
4090 * Returns the light assigned to a light index
4093 * Light: Structure to write the light information to
4097 * DDERR_INVALIDPARAMS if Light is NULL
4098 * For details, see IWineD3DDevice::GetLight
4100 *****************************************************************************/
4101 static HRESULT WINAPI
4102 IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7
*iface
,
4106 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4108 TRACE("(%p)->(%08lx,%p): Relay!\n", This
, LightIndex
, Light
);
4110 rc
= IWineD3DDevice_GetLight(This
->wineD3DDevice
,
4114 /* Translate the result. WineD3D returns other values than D3D7 */
4115 return hr_ddraw_from_wined3d(rc
);
4118 /*****************************************************************************
4119 * IDirect3DDevice7::BeginStateBlock
4121 * Begins recording to a stateblock
4127 * For details see IWineD3DDevice::BeginStateBlock
4129 *****************************************************************************/
4130 static HRESULT WINAPI
4131 IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7
*iface
)
4133 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4135 TRACE("(%p)->(): Relay!\n", This
);
4137 hr
= IWineD3DDevice_BeginStateBlock(This
->wineD3DDevice
);
4138 return hr_ddraw_from_wined3d(hr
);
4141 /*****************************************************************************
4142 * IDirect3DDevice7::EndStateBlock
4144 * Stops recording to a state block and returns the created stateblock
4145 * handle. The d3d7 stateblock handles are the interface pointers of the
4146 * IWineD3DStateBlock interface
4151 * BlockHandle: Address to store the stateblock's handle to
4155 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4156 * See IWineD3DDevice::EndStateBlock for more details
4158 *****************************************************************************/
4159 static HRESULT WINAPI
4160 IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7
*iface
,
4163 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4165 TRACE("(%p)->(%p): Relay!\n", This
, BlockHandle
);
4168 return DDERR_INVALIDPARAMS
;
4170 hr
= IWineD3DDevice_EndStateBlock(This
->wineD3DDevice
,
4171 (IWineD3DStateBlock
**) BlockHandle
);
4172 return hr_ddraw_from_wined3d(hr
);
4175 /*****************************************************************************
4176 * IDirect3DDevice7::PreLoad
4178 * Allows the app to signal that a texture will be used soon, to allow
4179 * the Direct3DDevice to load it to the video card in the meantime.
4184 * Texture: The texture to preload
4188 * DDERR_INVALIDPARAMS if Texture is NULL
4189 * See IWineD3DSurface::PreLoad for details
4191 *****************************************************************************/
4192 static HRESULT WINAPI
4193 IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7
*iface
,
4194 IDirectDrawSurface7
*Texture
)
4196 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4197 IDirectDrawSurfaceImpl
*surf
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, Texture
);
4199 TRACE("(%p)->(%p): Relay!\n", This
, surf
);
4202 return DDERR_INVALIDPARAMS
;
4204 IWineD3DSurface_PreLoad(surf
->WineD3DSurface
);
4208 /*****************************************************************************
4209 * IDirect3DDevice7::ApplyStateBlock
4211 * Activates the state stored in a state block handle.
4214 * BlockHandle: The stateblock handle to activate
4218 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4220 *****************************************************************************/
4221 static HRESULT WINAPI
4222 IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7
*iface
,
4225 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4227 TRACE("(%p)->(%08lx): Relay!\n", This
, BlockHandle
);
4230 return D3DERR_INVALIDSTATEBLOCK
;
4232 hr
= IWineD3DStateBlock_Apply((IWineD3DStateBlock
*) BlockHandle
);
4233 return hr_ddraw_from_wined3d(hr
);
4236 /*****************************************************************************
4237 * IDirect3DDevice7::CaptureStateBlock
4239 * Updates a stateblock's values to the values currently set for the device
4244 * BlockHandle: Stateblock to update
4248 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4249 * See IWineD3DDevice::CaptureStateBlock for more details
4251 *****************************************************************************/
4252 static HRESULT WINAPI
4253 IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7
*iface
,
4256 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4258 TRACE("(%p)->(%08lx): Relay!\n", This
, BlockHandle
);
4260 if(BlockHandle
== 0)
4261 return D3DERR_INVALIDSTATEBLOCK
;
4263 hr
= IWineD3DStateBlock_Capture((IWineD3DStateBlock
*) BlockHandle
);
4264 return hr_ddraw_from_wined3d(hr
);
4267 /*****************************************************************************
4268 * IDirect3DDevice7::DeleteStateBlock
4270 * Deletes a stateblock handle. This means releasing the WineD3DStateBlock
4275 * BlockHandle: Stateblock handle to delete
4279 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is 0
4281 *****************************************************************************/
4282 static HRESULT WINAPI
4283 IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7
*iface
,
4286 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4287 TRACE("(%p)->(%08lx): Relay!\n", This
, BlockHandle
);
4289 if(BlockHandle
== 0)
4290 return D3DERR_INVALIDSTATEBLOCK
;
4292 IWineD3DStateBlock_Release((IWineD3DStateBlock
*) BlockHandle
);
4297 /*****************************************************************************
4298 * IDirect3DDevice7::CreateStateBlock
4300 * Creates a new state block handle.
4305 * Type: The state block type
4306 * BlockHandle: Address to write the created handle to
4310 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4312 *****************************************************************************/
4313 static HRESULT WINAPI
4314 IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7
*iface
,
4315 D3DSTATEBLOCKTYPE Type
,
4318 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4320 TRACE("(%p)->(%08x,%p)!\n", This
, Type
, BlockHandle
);
4323 return DDERR_INVALIDPARAMS
;
4325 /* The D3DSTATEBLOCKTYPE enum is fine here */
4326 hr
= IWineD3DDevice_CreateStateBlock(This
->wineD3DDevice
,
4328 (IWineD3DStateBlock
**) BlockHandle
,
4329 NULL
/* Parent, hope that works */);
4330 return hr_ddraw_from_wined3d(hr
);
4333 /*****************************************************************************
4334 * IDirect3DDevice7::Load
4336 * Loads a rectangular area from the source into the destination texture.
4337 * It can also copy the source to the faces of a cubic environment map
4342 * DestTex: Destination texture
4343 * DestPoint: Point in the destination where the source image should be
4345 * SrcTex: Source texture
4346 * SrcRect: Source rectangle
4351 * DDERR_INVALIDPARAMS if DestTex or SrcTex are NULL
4352 * See IDirect3DTexture2::Load for details
4354 *****************************************************************************/
4355 static HRESULT WINAPI
4356 IDirect3DDeviceImpl_7_Load(IDirect3DDevice7
*iface
,
4357 IDirectDrawSurface7
*DestTex
,
4359 IDirectDrawSurface7
*SrcTex
,
4363 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4364 IDirectDrawSurfaceImpl
*dest
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, DestTex
);
4365 IDirectDrawSurfaceImpl
*src
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, SrcTex
);
4366 FIXME("(%p)->(%p,%p,%p,%p,%08lx): Partially Implemented!\n", This
, dest
, DestPoint
, src
, SrcRect
, Flags
);
4368 if( (!src
) || (!dest
) )
4369 return DDERR_INVALIDPARAMS
;
4371 IDirect3DTexture2_Load(ICOM_INTERFACE(dest
, IDirect3DTexture2
),
4372 ICOM_INTERFACE(src
, IDirect3DTexture2
));
4376 /*****************************************************************************
4377 * IDirect3DDevice7::LightEnable
4379 * Enables or disables a light
4381 * Version 7, IDirect3DLight uses this method too.
4384 * LightIndex: The index of the light to enable / disable
4385 * Enable: Enable or disable the light
4389 * For more details, see IWineD3DDevice::SetLightEnable
4391 *****************************************************************************/
4392 static HRESULT WINAPI
4393 IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7
*iface
,
4397 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4399 TRACE("(%p)->(%08lx,%d): Relay!\n", This
, LightIndex
, Enable
);
4401 hr
= IWineD3DDevice_SetLightEnable(This
->wineD3DDevice
, LightIndex
, Enable
);
4402 return hr_ddraw_from_wined3d(hr
);
4405 /*****************************************************************************
4406 * IDirect3DDevice7::GetLightEnable
4408 * Retrieves if the light with the given index is enabled or not
4413 * LightIndex: Index of desired light
4414 * Enable: Pointer to a BOOL which contains the result
4418 * DDERR_INVALIDPARAMS if Enable is NULL
4419 * See IWineD3DDevice::GetLightEnable for more details
4421 *****************************************************************************/
4422 static HRESULT WINAPI
4423 IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7
*iface
,
4427 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4429 TRACE("(%p)->(%08lx,%p): Relay\n", This
, LightIndex
, Enable
);
4432 return DDERR_INVALIDPARAMS
;
4434 hr
= IWineD3DDevice_GetLightEnable(This
->wineD3DDevice
, LightIndex
, Enable
);
4435 return hr_ddraw_from_wined3d(hr
);
4438 /*****************************************************************************
4439 * IDirect3DDevice7::SetClipPlane
4441 * Sets custom clipping plane
4446 * Index: The index of the clipping plane
4447 * PlaneEquation: An equation defining the clipping plane
4451 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4452 * See IWineD3DDevice::SetClipPlane for more details
4454 *****************************************************************************/
4455 static HRESULT WINAPI
4456 IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7
*iface
,
4458 D3DVALUE
* PlaneEquation
)
4460 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4461 TRACE("(%p)->(%08lx,%p): Relay!\n", This
, Index
, PlaneEquation
);
4464 return DDERR_INVALIDPARAMS
;
4466 return IWineD3DDevice_SetClipPlane(This
->wineD3DDevice
, Index
, PlaneEquation
);
4469 /*****************************************************************************
4470 * IDirect3DDevice7::GetClipPlane
4472 * Returns the clipping plane with a specific index
4475 * Index: The index of the desired plane
4476 * PlaneEquation: Address to store the plane equation to
4480 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4481 * See IWineD3DDevice::GetClipPlane for more details
4483 *****************************************************************************/
4484 static HRESULT WINAPI
4485 IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7
*iface
,
4487 D3DVALUE
* PlaneEquation
)
4489 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4490 TRACE("(%p)->(%ld,%p): Relay!\n", This
, Index
, PlaneEquation
);
4493 return DDERR_INVALIDPARAMS
;
4495 return IWineD3DDevice_GetClipPlane(This
->wineD3DDevice
, Index
, PlaneEquation
);
4498 /*****************************************************************************
4499 * IDirect3DDevice7::GetInfo
4501 * Retrieves some information about the device. The DirectX sdk says that
4502 * this version returns S_FALSE for all retail builds of DirectX, that's what
4503 * this implementation does.
4506 * DevInfoID: Information type requested
4507 * DevInfoStruct: Pointer to a structure to store the info to
4508 * Size: Size of the structure
4511 * S_FALSE, because it's a non-debug driver
4513 *****************************************************************************/
4514 static HRESULT WINAPI
4515 IDirect3DDeviceImpl_7_GetInfo(IDirect3DDevice7
*iface
,
4517 void *DevInfoStruct
,
4520 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4521 TRACE("(%p)->(%08lx,%p,%08lx)\n", This
, DevInfoID
, DevInfoStruct
, Size
);
4525 TRACE(" info requested : ");
4528 case D3DDEVINFOID_TEXTUREMANAGER
: TRACE("D3DDEVINFOID_TEXTUREMANAGER\n"); break;
4529 case D3DDEVINFOID_D3DTEXTUREMANAGER
: TRACE("D3DDEVINFOID_D3DTEXTUREMANAGER\n"); break;
4530 case D3DDEVINFOID_TEXTURING
: TRACE("D3DDEVINFOID_TEXTURING\n"); break;
4531 default: ERR(" invalid flag !!!\n"); return DDERR_INVALIDPARAMS
;
4535 return S_FALSE
; /* According to MSDN, this is valid for a non-debug driver */
4538 const IDirect3DDevice7Vtbl IDirect3DDevice7_Vtbl
=
4540 /*** IUnknown Methods ***/
4541 IDirect3DDeviceImpl_7_QueryInterface
,
4542 IDirect3DDeviceImpl_7_AddRef
,
4543 IDirect3DDeviceImpl_7_Release
,
4544 /*** IDirect3DDevice7 ***/
4545 IDirect3DDeviceImpl_7_GetCaps
,
4546 IDirect3DDeviceImpl_7_EnumTextureFormats
,
4547 IDirect3DDeviceImpl_7_BeginScene
,
4548 IDirect3DDeviceImpl_7_EndScene
,
4549 IDirect3DDeviceImpl_7_GetDirect3D
,
4550 IDirect3DDeviceImpl_7_SetRenderTarget
,
4551 IDirect3DDeviceImpl_7_GetRenderTarget
,
4552 IDirect3DDeviceImpl_7_Clear
,
4553 IDirect3DDeviceImpl_7_SetTransform
,
4554 IDirect3DDeviceImpl_7_GetTransform
,
4555 IDirect3DDeviceImpl_7_SetViewport
,
4556 IDirect3DDeviceImpl_7_MultiplyTransform
,
4557 IDirect3DDeviceImpl_7_GetViewport
,
4558 IDirect3DDeviceImpl_7_SetMaterial
,
4559 IDirect3DDeviceImpl_7_GetMaterial
,
4560 IDirect3DDeviceImpl_7_SetLight
,
4561 IDirect3DDeviceImpl_7_GetLight
,
4562 IDirect3DDeviceImpl_7_SetRenderState
,
4563 IDirect3DDeviceImpl_7_GetRenderState
,
4564 IDirect3DDeviceImpl_7_BeginStateBlock
,
4565 IDirect3DDeviceImpl_7_EndStateBlock
,
4566 IDirect3DDeviceImpl_7_PreLoad
,
4567 IDirect3DDeviceImpl_7_DrawPrimitive
,
4568 IDirect3DDeviceImpl_7_DrawIndexedPrimitive
,
4569 IDirect3DDeviceImpl_7_SetClipStatus
,
4570 IDirect3DDeviceImpl_7_GetClipStatus
,
4571 IDirect3DDeviceImpl_7_DrawPrimitiveStrided
,
4572 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided
,
4573 IDirect3DDeviceImpl_7_DrawPrimitiveVB
,
4574 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB
,
4575 IDirect3DDeviceImpl_7_ComputeSphereVisibility
,
4576 IDirect3DDeviceImpl_7_GetTexture
,
4577 IDirect3DDeviceImpl_7_SetTexture
,
4578 IDirect3DDeviceImpl_7_GetTextureStageState
,
4579 IDirect3DDeviceImpl_7_SetTextureStageState
,
4580 IDirect3DDeviceImpl_7_ValidateDevice
,
4581 IDirect3DDeviceImpl_7_ApplyStateBlock
,
4582 IDirect3DDeviceImpl_7_CaptureStateBlock
,
4583 IDirect3DDeviceImpl_7_DeleteStateBlock
,
4584 IDirect3DDeviceImpl_7_CreateStateBlock
,
4585 IDirect3DDeviceImpl_7_Load
,
4586 IDirect3DDeviceImpl_7_LightEnable
,
4587 IDirect3DDeviceImpl_7_GetLightEnable
,
4588 IDirect3DDeviceImpl_7_SetClipPlane
,
4589 IDirect3DDeviceImpl_7_GetClipPlane
,
4590 IDirect3DDeviceImpl_7_GetInfo
4593 const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl
=
4595 /*** IUnknown Methods ***/
4596 Thunk_IDirect3DDeviceImpl_3_QueryInterface
,
4597 Thunk_IDirect3DDeviceImpl_3_AddRef
,
4598 Thunk_IDirect3DDeviceImpl_3_Release
,
4599 /*** IDirect3DDevice3 ***/
4600 IDirect3DDeviceImpl_3_GetCaps
,
4601 IDirect3DDeviceImpl_3_GetStats
,
4602 IDirect3DDeviceImpl_3_AddViewport
,
4603 IDirect3DDeviceImpl_3_DeleteViewport
,
4604 IDirect3DDeviceImpl_3_NextViewport
,
4605 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats
,
4606 Thunk_IDirect3DDeviceImpl_3_BeginScene
,
4607 Thunk_IDirect3DDeviceImpl_3_EndScene
,
4608 Thunk_IDirect3DDeviceImpl_3_GetDirect3D
,
4609 IDirect3DDeviceImpl_3_SetCurrentViewport
,
4610 IDirect3DDeviceImpl_3_GetCurrentViewport
,
4611 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget
,
4612 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget
,
4613 IDirect3DDeviceImpl_3_Begin
,
4614 IDirect3DDeviceImpl_3_BeginIndexed
,
4615 IDirect3DDeviceImpl_3_Vertex
,
4616 IDirect3DDeviceImpl_3_Index
,
4617 IDirect3DDeviceImpl_3_End
,
4618 Thunk_IDirect3DDeviceImpl_3_GetRenderState
,
4619 Thunk_IDirect3DDeviceImpl_3_SetRenderState
,
4620 IDirect3DDeviceImpl_3_GetLightState
,
4621 IDirect3DDeviceImpl_3_SetLightState
,
4622 Thunk_IDirect3DDeviceImpl_3_SetTransform
,
4623 Thunk_IDirect3DDeviceImpl_3_GetTransform
,
4624 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform
,
4625 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive
,
4626 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive
,
4627 Thunk_IDirect3DDeviceImpl_3_SetClipStatus
,
4628 Thunk_IDirect3DDeviceImpl_3_GetClipStatus
,
4629 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided
,
4630 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided
,
4631 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB
,
4632 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB
,
4633 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility
,
4634 Thunk_IDirect3DDeviceImpl_3_GetTexture
,
4635 Thunk_IDirect3DDeviceImpl_3_SetTexture
,
4636 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState
,
4637 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState
,
4638 Thunk_IDirect3DDeviceImpl_3_ValidateDevice
4641 const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl
=
4643 /*** IUnknown Methods ***/
4644 Thunk_IDirect3DDeviceImpl_2_QueryInterface
,
4645 Thunk_IDirect3DDeviceImpl_2_AddRef
,
4646 Thunk_IDirect3DDeviceImpl_2_Release
,
4647 /*** IDirect3DDevice2 ***/
4648 Thunk_IDirect3DDeviceImpl_2_GetCaps
,
4649 IDirect3DDeviceImpl_2_SwapTextureHandles
,
4650 Thunk_IDirect3DDeviceImpl_2_GetStats
,
4651 Thunk_IDirect3DDeviceImpl_2_AddViewport
,
4652 Thunk_IDirect3DDeviceImpl_2_DeleteViewport
,
4653 Thunk_IDirect3DDeviceImpl_2_NextViewport
,
4654 IDirect3DDeviceImpl_2_EnumTextureFormats
,
4655 Thunk_IDirect3DDeviceImpl_2_BeginScene
,
4656 Thunk_IDirect3DDeviceImpl_2_EndScene
,
4657 Thunk_IDirect3DDeviceImpl_2_GetDirect3D
,
4658 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport
,
4659 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport
,
4660 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget
,
4661 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget
,
4662 Thunk_IDirect3DDeviceImpl_2_Begin
,
4663 Thunk_IDirect3DDeviceImpl_2_BeginIndexed
,
4664 Thunk_IDirect3DDeviceImpl_2_Vertex
,
4665 Thunk_IDirect3DDeviceImpl_2_Index
,
4666 Thunk_IDirect3DDeviceImpl_2_End
,
4667 Thunk_IDirect3DDeviceImpl_2_GetRenderState
,
4668 Thunk_IDirect3DDeviceImpl_2_SetRenderState
,
4669 Thunk_IDirect3DDeviceImpl_2_GetLightState
,
4670 Thunk_IDirect3DDeviceImpl_2_SetLightState
,
4671 Thunk_IDirect3DDeviceImpl_2_SetTransform
,
4672 Thunk_IDirect3DDeviceImpl_2_GetTransform
,
4673 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform
,
4674 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive
,
4675 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive
,
4676 Thunk_IDirect3DDeviceImpl_2_SetClipStatus
,
4677 Thunk_IDirect3DDeviceImpl_2_GetClipStatus
4680 const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl
=
4682 /*** IUnknown Methods ***/
4683 Thunk_IDirect3DDeviceImpl_1_QueryInterface
,
4684 Thunk_IDirect3DDeviceImpl_1_AddRef
,
4685 Thunk_IDirect3DDeviceImpl_1_Release
,
4686 /*** IDirect3DDevice1 ***/
4687 IDirect3DDeviceImpl_1_Initialize
,
4688 Thunk_IDirect3DDeviceImpl_1_GetCaps
,
4689 Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles
,
4690 IDirect3DDeviceImpl_1_CreateExecuteBuffer
,
4691 Thunk_IDirect3DDeviceImpl_1_GetStats
,
4692 IDirect3DDeviceImpl_1_Execute
,
4693 Thunk_IDirect3DDeviceImpl_1_AddViewport
,
4694 Thunk_IDirect3DDeviceImpl_1_DeleteViewport
,
4695 Thunk_IDirect3DDeviceImpl_1_NextViewport
,
4696 IDirect3DDeviceImpl_1_Pick
,
4697 IDirect3DDeviceImpl_1_GetPickRecords
,
4698 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats
,
4699 IDirect3DDeviceImpl_1_CreateMatrix
,
4700 IDirect3DDeviceImpl_1_SetMatrix
,
4701 IDirect3DDeviceImpl_1_GetMatrix
,
4702 IDirect3DDeviceImpl_1_DeleteMatrix
,
4703 Thunk_IDirect3DDeviceImpl_1_EndScene
,
4704 Thunk_IDirect3DDeviceImpl_1_BeginScene
,
4705 Thunk_IDirect3DDeviceImpl_1_GetDirect3D
4708 /*****************************************************************************
4709 * IDirect3DDeviceImpl_CreateHandle
4711 * Not called from the VTable
4713 * Some older interface versions operate with handles, which are basically
4714 * DWORDs which identify an interface, for example
4715 * IDirect3DDevice::SetRenderState with DIRECT3DRENDERSTATE_TEXTUREHANDLE
4717 * Those handle could be just casts to the interface pointers or vice versa,
4718 * but that is not 64 bit safe and would mean blindly derefering a DWORD
4719 * passed by the app. Instead there is a dynamic array in the device which
4720 * keeps a DWORD to pointer information and a type for the handle.
4722 * Basically this array only grows, when a handle is freed its pointer is
4723 * just set to NULL. There will be much more reads from the array than
4724 * insertion operations, so a dynamic array is fine.
4727 * This: D3DDevice implementation for which this handle should be created
4730 * A free handle on success
4733 *****************************************************************************/
4735 IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl
*This
)
4738 struct HandleEntry
*oldHandles
= This
->Handles
;
4740 TRACE("(%p)\n", This
);
4742 for(i
= 0; i
< This
->numHandles
; i
++)
4744 if(This
->Handles
[i
].ptr
== NULL
&&
4745 This
->Handles
[i
].type
== DDrawHandle_Unknown
)
4747 TRACE("Reusing freed handle %ld\n", i
+ 1);
4752 TRACE("Growing the handle array\n");
4755 This
->Handles
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct HandleEntry
) * This
->numHandles
);
4758 ERR("Out of memory\n");
4759 This
->Handles
= oldHandles
;
4765 memcpy(This
->Handles
, oldHandles
, (This
->numHandles
- 1) * sizeof(struct HandleEntry
));
4766 HeapFree(GetProcessHeap(), 0, oldHandles
);
4769 TRACE("Returning %ld\n", This
->numHandles
);
4770 return This
->numHandles
;