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\n", 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 %u.\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 %u.\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 %d not unset properly\n", i
+ 1);
338 case DDrawHandle_Material
:
340 IDirect3DMaterialImpl
*mat
= (IDirect3DMaterialImpl
*) This
->Handles
[i
].ptr
;
341 FIXME("Material handle %d 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 %d, deleting\n", i
+ 1);
350 IDirect3DDevice_DeleteMatrix(ICOM_INTERFACE(This
, IDirect3DDevice
),
356 FIXME("Unknown handle %d 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,%08x)\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,%08x)\n", This
, vp
, lplpDirect3DViewport3
, Flags
);
906 *lplpDirect3DViewport3
= NULL
;
907 return DDERR_INVALIDPARAMS
;
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,%08x) 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,%08x) 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,%08x,%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 * IDirect3DDevice7::EnumTextureformats
1046 * Enumerates the supported texture formats. It has a list of all possible
1047 * formats and calls IWineD3D::CheckDeviceFormat for each format to see if
1048 * WineD3D supports it. If so, then it is passed to the app.
1050 * This is for Version 7 and 3, older versions have a different
1051 * callback function and their own implementation
1054 * Callback: Callback to call for each enumerated format
1055 * Arg: Argument to pass to the callback
1059 * DDERR_INVALIDPARAMS if Callback == NULL
1061 *****************************************************************************/
1062 static HRESULT WINAPI
1063 IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7
*iface
,
1064 LPD3DENUMPIXELFORMATSCALLBACK Callback
,
1067 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1071 WINED3DFORMAT FormatList
[] = {
1073 WINED3DFMT_A8R8G8B8
,
1074 WINED3DFMT_X8R8G8B8
,
1078 WINED3DFMT_A1R5G5B5
,
1079 WINED3DFMT_A4R4G4B4
,
1081 WINED3DFMT_X1R5G5B5
,
1091 TRACE("(%p)->(%p,%p): Relay\n", This
, Callback
, Arg
);
1094 return DDERR_INVALIDPARAMS
;
1096 for(i
= 0; i
< sizeof(FormatList
) / sizeof(WINED3DFORMAT
); i
++)
1098 hr
= IWineD3D_CheckDeviceFormat(This
->ddraw
->wineD3D
,
1101 0 /* AdapterFormat */,
1103 0 /* ResourceType */,
1107 DDPIXELFORMAT pformat
;
1109 memset(&pformat
, 0, sizeof(pformat
));
1110 pformat
.dwSize
= sizeof(pformat
);
1111 PixelFormat_WineD3DtoDD(&pformat
, FormatList
[i
]);
1113 TRACE("Enumerating WineD3DFormat %d\n", FormatList
[i
]);
1114 hr
= Callback(&pformat
, Arg
);
1115 if(hr
!= DDENUMRET_OK
)
1117 TRACE("Format enumeration cancelled by application\n");
1122 TRACE("End of enumeration\n");
1126 static HRESULT WINAPI
1127 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats(IDirect3DDevice3
*iface
,
1128 LPD3DENUMPIXELFORMATSCALLBACK Callback
,
1131 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1132 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice7 interface.\n", This
, Callback
, Arg
);
1133 return IDirect3DDevice7_EnumTextureFormats(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1138 /*****************************************************************************
1139 * IDirect3DDevice2::EnumTextureformats
1141 * EnumTextureFormats for Version 1 and 2, see
1142 * IDirect3DDevice7::EnumTexureFormats for a more detailed description.
1144 * This version has a different callback and does not enumerate FourCC
1147 *****************************************************************************/
1148 static HRESULT WINAPI
1149 IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2
*iface
,
1150 LPD3DENUMTEXTUREFORMATSCALLBACK Callback
,
1153 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1157 WINED3DFORMAT FormatList
[] = {
1159 WINED3DFMT_A8R8G8B8
,
1160 WINED3DFMT_X8R8G8B8
,
1164 WINED3DFMT_A1R5G5B5
,
1165 WINED3DFMT_A4R4G4B4
,
1167 WINED3DFMT_X1R5G5B5
,
1171 /* FOURCC codes - Not in this version*/
1174 TRACE("(%p)->(%p,%p): Relay\n", This
, Callback
, Arg
);
1177 return DDERR_INVALIDPARAMS
;
1179 for(i
= 0; i
< sizeof(FormatList
) / sizeof(WINED3DFORMAT
); i
++)
1181 hr
= IWineD3D_CheckDeviceFormat(This
->ddraw
->wineD3D
,
1184 0 /* AdapterFormat */,
1186 0 /* ResourceType */,
1190 DDSURFACEDESC sdesc
;
1192 memset(&sdesc
, 0, sizeof(sdesc
));
1193 sdesc
.dwSize
= sizeof(sdesc
);
1194 sdesc
.dwFlags
= DDSD_PIXELFORMAT
| DDSD_CAPS
;
1195 sdesc
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
;
1196 sdesc
.ddpfPixelFormat
.dwSize
= sizeof(sdesc
.ddpfPixelFormat
.dwSize
);
1197 PixelFormat_WineD3DtoDD(&sdesc
.ddpfPixelFormat
, FormatList
[i
]);
1199 TRACE("Enumerating WineD3DFormat %d\n", FormatList
[i
]);
1200 hr
= Callback(&sdesc
, Arg
);
1201 if(hr
!= DDENUMRET_OK
)
1203 TRACE("Format enumeration cancelled by application\n");
1208 TRACE("End of enumeration\n");
1212 static HRESULT WINAPI
1213 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats(IDirect3DDevice
*iface
,
1214 LPD3DENUMTEXTUREFORMATSCALLBACK Callback
,
1217 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1218 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", This
, Callback
, Arg
);
1219 return IDirect3DDevice2_EnumTextureFormats(ICOM_INTERFACE(This
, IDirect3DDevice2
),
1224 /*****************************************************************************
1225 * IDirect3DDevice::CreateMatrix
1227 * Creates a matrix handle. A handle is created and memory for a D3DMATRIX is
1228 * allocated for the handle.
1233 * D3DMatHandle: Address to return the handle at
1237 * DDERR_INVALIDPARAMS if D3DMatHandle = NULL
1239 *****************************************************************************/
1240 static HRESULT WINAPI
1241 IDirect3DDeviceImpl_1_CreateMatrix(IDirect3DDevice
*iface
, D3DMATRIXHANDLE
*D3DMatHandle
)
1243 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1245 TRACE("(%p)->(%p)\n", This
, D3DMatHandle
);
1248 return DDERR_INVALIDPARAMS
;
1250 Matrix
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(D3DMATRIX
));
1253 ERR("Out of memory when allocating a D3DMATRIX\n");
1254 return DDERR_OUTOFMEMORY
;
1256 *D3DMatHandle
= IDirect3DDeviceImpl_CreateHandle(This
);
1257 if(!(*D3DMatHandle
))
1259 ERR("Failed to create a matrix handle\n");
1260 HeapFree(GetProcessHeap(), 0, Matrix
);
1261 return DDERR_OUTOFMEMORY
;
1263 This
->Handles
[(DWORD
) *D3DMatHandle
- 1].ptr
= Matrix
;
1264 This
->Handles
[(DWORD
) *D3DMatHandle
- 1].type
= DDrawHandle_Matrix
;
1265 TRACE(" returning matrix handle %d\n", *D3DMatHandle
);
1270 /*****************************************************************************
1271 * IDirect3DDevice::SetMatrix
1273 * Sets a matrix for a matrix handle. The matrix is copied into the memory
1274 * allocated for the handle
1279 * D3DMatHandle: Handle to set the matrix to
1280 * D3DMatrix: Matrix to set
1284 * DDERR_INVALIDPARAMS if the handle of the matrix is invalid or the matrix
1287 *****************************************************************************/
1288 static HRESULT WINAPI
1289 IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice
*iface
,
1290 D3DMATRIXHANDLE D3DMatHandle
,
1291 D3DMATRIX
*D3DMatrix
)
1293 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1294 TRACE("(%p)->(%08x,%p)\n", This
, (DWORD
) D3DMatHandle
, D3DMatrix
);
1296 if( (!D3DMatHandle
) || (!D3DMatrix
) )
1297 return DDERR_INVALIDPARAMS
;
1299 if(D3DMatHandle
> This
->numHandles
)
1301 ERR("Handle %d out of range\n", D3DMatHandle
);
1302 return DDERR_INVALIDPARAMS
;
1304 else if(This
->Handles
[D3DMatHandle
- 1].type
!= DDrawHandle_Matrix
)
1306 ERR("Handle %d is not a matrix handle\n", D3DMatHandle
);
1307 return DDERR_INVALIDPARAMS
;
1311 dump_D3DMATRIX(D3DMatrix
);
1313 *((D3DMATRIX
*) This
->Handles
[D3DMatHandle
- 1].ptr
) = *D3DMatrix
;
1318 /*****************************************************************************
1319 * IDirect3DDevice::SetMatrix
1321 * Returns the content of a D3DMATRIX handle
1326 * D3DMatHandle: Matrix handle to read the content from
1327 * D3DMatrix: Address to store the content at
1331 * DDERR_INVALIDPARAMS if D3DMatHandle is invalid or D3DMatrix is NULL
1333 *****************************************************************************/
1334 static HRESULT WINAPI
1335 IDirect3DDeviceImpl_1_GetMatrix(IDirect3DDevice
*iface
,
1336 D3DMATRIXHANDLE D3DMatHandle
,
1337 D3DMATRIX
*D3DMatrix
)
1339 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1340 TRACE("(%p)->(%08x,%p)\n", This
, (DWORD
) D3DMatHandle
, D3DMatrix
);
1343 return DDERR_INVALIDPARAMS
;
1345 return DDERR_INVALIDPARAMS
;
1347 if(D3DMatHandle
> This
->numHandles
)
1349 ERR("Handle %d out of range\n", D3DMatHandle
);
1350 return DDERR_INVALIDPARAMS
;
1352 else if(This
->Handles
[D3DMatHandle
- 1].type
!= DDrawHandle_Matrix
)
1354 ERR("Handle %d is not a matrix handle\n", D3DMatHandle
);
1355 return DDERR_INVALIDPARAMS
;
1358 /* The handle is simply a pointer to a D3DMATRIX structure */
1359 *D3DMatrix
= *((D3DMATRIX
*) This
->Handles
[D3DMatHandle
- 1].ptr
);
1364 /*****************************************************************************
1365 * IDirect3DDevice::DeleteMatrix
1367 * Destroys a Matrix handle. Frees the memory and unsets the handle data
1372 * D3DMatHandle: Handle to destroy
1376 * DDERR_INVALIDPARAMS if D3DMatHandle is invalid
1378 *****************************************************************************/
1379 static HRESULT WINAPI
1380 IDirect3DDeviceImpl_1_DeleteMatrix(IDirect3DDevice
*iface
,
1381 D3DMATRIXHANDLE D3DMatHandle
)
1383 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1384 TRACE("(%p)->(%08x)\n", This
, (DWORD
) D3DMatHandle
);
1387 return DDERR_INVALIDPARAMS
;
1389 if(D3DMatHandle
> This
->numHandles
)
1391 ERR("Handle %d out of range\n", D3DMatHandle
);
1392 return DDERR_INVALIDPARAMS
;
1394 else if(This
->Handles
[D3DMatHandle
- 1].type
!= DDrawHandle_Matrix
)
1396 ERR("Handle %d is not a matrix handle\n", D3DMatHandle
);
1397 return DDERR_INVALIDPARAMS
;
1400 HeapFree(GetProcessHeap(), 0, This
->Handles
[D3DMatHandle
- 1].ptr
);
1401 This
->Handles
[D3DMatHandle
- 1].ptr
= NULL
;
1402 This
->Handles
[D3DMatHandle
- 1].type
= DDrawHandle_Unknown
;
1407 /*****************************************************************************
1408 * IDirect3DDevice7::BeginScene
1410 * This method must be called before any rendering is performed.
1411 * IDirect3DDevice::EndScene has to be called after the scene is complete
1413 * Version 1, 2, 3 and 7
1416 * D3D_OK on success, for details see IWineD3DDevice::BeginScene
1418 *****************************************************************************/
1419 static HRESULT WINAPI
1420 IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7
*iface
)
1422 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1423 TRACE("(%p): Relay\n", This
);
1425 return IWineD3DDevice_BeginScene(This
->wineD3DDevice
);
1428 static HRESULT WINAPI
1429 Thunk_IDirect3DDeviceImpl_3_BeginScene(IDirect3DDevice3
*iface
)
1431 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1432 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1433 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1436 static HRESULT WINAPI
1437 Thunk_IDirect3DDeviceImpl_2_BeginScene(IDirect3DDevice2
*iface
)
1439 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1440 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1441 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1444 static HRESULT WINAPI
1445 Thunk_IDirect3DDeviceImpl_1_BeginScene(IDirect3DDevice
*iface
)
1447 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1448 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1449 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1452 /*****************************************************************************
1453 * IDirect3DDevice7::EndScene
1455 * Ends a scene that has been begun with IDirect3DDevice7::BeginScene.
1456 * This method must be called after rendering is finished.
1458 * Version 1, 2, 3 and 7
1461 * D3D_OK on success, for details see IWineD3DDevice::EndScene
1463 *****************************************************************************/
1464 static HRESULT WINAPI
1465 IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7
*iface
)
1467 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1468 TRACE("(%p): Relay\n", This
);
1470 IWineD3DDevice_EndScene(This
->wineD3DDevice
);
1474 static HRESULT WINAPI
1475 Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3
*iface
)
1477 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1478 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1479 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1482 static HRESULT WINAPI
1483 Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2
*iface
)
1485 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1486 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1487 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1490 static HRESULT WINAPI
1491 Thunk_IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice
*iface
)
1493 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1494 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1495 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1498 /*****************************************************************************
1499 * IDirect3DDevice7::GetDirect3D
1501 * Returns the IDirect3D(= interface to the DirectDraw object) used to create
1505 * Direct3D7: Address to store the interface pointer at
1509 * DDERR_INVALIDPARAMS if Direct3D7 == NULL
1511 *****************************************************************************/
1512 static HRESULT WINAPI
1513 IDirect3DDeviceImpl_7_GetDirect3D(IDirect3DDevice7
*iface
,
1514 IDirect3D7
**Direct3D7
)
1516 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1517 TRACE("(%p)->(%p)\n", This
, Direct3D7
);
1520 return DDERR_INVALIDPARAMS
;
1522 *Direct3D7
= ICOM_INTERFACE(This
->ddraw
, IDirect3D7
);
1523 IDirect3D7_AddRef(*Direct3D7
);
1525 TRACE(" returning interface %p\n", *Direct3D7
);
1529 static HRESULT WINAPI
1530 Thunk_IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3
*iface
,
1531 IDirect3D3
**Direct3D3
)
1533 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1535 IDirect3D7
*ret_ptr
;
1537 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D3
);
1538 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1542 *Direct3D3
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D3
, ret_ptr
);
1543 TRACE(" returning interface %p\n", *Direct3D3
);
1547 static HRESULT WINAPI
1548 Thunk_IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2
*iface
,
1549 IDirect3D2
**Direct3D2
)
1551 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1553 IDirect3D7
*ret_ptr
;
1555 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D2
);
1556 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1560 *Direct3D2
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D2
, ret_ptr
);
1561 TRACE(" returning interface %p\n", *Direct3D2
);
1565 static HRESULT WINAPI
1566 Thunk_IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice
*iface
,
1567 IDirect3D
**Direct3D
)
1569 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1571 IDirect3D7
*ret_ptr
;
1573 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D
);
1574 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1578 *Direct3D
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D
, ret_ptr
);
1579 TRACE(" returning interface %p\n", *Direct3D
);
1583 /*****************************************************************************
1584 * IDirect3DDevice3::SetCurrentViewport
1586 * Sets a Direct3DViewport as the current viewport.
1587 * For the thunks note that all viewport interface versions are equal
1590 * Direct3DViewport3: The viewport to set
1596 * (Is a NULL viewport valid?)
1598 *****************************************************************************/
1599 static HRESULT WINAPI
1600 IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3
*iface
,
1601 IDirect3DViewport3
*Direct3DViewport3
)
1603 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1604 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport3
);
1605 TRACE("(%p)->(%p)\n", This
, Direct3DViewport3
);
1607 /* Do nothing if the specified viewport is the same as the current one */
1608 if (This
->current_viewport
== vp
)
1611 /* Should check if the viewport was added or not */
1613 /* Release previous viewport and AddRef the new one */
1614 if (This
->current_viewport
)
1616 TRACE("ViewportImpl is at %p, interface is at %p\n", This
->current_viewport
, ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
));
1617 IDirect3DViewport3_Release( ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
) );
1619 IDirect3DViewport3_AddRef(Direct3DViewport3
);
1621 /* Set this viewport as the current viewport */
1622 This
->current_viewport
= vp
;
1624 /* Activate this viewport */
1625 This
->current_viewport
->active_device
= This
;
1626 This
->current_viewport
->activate(This
->current_viewport
);
1631 static HRESULT WINAPI
1632 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2
*iface
,
1633 IDirect3DViewport2
*Direct3DViewport2
)
1635 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1636 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
1637 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
1638 return IDirect3DDevice3_SetCurrentViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1639 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
1642 /*****************************************************************************
1643 * IDirect3DDevice3::GetCurrentViewport
1645 * Returns the currently active viewport.
1650 * Direct3DViewport3: Address to return the interface pointer at
1654 * DDERR_INVALIDPARAMS if Direct3DViewport == NULL
1656 *****************************************************************************/
1657 static HRESULT WINAPI
1658 IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3
*iface
,
1659 IDirect3DViewport3
**Direct3DViewport3
)
1661 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1662 TRACE("(%p)->(%p)\n", This
, Direct3DViewport3
);
1664 if(!Direct3DViewport3
)
1665 return DDERR_INVALIDPARAMS
;
1667 *Direct3DViewport3
= ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
);
1669 /* AddRef the returned viewport */
1670 if(*Direct3DViewport3
) IDirect3DViewport3_AddRef(*Direct3DViewport3
);
1672 TRACE(" returning interface %p\n", *Direct3DViewport3
);
1677 static HRESULT WINAPI
1678 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(IDirect3DDevice2
*iface
,
1679 IDirect3DViewport2
**Direct3DViewport2
)
1681 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1683 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Direct3DViewport2
);
1684 hr
= IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1685 (IDirect3DViewport3
**) Direct3DViewport2
);
1686 if(hr
!= D3D_OK
) return hr
;
1687 *Direct3DViewport2
= (IDirect3DViewport2
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, Direct3DViewport2
);
1691 /*****************************************************************************
1692 * IDirect3DDevice7::SetRenderTarget
1694 * Sets the render target for the Direct3DDevice.
1695 * For the thunks note that IDirectDrawSurface7 == IDirectDrawSurface4 and
1696 * IDirectDrawSurface3 == IDirectDrawSurface
1698 * Version 2, 3 and 7
1701 * NewTarget: Pointer to an IDirectDrawSurface7 interface to set as the new
1706 * D3D_OK on success, for details see IWineD3DDevice::SetRenderTarget
1708 *****************************************************************************/
1709 static HRESULT WINAPI
1710 IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7
*iface
,
1711 IDirectDrawSurface7
*NewTarget
,
1714 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1715 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, NewTarget
);
1716 TRACE("(%p)->(%p,%08x): Relay\n", This
, NewTarget
, Flags
);
1718 /* Flags: Not used */
1720 return IWineD3DDevice_SetRenderTarget(This
->wineD3DDevice
,
1722 Target
? Target
->WineD3DSurface
: NULL
);
1725 static HRESULT WINAPI
1726 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3
*iface
,
1727 IDirectDrawSurface4
*NewRenderTarget
,
1730 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1731 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, NewRenderTarget
);
1732 TRACE_(ddraw_thunk
)("(%p)->(%p,%08x) thunking to IDirect3DDevice7 interface.\n", This
, Target
, Flags
);
1733 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1734 ICOM_INTERFACE(Target
, IDirectDrawSurface7
),
1738 static HRESULT WINAPI
1739 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2
*iface
,
1740 IDirectDrawSurface
*NewRenderTarget
,
1743 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1744 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface3
, NewRenderTarget
);
1745 TRACE_(ddraw_thunk
)("(%p)->(%p,%08x) thunking to IDirect3DDevice7 interface.\n", This
, Target
, Flags
);
1746 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1747 ICOM_INTERFACE(Target
, IDirectDrawSurface7
),
1751 /*****************************************************************************
1752 * IDirect3DDevice7::GetRenderTarget
1754 * Returns the current render target.
1755 * This is handled locally, because the WineD3D render target's parent
1758 * Version 2, 3 and 7
1761 * RenderTarget: Address to store the surface interface pointer
1765 * DDERR_INVALIDPARAMS if RenderTarget == NULL
1767 *****************************************************************************/
1768 static HRESULT WINAPI
1769 IDirect3DDeviceImpl_7_GetRenderTarget(IDirect3DDevice7
*iface
,
1770 IDirectDrawSurface7
**RenderTarget
)
1772 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1773 TRACE("(%p)->(%p): Relay\n", This
, RenderTarget
);
1776 return DDERR_INVALIDPARAMS
;
1778 *RenderTarget
= ICOM_INTERFACE(This
->target
, IDirectDrawSurface7
);
1779 IDirectDrawSurface7_AddRef(*RenderTarget
);
1784 static HRESULT WINAPI
1785 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3
*iface
,
1786 IDirectDrawSurface4
**RenderTarget
)
1788 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1790 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, RenderTarget
);
1791 hr
= IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1792 (IDirectDrawSurface7
**) RenderTarget
);
1793 if(hr
!= D3D_OK
) return hr
;
1794 *RenderTarget
= (IDirectDrawSurface4
*) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirectDrawSurface7
, RenderTarget
);
1798 static HRESULT WINAPI
1799 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(IDirect3DDevice2
*iface
,
1800 IDirectDrawSurface
**RenderTarget
)
1802 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1804 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, RenderTarget
);
1805 hr
= IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1806 (IDirectDrawSurface7
**) RenderTarget
);
1807 if(hr
!= D3D_OK
) return hr
;
1808 *RenderTarget
= (IDirectDrawSurface
*) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirectDrawSurface3
, RenderTarget
);
1812 /*****************************************************************************
1813 * IDirect3DDevice3::Begin
1815 * Begins a description block of vertices. This is similar to glBegin()
1816 * and glEnd(). After a call to IDirect3DDevice3::End, the vertices
1817 * described with IDirect3DDevice::Vertex are drawn.
1822 * PrimitiveType: The type of primitives to draw
1823 * VertexTypeDesc: A flexible vertex format description of the vertices
1824 * Flags: Some flags..
1829 *****************************************************************************/
1830 static HRESULT WINAPI
1831 IDirect3DDeviceImpl_3_Begin(IDirect3DDevice3
*iface
,
1832 D3DPRIMITIVETYPE PrimitiveType
,
1833 DWORD VertexTypeDesc
,
1836 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1837 TRACE("(%p)->(%d,%d,%08x)\n", This
, PrimitiveType
, VertexTypeDesc
, Flags
);
1839 This
->primitive_type
= PrimitiveType
;
1840 This
->vertex_type
= VertexTypeDesc
;
1841 This
->render_flags
= Flags
;
1842 This
->vertex_size
= get_flexible_vertex_size(This
->vertex_type
);
1843 This
->nb_vertices
= 0;
1848 static HRESULT WINAPI
1849 Thunk_IDirect3DDeviceImpl_2_Begin(IDirect3DDevice2
*iface
,
1850 D3DPRIMITIVETYPE d3dpt
,
1851 D3DVERTEXTYPE dwVertexTypeDesc
,
1855 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1856 TRACE_(ddraw_thunk
)("(%p/%p)->(%08x,%08x,%08x): Thunking to IDirect3DDevice3\n", This
, iface
, d3dpt
, dwVertexTypeDesc
, dwFlags
);
1858 switch(dwVertexTypeDesc
)
1860 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
1861 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
1862 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
1864 ERR("Unexpected vertex type %d\n", dwVertexTypeDesc
);
1865 return DDERR_INVALIDPARAMS
; /* Should never happen */
1868 return IDirect3DDevice3_Begin(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1874 /*****************************************************************************
1875 * IDirect3DDevice3::BeginIndexed
1877 * Draws primitives based on vertices in a vertex array which are specified
1883 * PrimitiveType: Primitive type to draw
1884 * VertexType: A FVF description of the vertex format
1885 * Vertices: pointer to an array containing the vertices
1886 * NumVertices: The number of vertices in the vertex array
1887 * Flags: Some flags ...
1890 * D3D_OK, because it's a stub
1892 *****************************************************************************/
1893 static HRESULT WINAPI
1894 IDirect3DDeviceImpl_3_BeginIndexed(IDirect3DDevice3
*iface
,
1895 D3DPRIMITIVETYPE PrimitiveType
,
1901 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1902 FIXME("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This
, PrimitiveType
, VertexType
, Vertices
, NumVertices
, Flags
);
1907 static HRESULT WINAPI
1908 Thunk_IDirect3DDeviceImpl_2_BeginIndexed(IDirect3DDevice2
*iface
,
1909 D3DPRIMITIVETYPE d3dptPrimitiveType
,
1910 D3DVERTEXTYPE d3dvtVertexType
,
1912 DWORD dwNumVertices
,
1916 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1917 TRACE_(ddraw_thunk
)("(%p/%p)->(%08x,%08x,%p,%08x,%08x): Thunking to IDirect3DDevice3\n", This
, iface
, d3dptPrimitiveType
, d3dvtVertexType
, lpvVertices
, dwNumVertices
, dwFlags
);
1919 switch(d3dvtVertexType
)
1921 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
1922 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
1923 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
1925 ERR("Unexpected vertex type %d\n", d3dvtVertexType
);
1926 return DDERR_INVALIDPARAMS
; /* Should never happen */
1929 return IDirect3DDevice3_BeginIndexed(ICOM_INTERFACE(This
,IDirect3DDevice3
),
1937 /*****************************************************************************
1938 * IDirect3DDevice3::Vertex
1940 * Draws a vertex as described by IDirect3DDevice3::Begin. It places all
1941 * drawn vertices in a vertex buffer. If the buffer is too small, its
1942 * size is increased.
1947 * Vertex: Pointer to the vertex
1950 * D3D_OK, on success
1951 * DDERR_INVALIDPARAMS if Vertex is NULL
1953 *****************************************************************************/
1954 static HRESULT WINAPI
1955 IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3
*iface
,
1958 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1959 TRACE("(%p)->(%p)\n", This
, Vertex
);
1962 return DDERR_INVALIDPARAMS
;
1964 if ((This
->nb_vertices
+1)*This
->vertex_size
> This
->buffer_size
)
1967 This
->buffer_size
= This
->buffer_size
? This
->buffer_size
* 2 : This
->vertex_size
* 3;
1968 old_buffer
= This
->vertex_buffer
;
1969 This
->vertex_buffer
= HeapAlloc(GetProcessHeap(), 0, This
->buffer_size
);
1972 CopyMemory(This
->vertex_buffer
, old_buffer
, This
->nb_vertices
* This
->vertex_size
);
1973 HeapFree(GetProcessHeap(), 0, old_buffer
);
1977 CopyMemory(This
->vertex_buffer
+ This
->nb_vertices
++ * This
->vertex_size
, Vertex
, This
->vertex_size
);
1982 static HRESULT WINAPI
1983 Thunk_IDirect3DDeviceImpl_2_Vertex(IDirect3DDevice2
*iface
,
1986 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1987 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, lpVertexType
);
1988 return IDirect3DDevice3_Vertex(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1992 /*****************************************************************************
1993 * IDirect3DDevice3::Index
1995 * Specifies an index to a vertex to be drawn. The vertex array has to
1996 * be specified with BeginIndexed first.
1999 * VertexIndex: The index of the vertex to draw
2002 * D3D_OK because it's a stub
2004 *****************************************************************************/
2005 static HRESULT WINAPI
2006 IDirect3DDeviceImpl_3_Index(IDirect3DDevice3
*iface
,
2009 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2010 FIXME("(%p)->(%04x): stub!\n", This
, VertexIndex
);
2014 static HRESULT WINAPI
2015 Thunk_IDirect3DDeviceImpl_2_Index(IDirect3DDevice2
*iface
,
2018 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2019 TRACE_(ddraw_thunk
)("(%p)->(%04x) thunking to IDirect3DDevice3 interface.\n", This
, wVertexIndex
);
2020 return IDirect3DDevice3_Index(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2024 /*****************************************************************************
2025 * IDirect3DDevice3::End
2027 * Ends a draw begun with IDirect3DDevice3::Begin or
2028 * IDirect3DDevice::BeginIndexed. The vertices specified with
2029 * IDirect3DDevice::Vertex or IDirect3DDevice::Index are drawn using
2030 * the IDirect3DDevice7::DrawPrimitive method. So far only
2031 * non-indexed mode is supported
2036 * Flags: Some flags, as usual. Don't know which are defined
2039 * The return value of IDirect3DDevice7::DrawPrimitive
2041 *****************************************************************************/
2042 static HRESULT WINAPI
2043 IDirect3DDeviceImpl_3_End(IDirect3DDevice3
*iface
,
2046 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2047 TRACE("(%p)->(%08x)\n", This
, Flags
);
2049 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2050 This
->primitive_type
, This
->vertex_type
,
2051 This
->vertex_buffer
, This
->nb_vertices
,
2052 This
->render_flags
);
2055 static HRESULT WINAPI
2056 Thunk_IDirect3DDeviceImpl_2_End(IDirect3DDevice2
*iface
,
2059 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2060 TRACE_(ddraw_thunk
)("(%p)->(%08x) thunking to IDirect3DDevice3 interface.\n", This
, dwFlags
);
2061 return IDirect3DDevice3_End(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2065 /*****************************************************************************
2066 * IDirect3DDevice7::GetRenderState
2068 * Returns the value of a render state. The possible render states are
2069 * defined in include/d3dtypes.h
2071 * Version 2, 3 and 7
2074 * RenderStateType: Render state to return the current setting of
2075 * Value: Address to store the value at
2078 * D3D_OK on success, for details see IWineD3DDevice::GetRenderState
2079 * DDERR_INVALIDPARAMS if Value == NULL
2081 *****************************************************************************/
2082 static HRESULT WINAPI
2083 IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7
*iface
,
2084 D3DRENDERSTATETYPE RenderStateType
,
2087 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2088 TRACE("(%p)->(%08x,%p): Relay\n", This
, RenderStateType
, Value
);
2091 return DDERR_INVALIDPARAMS
;
2093 /* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
2095 return IWineD3DDevice_GetRenderState(This
->wineD3DDevice
,
2100 static HRESULT WINAPI
2101 Thunk_IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3
*iface
,
2102 D3DRENDERSTATETYPE dwRenderStateType
,
2103 DWORD
*lpdwRenderState
)
2105 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2106 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, dwRenderStateType
, lpdwRenderState
);
2107 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2112 static HRESULT WINAPI
2113 Thunk_IDirect3DDeviceImpl_2_GetRenderState(IDirect3DDevice2
*iface
,
2114 D3DRENDERSTATETYPE dwRenderStateType
,
2115 DWORD
*lpdwRenderState
)
2117 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2118 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, dwRenderStateType
, lpdwRenderState
);
2119 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2124 /*****************************************************************************
2125 * IDirect3DDevice7::SetRenderState
2127 * Sets a render state. The possible render states are defined in
2128 * include/d3dtypes.h
2130 * Version 2, 3 and 7
2133 * RenderStateType: State to set
2134 * Value: Value to assign to that state
2137 * D3D_OK on success,
2138 * for details see IWineD3DDevice::SetRenderState
2140 *****************************************************************************/
2141 static HRESULT WINAPI
2142 IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7
*iface
,
2143 D3DRENDERSTATETYPE RenderStateType
,
2146 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2147 TRACE("(%p)->(%08x,%d): Relay\n", This
, RenderStateType
, Value
);
2149 /* Some render states need special care */
2150 switch(RenderStateType
)
2152 case D3DRENDERSTATE_TEXTUREHANDLE
:
2156 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
2161 if(Value
> This
->numHandles
)
2163 FIXME("Specified handle %d out of range\n", Value
);
2164 return DDERR_INVALIDPARAMS
;
2166 if(This
->Handles
[Value
- 1].type
!= DDrawHandle_Texture
)
2168 FIXME("Handle %d isn't a texture handle\n", Value
);
2169 return DDERR_INVALIDPARAMS
;
2173 IDirectDrawSurfaceImpl
*surf
= (IDirectDrawSurfaceImpl
*) This
->Handles
[Value
- 1].ptr
;
2174 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
2176 (IWineD3DBaseTexture
*) surf
->wineD3DTexture
);
2180 case D3DRENDERSTATE_TEXTUREMAG
:
2182 WINED3DTEXTUREFILTERTYPE tex_mag
= WINED3DTEXF_NONE
;
2184 switch ((D3DTEXTUREFILTER
) Value
)
2186 case D3DFILTER_NEAREST
:
2187 tex_mag
= WINED3DTEXF_POINT
;
2189 case D3DFILTER_LINEAR
:
2190 tex_mag
= WINED3DTEXF_LINEAR
;
2193 ERR("Unhandled texture mag %d !\n",Value
);
2196 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
2197 0, WINED3DSAMP_MAGFILTER
,
2201 case D3DRENDERSTATE_TEXTUREMIN
:
2203 WINED3DTEXTUREFILTERTYPE tex_min
= WINED3DTEXF_NONE
;
2205 switch ((D3DTEXTUREFILTER
) Value
)
2207 case D3DFILTER_NEAREST
:
2208 tex_min
= WINED3DTEXF_POINT
;
2210 case D3DFILTER_LINEAR
:
2211 tex_min
= WINED3DTEXF_LINEAR
;
2214 ERR("Unhandled texture mag %d !\n",Value
);
2217 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
2218 0, WINED3DSAMP_MINFILTER
,
2222 case D3DRENDERSTATE_TEXTUREADDRESSU
:
2223 case D3DRENDERSTATE_TEXTUREADDRESSV
:
2224 case D3DRENDERSTATE_TEXTUREADDRESS
:
2226 WINED3DTEXTURESTAGESTATETYPE TexStageStateType
;
2228 if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESS
)
2230 TexStageStateType
= WINED3DTSS_ADDRESS
;
2232 else if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESSU
)
2234 TexStageStateType
= WINED3DTSS_ADDRESSU
;
2238 TexStageStateType
= WINED3DTSS_ADDRESSV
;
2241 return IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
,
2242 0, TexStageStateType
,
2246 case D3DRENDERSTATE_TEXTUREMAPBLEND
:
2248 /* Old texture combine setup style, superseded by texture stage states
2249 * in D3D7. It is safe for us to wrap it to texture stage states.
2251 switch ( (D3DTEXTUREBLEND
) Value
)
2253 case D3DTBLEND_MODULATE
:
2254 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_COLORARG1
, D3DTA_TEXTURE
);
2255 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_ALPHAARG1
, D3DTA_TEXTURE
);
2256 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_COLORARG2
, D3DTA_CURRENT
);
2257 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_COLOROP
, D3DTOP_MODULATE
);
2258 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_ALPHAOP
, D3DTOP_SELECTARG1
);
2261 case D3DTBLEND_MODULATEALPHA
:
2262 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_COLORARG1
, D3DTA_TEXTURE
);
2263 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_ALPHAARG1
, D3DTA_TEXTURE
);
2264 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_COLORARG2
, D3DTA_CURRENT
);
2265 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_ALPHAARG2
, D3DTA_CURRENT
);
2266 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_COLOROP
, D3DTOP_MODULATE
);
2267 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_ALPHAOP
, D3DTOP_MODULATE
);
2270 case D3DTBLEND_DECAL
:
2271 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_COLORARG1
, D3DTA_TEXTURE
);
2272 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_ALPHAARG1
, D3DTA_TEXTURE
);
2273 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_COLOROP
, D3DTOP_SELECTARG1
);
2274 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_ALPHAOP
, D3DTOP_SELECTARG1
);
2277 case D3DTBLEND_DECALALPHA
:
2278 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_COLORARG1
, D3DTA_TEXTURE
);
2279 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_ALPHAARG1
, D3DTA_TEXTURE
);
2280 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_ALPHAARG2
, D3DTA_CURRENT
);
2281 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_COLOROP
, D3DTOP_SELECTARG1
);
2282 IWineD3DDevice_SetTextureStageState(iface
, 0, D3DTSS_ALPHAOP
, D3DTOP_MODULATE
);
2286 ERR("Unhandled texture environment %d !\n",Value
);
2294 /* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
2296 return IWineD3DDevice_SetRenderState(This
->wineD3DDevice
,
2302 static HRESULT WINAPI
2303 Thunk_IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3
*iface
,
2304 D3DRENDERSTATETYPE RenderStateType
,
2307 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2308 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, RenderStateType
, Value
);
2309 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2314 static HRESULT WINAPI
2315 Thunk_IDirect3DDeviceImpl_2_SetRenderState(IDirect3DDevice2
*iface
,
2316 D3DRENDERSTATETYPE RenderStateType
,
2319 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2320 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, RenderStateType
, Value
);
2321 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2326 /*****************************************************************************
2327 * Direct3DDevice3::SetLightState
2329 * Sets a light state for Direct3DDevice3 and Direct3DDevice2. The
2330 * light states are forwarded to Direct3DDevice7 render states
2335 * LightStateType: The light state to change
2336 * Value: The value to assign to that light state
2340 * DDERR_INVALIDPARAMS if the parameters were incorrect
2341 * Also check IDirect3DDevice7::SetRenderState
2343 *****************************************************************************/
2344 static HRESULT WINAPI
2345 IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3
*iface
,
2346 D3DLIGHTSTATETYPE LightStateType
,
2349 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2351 TRACE("(%p)->(%08x,%08x)\n", This
, LightStateType
, Value
);
2353 if (!LightStateType
&& (LightStateType
> D3DLIGHTSTATE_COLORVERTEX
))
2355 TRACE("Unexpected Light State Type\n");
2356 return DDERR_INVALIDPARAMS
;
2359 if (LightStateType
== D3DLIGHTSTATE_MATERIAL
/* 1 */)
2361 IDirect3DMaterialImpl
*mat
;
2363 if(Value
== 0) mat
= NULL
;
2364 else if(Value
> This
->numHandles
)
2366 ERR("Material handle out of range(%d)\n", Value
);
2367 return DDERR_INVALIDPARAMS
;
2369 else if(This
->Handles
[Value
- 1].type
!= DDrawHandle_Material
)
2371 ERR("Invalid handle %d\n", Value
);
2372 return DDERR_INVALIDPARAMS
;
2376 mat
= (IDirect3DMaterialImpl
*) This
->Handles
[Value
- 1].ptr
;
2381 TRACE(" activating material %p.\n", mat
);
2386 FIXME(" D3DLIGHTSTATE_MATERIAL called with NULL material !!!\n");
2388 This
->material
= Value
;
2390 else if (LightStateType
== D3DLIGHTSTATE_COLORMODEL
/* 3 */)
2395 ERR("DDCOLOR_MONO should not happen!\n");
2398 /* We are already in this mode */
2399 TRACE("Setting color model to RGB (no-op).\n");
2402 ERR("Unknown color model!\n");
2403 return DDERR_INVALIDPARAMS
;
2408 D3DRENDERSTATETYPE rs
;
2409 switch (LightStateType
)
2411 case D3DLIGHTSTATE_AMBIENT
: /* 2 */
2412 rs
= D3DRENDERSTATE_AMBIENT
;
2414 case D3DLIGHTSTATE_FOGMODE
: /* 4 */
2415 rs
= D3DRENDERSTATE_FOGVERTEXMODE
;
2417 case D3DLIGHTSTATE_FOGSTART
: /* 5 */
2418 rs
= D3DRENDERSTATE_FOGSTART
;
2420 case D3DLIGHTSTATE_FOGEND
: /* 6 */
2421 rs
= D3DRENDERSTATE_FOGEND
;
2423 case D3DLIGHTSTATE_FOGDENSITY
: /* 7 */
2424 rs
= D3DRENDERSTATE_FOGDENSITY
;
2426 case D3DLIGHTSTATE_COLORVERTEX
: /* 8 */
2427 rs
= D3DRENDERSTATE_COLORVERTEX
;
2430 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType
);
2431 return DDERR_INVALIDPARAMS
;
2434 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2442 static HRESULT WINAPI
2443 Thunk_IDirect3DDeviceImpl_2_SetLightState(IDirect3DDevice2
*iface
,
2444 D3DLIGHTSTATETYPE LightStateType
,
2447 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2448 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x) thunking to IDirect3DDevice3 interface.\n", This
, LightStateType
, Value
);
2449 return IDirect3DDevice3_SetLightState(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2454 /*****************************************************************************
2455 * IDirect3DDevice3::GetLightState
2457 * Returns the current setting of a light state. The state is read from
2458 * the Direct3DDevice7 render state.
2463 * LightStateType: The light state to return
2464 * Value: The address to store the light state setting at
2468 * DDDERR_INVALIDPARAMS if the parameters were incorrect
2469 * Also see IDirect3DDevice7::GetRenderState
2471 *****************************************************************************/
2472 static HRESULT WINAPI
2473 IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3
*iface
,
2474 D3DLIGHTSTATETYPE LightStateType
,
2477 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2479 TRACE("(%p)->(%08x,%p)\n", This
, LightStateType
, Value
);
2481 if (!LightStateType
&& (LightStateType
> D3DLIGHTSTATE_COLORVERTEX
))
2483 TRACE("Unexpected Light State Type\n");
2484 return DDERR_INVALIDPARAMS
;
2488 return DDERR_INVALIDPARAMS
;
2490 if (LightStateType
== D3DLIGHTSTATE_MATERIAL
/* 1 */)
2492 *Value
= This
->material
;
2494 else if (LightStateType
== D3DLIGHTSTATE_COLORMODEL
/* 3 */)
2496 *Value
= D3DCOLOR_RGB
;
2500 D3DRENDERSTATETYPE rs
;
2501 switch (LightStateType
)
2503 case D3DLIGHTSTATE_AMBIENT
: /* 2 */
2504 rs
= D3DRENDERSTATE_AMBIENT
;
2506 case D3DLIGHTSTATE_FOGMODE
: /* 4 */
2507 rs
= D3DRENDERSTATE_FOGVERTEXMODE
;
2509 case D3DLIGHTSTATE_FOGSTART
: /* 5 */
2510 rs
= D3DRENDERSTATE_FOGSTART
;
2512 case D3DLIGHTSTATE_FOGEND
: /* 6 */
2513 rs
= D3DRENDERSTATE_FOGEND
;
2515 case D3DLIGHTSTATE_FOGDENSITY
: /* 7 */
2516 rs
= D3DRENDERSTATE_FOGDENSITY
;
2518 case D3DLIGHTSTATE_COLORVERTEX
: /* 8 */
2519 rs
= D3DRENDERSTATE_COLORVERTEX
;
2522 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType
);
2523 return DDERR_INVALIDPARAMS
;
2526 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2534 static HRESULT WINAPI
2535 Thunk_IDirect3DDeviceImpl_2_GetLightState(IDirect3DDevice2
*iface
,
2536 D3DLIGHTSTATETYPE LightStateType
,
2539 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2540 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice3 interface.\n", This
, LightStateType
, Value
);
2541 return IDirect3DDevice3_GetLightState(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2546 /*****************************************************************************
2547 * IDirect3DDevice7::SetTransform
2549 * Assigns a D3DMATRIX to a transform type. The transform types are defined
2550 * in include/d3dtypes.h.
2551 * The D3DTRANSFORMSTATE_WORLD (=1) is translated to D3DTS_WORLDMATRIX(0)
2552 * (=255) for wined3d, because the 1 transform state was removed in d3d8
2553 * and WineD3D already understands the replacement D3DTS_WORLDMATRIX(0)
2555 * Version 2, 3 and 7
2558 * TransformStateType: transform state to set
2559 * Matrix: Matrix to assign to the state
2563 * DDERR_INVALIDPARAMS if Matrix == NULL
2564 * For details see IWineD3DDevice::SetTransform
2566 *****************************************************************************/
2567 static HRESULT WINAPI
2568 IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7
*iface
,
2569 D3DTRANSFORMSTATETYPE TransformStateType
,
2572 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2573 D3DTRANSFORMSTATETYPE type
= TransformStateType
;
2574 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, Matrix
);
2577 return DDERR_INVALIDPARAMS
;
2579 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2580 * use D3DTS_WORLDMATRIX(0) instead
2581 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2583 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2584 type
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2587 Unhandled: D3DTRANSFORMSTATE_WORLD1
2588 Unhandled: D3DTRANSFORMSTATE_WORLD2
2589 Unhandled: D3DTRANSFORMSTATE_WORLD3
2592 return IWineD3DDevice_SetTransform(This
->wineD3DDevice
,
2597 static HRESULT WINAPI
2598 Thunk_IDirect3DDeviceImpl_3_SetTransform(IDirect3DDevice3
*iface
,
2599 D3DTRANSFORMSTATETYPE TransformStateType
,
2600 D3DMATRIX
*D3DMatrix
)
2602 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2603 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2604 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2609 static HRESULT WINAPI
2610 Thunk_IDirect3DDeviceImpl_2_SetTransform(IDirect3DDevice2
*iface
,
2611 D3DTRANSFORMSTATETYPE TransformStateType
,
2612 D3DMATRIX
*D3DMatrix
)
2614 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2615 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2616 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2621 /*****************************************************************************
2622 * IDirect3DDevice7::GetTransform
2624 * Returns the matrix assigned to a transform state
2625 * D3DTRANSFORMSTATE_WORLD is translated to D3DTS_WORLDMATRIX(0), see
2629 * TransformStateType: State to read the matrix from
2630 * Matrix: Address to store the matrix at
2634 * DDERR_INVALIDPARAMS if Matrix == NULL
2635 * For details, see IWineD3DDevice::GetTransform
2637 *****************************************************************************/
2638 static HRESULT WINAPI
2639 IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7
*iface
,
2640 D3DTRANSFORMSTATETYPE TransformStateType
,
2643 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2644 D3DTRANSFORMSTATETYPE type
= TransformStateType
;
2645 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, Matrix
);
2648 return DDERR_INVALIDPARAMS
;
2650 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2651 * use D3DTS_WORLDMATRIX(0) instead
2652 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2654 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2655 type
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2658 Unhandled: D3DTRANSFORMSTATE_WORLD1
2659 Unhandled: D3DTRANSFORMSTATE_WORLD2
2660 Unhandled: D3DTRANSFORMSTATE_WORLD3
2663 return IWineD3DDevice_GetTransform(This
->wineD3DDevice
, type
, Matrix
);
2666 static HRESULT WINAPI
2667 Thunk_IDirect3DDeviceImpl_3_GetTransform(IDirect3DDevice3
*iface
,
2668 D3DTRANSFORMSTATETYPE TransformStateType
,
2669 D3DMATRIX
*D3DMatrix
)
2671 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2672 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2673 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2678 static HRESULT WINAPI
2679 Thunk_IDirect3DDeviceImpl_2_GetTransform(IDirect3DDevice2
*iface
,
2680 D3DTRANSFORMSTATETYPE TransformStateType
,
2681 D3DMATRIX
*D3DMatrix
)
2683 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2684 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2685 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2690 /*****************************************************************************
2691 * IDirect3DDevice7::MultiplyTransform
2693 * Multiplies the already-set transform matrix of a transform state
2694 * with another matrix. For the world matrix, see SetTransform
2696 * Version 2, 3 and 7
2699 * TransformStateType: Transform state to multiply
2700 * D3DMatrix Matrix to multiply with.
2704 * DDERR_INVALIDPARAMS if D3DMatrix is NULL
2705 * For details, see IWineD3DDevice::MultiplyTransform
2707 *****************************************************************************/
2708 static HRESULT WINAPI
2709 IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7
*iface
,
2710 D3DTRANSFORMSTATETYPE TransformStateType
,
2711 D3DMATRIX
*D3DMatrix
)
2713 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2714 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, D3DMatrix
);
2716 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2717 * use D3DTS_WORLDMATRIX(0) instead
2718 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2720 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2721 TransformStateType
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2724 Unhandled: D3DTRANSFORMSTATE_WORLD1
2725 Unhandled: D3DTRANSFORMSTATE_WORLD2
2726 Unhandled: D3DTRANSFORMSTATE_WORLD3
2729 return IWineD3DDevice_MultiplyTransform(This
->wineD3DDevice
,
2734 static HRESULT WINAPI
2735 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(IDirect3DDevice3
*iface
,
2736 D3DTRANSFORMSTATETYPE TransformStateType
,
2737 D3DMATRIX
*D3DMatrix
)
2739 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2740 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2741 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2746 static HRESULT WINAPI
2747 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform(IDirect3DDevice2
*iface
,
2748 D3DTRANSFORMSTATETYPE TransformStateType
,
2749 D3DMATRIX
*D3DMatrix
)
2751 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2752 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2753 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2758 /*****************************************************************************
2759 * IDirect3DDevice7::DrawPrimitive
2761 * Draws primitives based on vertices in an application-provided pointer
2763 * Version 2, 3 and 7. The IDirect3DDevice2 thunk converts the fixed vertex type into
2764 * an FVF format for D3D7
2767 * PrimitiveType: The type of the primitives to draw
2768 * Vertex type: Flexible vertex format vertex description
2769 * Vertices: Pointer to the vertex array
2770 * VertexCount: The number of vertices to draw
2771 * Flags: As usual a few flags
2775 * DDERR_INVALIDPARAMS if Vertices is NULL
2776 * For details, see IWineD3DDevice::DrawPrimitiveUP
2778 *****************************************************************************/
2779 static HRESULT WINAPI
2780 IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7
*iface
,
2781 D3DPRIMITIVETYPE PrimitiveType
,
2787 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2788 UINT PrimitiveCount
, stride
;
2790 TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): Relay!\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2793 return DDERR_INVALIDPARAMS
;
2795 /* Get the vertex count */
2796 switch(PrimitiveType
)
2798 case D3DPT_POINTLIST
:
2799 PrimitiveCount
= VertexCount
;
2802 case D3DPT_LINELIST
:
2803 PrimitiveCount
= VertexCount
/ 2;
2806 case D3DPT_LINESTRIP
:
2807 PrimitiveCount
= VertexCount
- 1;
2810 case D3DPT_TRIANGLELIST
:
2811 PrimitiveCount
= VertexCount
/ 3;
2814 case D3DPT_TRIANGLESTRIP
:
2815 PrimitiveCount
= VertexCount
- 2;
2818 case D3DPT_TRIANGLEFAN
:
2819 PrimitiveCount
= VertexCount
- 2;
2822 default: return DDERR_INVALIDPARAMS
;
2825 /* Get the stride */
2826 stride
= get_flexible_vertex_size(VertexType
);
2829 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, VertexType
);
2830 if(hr
!= D3D_OK
) return hr
;
2832 /* This method translates to the user pointer draw of WineD3D */
2833 return IWineD3DDevice_DrawPrimitiveUP(This
->wineD3DDevice
,
2840 static HRESULT WINAPI
2841 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(IDirect3DDevice3
*iface
,
2842 D3DPRIMITIVETYPE PrimitiveType
,
2848 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2849 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2850 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2858 static HRESULT WINAPI
2859 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive(IDirect3DDevice2
*iface
,
2860 D3DPRIMITIVETYPE PrimitiveType
,
2861 D3DVERTEXTYPE VertexType
,
2866 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2868 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2872 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
2873 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
2874 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
2876 ERR("Unexpected vertex type %d\n", VertexType
);
2877 return DDERR_INVALIDPARAMS
; /* Should never happen */
2880 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2888 /*****************************************************************************
2889 * IDirect3DDevice7::DrawIndexedPrimitive
2891 * Draws vertices from an application-provided pointer, based on the index
2892 * numbers in a WORD array.
2894 * Version 2, 3 and 7. The version 7 thunk translates the vertex type into
2895 * an FVF format for D3D7
2898 * PrimitiveType: The primitive type to draw
2899 * VertexType: The FVF vertex description
2900 * Vertices: Pointer to the vertex array
2902 * Indices: Pointer to the index array
2903 * IndexCount: Number of indices = Number of vertices to draw
2904 * Flags: As usual, some flags
2908 * DDERR_INVALIDPARAMS if Vertices or Indices is NULL
2909 * For details, see IWineD3DDevice::DrawIndexedPrimitiveUP
2911 *****************************************************************************/
2912 static HRESULT WINAPI
2913 IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7
*iface
,
2914 D3DPRIMITIVETYPE PrimitiveType
,
2922 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2923 UINT PrimitiveCount
= 0;
2925 TRACE("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): Relay!\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
2926 /* Get the primitive number */
2927 switch(PrimitiveType
)
2929 case D3DPT_POINTLIST
:
2930 PrimitiveCount
= IndexCount
;
2933 case D3DPT_LINELIST
:
2934 PrimitiveCount
= IndexCount
/ 2;
2937 case D3DPT_LINESTRIP
:
2938 PrimitiveCount
= IndexCount
- 1;
2941 case D3DPT_TRIANGLELIST
:
2942 PrimitiveCount
= IndexCount
/ 3;
2945 case D3DPT_TRIANGLESTRIP
:
2946 PrimitiveCount
= IndexCount
- 2;
2949 case D3DPT_TRIANGLEFAN
:
2950 PrimitiveCount
= IndexCount
- 2;
2953 default: return DDERR_INVALIDPARAMS
;
2956 /* Set the D3DDevice's FVF */
2957 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, VertexType
);
2960 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This
, hr
);
2964 return IWineD3DDevice_DrawIndexedPrimitiveUP(This
->wineD3DDevice
,
2966 0 /* MinVertexIndex */,
2967 VertexCount
/* UINT NumVertexIndex */,
2972 get_flexible_vertex_size(VertexType
));
2975 static HRESULT WINAPI
2976 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(IDirect3DDevice3
*iface
,
2977 D3DPRIMITIVETYPE PrimitiveType
,
2985 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2986 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
2987 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2997 static HRESULT WINAPI
2998 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(IDirect3DDevice2
*iface
,
2999 D3DPRIMITIVETYPE PrimitiveType
,
3000 D3DVERTEXTYPE VertexType
,
3008 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3009 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
3013 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
3014 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
3015 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
3017 ERR("Unexpected vertex type %d\n", VertexType
);
3018 return DDERR_INVALIDPARAMS
; /* Should never happen */
3021 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3031 /*****************************************************************************
3032 * IDirect3DDevice7::SetClipStatus
3034 * Sets the clip status. This defines things as clipping conditions and
3035 * the extents of the clipping region.
3037 * Version 2, 3 and 7
3043 * D3D_OK because it's a stub
3044 * (DDERR_INVALIDPARAMS if ClipStatus == NULL)
3046 *****************************************************************************/
3047 static HRESULT WINAPI
3048 IDirect3DDeviceImpl_7_SetClipStatus(IDirect3DDevice7
*iface
,
3049 D3DCLIPSTATUS
*ClipStatus
)
3051 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3052 FIXME("(%p)->(%p): Stub!\n", This
, ClipStatus
);
3054 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them
3055 * Perhaps this needs a new data type and an additional IWineD3DDevice method
3057 /* return IWineD3DDevice_SetClipStatus(This->wineD3DDevice, ClipStatus);*/
3061 static HRESULT WINAPI
3062 Thunk_IDirect3DDeviceImpl_3_SetClipStatus(IDirect3DDevice3
*iface
,
3063 D3DCLIPSTATUS
*ClipStatus
)
3065 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3066 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3067 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3071 static HRESULT WINAPI
3072 Thunk_IDirect3DDeviceImpl_2_SetClipStatus(IDirect3DDevice2
*iface
,
3073 D3DCLIPSTATUS
*ClipStatus
)
3075 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3076 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3077 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3081 /*****************************************************************************
3082 * IDirect3DDevice7::GetClipStatus
3084 * Returns the clip status
3087 * ClipStatus: Address to write the clip status to
3090 * D3D_OK because it's a stub
3092 *****************************************************************************/
3093 static HRESULT WINAPI
3094 IDirect3DDeviceImpl_7_GetClipStatus(IDirect3DDevice7
*iface
,
3095 D3DCLIPSTATUS
*ClipStatus
)
3097 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3098 FIXME("(%p)->(%p): Stub!\n", This
, ClipStatus
);
3100 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them */
3101 /* return IWineD3DDevice_GetClipStatus(This->wineD3DDevice, ClipStatus);*/
3105 static HRESULT WINAPI
3106 Thunk_IDirect3DDeviceImpl_3_GetClipStatus(IDirect3DDevice3
*iface
,
3107 D3DCLIPSTATUS
*ClipStatus
)
3109 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3110 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3111 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3115 static HRESULT WINAPI
3116 Thunk_IDirect3DDeviceImpl_2_GetClipStatus(IDirect3DDevice2
*iface
,
3117 D3DCLIPSTATUS
*ClipStatus
)
3119 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3120 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3121 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3125 /*****************************************************************************
3126 * IDirect3DDevice::DrawPrimitiveStrided
3128 * Draws vertices described by a D3DDRAWPRIMITIVESTRIDEDDATA structure.
3133 * PrimitiveType: The primitive type to draw
3134 * VertexType: The FVF description of the vertices to draw (for the stride??)
3135 * D3DDrawPrimStrideData: A D3DDRAWPRIMITIVESTRIDEDDATA structure describing
3136 * the vertex data locations
3137 * VertexCount: The number of vertices to draw
3141 * D3D_OK, because it's a stub
3142 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3143 * (For details, see IWineD3DDevice::DrawPrimitiveStrided)
3145 *****************************************************************************/
3146 static HRESULT WINAPI
3147 IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7
*iface
,
3148 D3DPRIMITIVETYPE PrimitiveType
,
3150 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3154 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3155 WineDirect3DVertexStridedData WineD3DStrided
;
3157 UINT PrimitiveCount
;
3159 TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Flags
);
3161 /* Get the strided data right. the wined3d structure is a bit bigger
3162 * Watch out: The contents of the strided data are determined by the fvf,
3163 * not by the members set in D3DDrawPrimStrideData. So it's valid
3164 * to have diffuse.lpvData set to 0xdeadbeef if the diffuse flag is
3165 * not set in the fvf.
3167 if(VertexType
& D3DFVF_POSITION_MASK
)
3169 memset(&WineD3DStrided
, 0, sizeof(WineD3DStrided
));
3170 WineD3DStrided
.u
.s
.position
.lpData
= D3DDrawPrimStrideData
->position
.lpvData
;
3171 WineD3DStrided
.u
.s
.position
.dwStride
= D3DDrawPrimStrideData
->position
.dwStride
;
3172 WineD3DStrided
.u
.s
.position
.dwType
= WINED3DDECLTYPE_FLOAT3
;
3173 if (VertexType
& D3DFVF_XYZRHW
)
3175 WineD3DStrided
.u
.s
.position
.dwType
= WINED3DDECLTYPE_FLOAT4
;
3176 WineD3DStrided
.u
.s
.position_transformed
= TRUE
;
3178 WineD3DStrided
.u
.s
.position_transformed
= FALSE
;
3181 if(VertexType
& D3DFVF_NORMAL
)
3183 WineD3DStrided
.u
.s
.normal
.lpData
= D3DDrawPrimStrideData
->normal
.lpvData
;
3184 WineD3DStrided
.u
.s
.normal
.dwStride
= D3DDrawPrimStrideData
->normal
.dwStride
;
3185 WineD3DStrided
.u
.s
.normal
.dwType
= WINED3DDECLTYPE_FLOAT3
;
3188 if(VertexType
& D3DFVF_DIFFUSE
)
3190 WineD3DStrided
.u
.s
.diffuse
.lpData
= D3DDrawPrimStrideData
->diffuse
.lpvData
;
3191 WineD3DStrided
.u
.s
.diffuse
.dwStride
= D3DDrawPrimStrideData
->diffuse
.dwStride
;
3192 WineD3DStrided
.u
.s
.diffuse
.dwType
= WINED3DDECLTYPE_SHORT4
;
3195 if(VertexType
& D3DFVF_SPECULAR
)
3197 WineD3DStrided
.u
.s
.specular
.lpData
= D3DDrawPrimStrideData
->specular
.lpvData
;
3198 WineD3DStrided
.u
.s
.specular
.dwStride
= D3DDrawPrimStrideData
->specular
.dwStride
;
3199 WineD3DStrided
.u
.s
.specular
.dwType
= WINED3DDECLTYPE_SHORT4
;
3202 for( i
= 0; i
< GET_TEXCOUNT_FROM_FVF(VertexType
); i
++)
3204 WineD3DStrided
.u
.s
.texCoords
[i
].lpData
= D3DDrawPrimStrideData
->textureCoords
[i
].lpvData
;
3205 WineD3DStrided
.u
.s
.texCoords
[i
].dwStride
= D3DDrawPrimStrideData
->textureCoords
[i
].dwStride
;
3206 switch(GET_TEXCOORD_SIZE_FROM_FVF(VertexType
, i
))
3208 case 1: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT1
; break;
3209 case 2: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT2
; break;
3210 case 3: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT3
; break;
3211 case 4: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT4
; break;
3212 default: ERR("Unexpected texture coordinate size %d\n",
3213 GET_TEXCOORD_SIZE_FROM_FVF(VertexType
, i
));
3217 /* Get the primitive count */
3218 switch(PrimitiveType
)
3220 case D3DPT_POINTLIST
:
3221 PrimitiveCount
= VertexCount
;
3224 case D3DPT_LINELIST
:
3225 PrimitiveCount
= VertexCount
/ 2;
3228 case D3DPT_LINESTRIP
:
3229 PrimitiveCount
= VertexCount
- 1;
3232 case D3DPT_TRIANGLELIST
:
3233 PrimitiveCount
= VertexCount
/ 3;
3236 case D3DPT_TRIANGLESTRIP
:
3237 PrimitiveCount
= VertexCount
- 2;
3240 case D3DPT_TRIANGLEFAN
:
3241 PrimitiveCount
= VertexCount
- 2;
3244 default: return DDERR_INVALIDPARAMS
;
3247 IWineD3DDevice_SetFVF(This
->wineD3DDevice
,
3250 return IWineD3DDevice_DrawPrimitiveStrided(This
->wineD3DDevice
,
3256 static HRESULT WINAPI
3257 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided(IDirect3DDevice3
*iface
,
3258 D3DPRIMITIVETYPE PrimitiveType
,
3260 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3264 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3265 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Flags
);
3266 return IDirect3DDevice7_DrawPrimitiveStrided(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3269 D3DDrawPrimStrideData
,
3274 /*****************************************************************************
3275 * IDirect3DDevice7::DrawIndexedPrimitiveStrided
3277 * Draws primitives specified by strided data locations based on indices
3285 * D3D_OK, because it's a stub
3286 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3287 * (DDERR_INVALIDPARAMS if Indices is NULL)
3288 * (For more details, see IWineD3DDevice::DrawIndexedPrimitiveStrided)
3290 *****************************************************************************/
3291 static HRESULT WINAPI
3292 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7
*iface
,
3293 D3DPRIMITIVETYPE PrimitiveType
,
3295 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3301 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3302 FIXME("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): stub!\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Indices
, IndexCount
, Flags
);
3304 /* I'll implement it as soon as I find a app to test it.
3305 * This needs an additional method in IWineD3DDevice.
3310 static HRESULT WINAPI
3311 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(IDirect3DDevice3
*iface
,
3312 D3DPRIMITIVETYPE PrimitiveType
,
3314 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3320 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3321 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", iface
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Indices
, IndexCount
, Flags
);
3322 return IDirect3DDevice7_DrawIndexedPrimitiveStrided(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3325 D3DDrawPrimStrideData
,
3332 /*****************************************************************************
3333 * IDirect3DDevice7::DrawPrimitiveVB
3335 * Draws primitives from a vertex buffer to the screen.
3340 * PrimitiveType: Type of primitive to be rendered.
3341 * D3DVertexBuf: Source Vertex Buffer
3342 * StartVertex: Index of the first vertex from the buffer to be rendered
3343 * NumVertices: Number of vertices to be rendered
3344 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3348 * DDERR_INVALIDPARAMS if D3DVertexBuf is NULL
3350 *****************************************************************************/
3351 static HRESULT WINAPI
3352 IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7
*iface
,
3353 D3DPRIMITIVETYPE PrimitiveType
,
3354 IDirect3DVertexBuffer7
*D3DVertexBuf
,
3359 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3360 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer7
, D3DVertexBuf
);
3361 UINT PrimitiveCount
;
3364 WINED3DVERTEXBUFFER_DESC Desc
;
3366 TRACE("(%p)->(%08x,%p,%08x,%08x,%08x)\n", This
, PrimitiveType
, D3DVertexBuf
, StartVertex
, NumVertices
, Flags
);
3371 ERR("(%p) No Vertex buffer specified\n", This
);
3372 return DDERR_INVALIDPARAMS
;
3375 /* Get the primitive count */
3376 switch(PrimitiveType
)
3378 case D3DPT_POINTLIST
:
3379 PrimitiveCount
= NumVertices
;
3382 case D3DPT_LINELIST
:
3383 PrimitiveCount
= NumVertices
/ 2;
3386 case D3DPT_LINESTRIP
:
3387 PrimitiveCount
= NumVertices
- 1;
3390 case D3DPT_TRIANGLELIST
:
3391 PrimitiveCount
= NumVertices
/ 3;
3394 case D3DPT_TRIANGLESTRIP
:
3395 PrimitiveCount
= NumVertices
- 2;
3398 case D3DPT_TRIANGLEFAN
:
3399 PrimitiveCount
= NumVertices
- 2;
3402 default: return DDERR_INVALIDPARAMS
;
3405 /* Get the FVF of the vertex buffer, and its stride */
3406 hr
= IWineD3DVertexBuffer_GetDesc(vb
->wineD3DVertexBuffer
,
3410 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x\n", This
, hr
);
3413 stride
= get_flexible_vertex_size(Desc
.FVF
);
3415 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, Desc
.FVF
);
3418 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This
, hr
);
3422 /* Set the vertex stream source */
3423 hr
= IWineD3DDevice_SetStreamSource(This
->wineD3DDevice
,
3424 0 /* StreamNumber */,
3425 vb
->wineD3DVertexBuffer
,
3426 0 /* StartVertex - we pass this to DrawPrimitive */,
3430 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This
, hr
);
3434 /* Now draw the primitives */
3435 return IWineD3DDevice_DrawPrimitive(This
->wineD3DDevice
,
3441 static HRESULT WINAPI
3442 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3
*iface
,
3443 D3DPRIMITIVETYPE PrimitiveType
,
3444 IDirect3DVertexBuffer
*D3DVertexBuf
,
3449 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3450 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer
, D3DVertexBuf
);
3451 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p,%08x,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, vb
, StartVertex
, NumVertices
, Flags
);
3452 return IDirect3DDevice7_DrawPrimitiveVB(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3454 ICOM_INTERFACE(vb
, IDirect3DVertexBuffer7
),
3461 /*****************************************************************************
3462 * IDirect3DDevice7::DrawIndexedPrimitiveVB
3464 * Draws primitives from a vertex buffer to the screen
3467 * PrimitiveType: Type of primitive to be rendered.
3468 * D3DVertexBuf: Source Vertex Buffer
3469 * StartVertex: Index of the first vertex from the buffer to be rendered
3470 * NumVertices: Number of vertices to be rendered
3471 * Indices: Array of DWORDs used to index into the Vertices
3472 * IndexCount: Number of indices in Indices
3473 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3477 *****************************************************************************/
3478 static HRESULT WINAPI
3479 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7
*iface
,
3480 D3DPRIMITIVETYPE PrimitiveType
,
3481 IDirect3DVertexBuffer7
*D3DVertexBuf
,
3488 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3489 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer7
, D3DVertexBuf
);
3491 UINT PrimitiveCount
;
3492 WORD
*LockedIndices
;
3494 WINED3DVERTEXBUFFER_DESC Desc
;
3496 TRACE("(%p)->(%08x,%p,%d,%d,%p,%d,%08x)\n", This
, PrimitiveType
, vb
, StartVertex
, NumVertices
, Indices
, IndexCount
, Flags
);
3499 * 1) Calculate some things: Vertex count -> Primitive count, stride, ...
3500 * 2) Upload the Indices to the index buffer
3501 * 3) Set the index source
3502 * 4) Set the Vertex Buffer as the Stream source
3503 * 5) Call IWineD3DDevice::DrawIndexedPrimitive
3506 /* Get the primitive count */
3507 switch(PrimitiveType
)
3509 case D3DPT_POINTLIST
:
3510 PrimitiveCount
= IndexCount
;
3513 case D3DPT_LINELIST
:
3514 PrimitiveCount
= IndexCount
/ 2;
3517 case D3DPT_LINESTRIP
:
3518 PrimitiveCount
= IndexCount
- 1;
3521 case D3DPT_TRIANGLELIST
:
3522 PrimitiveCount
= IndexCount
/ 3;
3525 case D3DPT_TRIANGLESTRIP
:
3526 PrimitiveCount
= IndexCount
- 2;
3529 case D3DPT_TRIANGLEFAN
:
3530 PrimitiveCount
= IndexCount
- 2;
3533 default: return DDERR_INVALIDPARAMS
;
3536 /* Get the FVF of the vertex buffer, and its stride */
3537 hr
= IWineD3DVertexBuffer_GetDesc(vb
->wineD3DVertexBuffer
,
3541 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x\n", This
, hr
);
3544 stride
= get_flexible_vertex_size(Desc
.FVF
);
3545 TRACE("Vertex buffer FVF = %08x, stride=%d\n", Desc
.FVF
, stride
);
3547 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, Desc
.FVF
);
3550 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This
, hr
);
3554 /* copy the index stream into the index buffer.
3555 * A new IWineD3DDevice method could be created
3556 * which takes an user pointer containing the indices
3557 * or a SetData-Method for the index buffer, which
3558 * overrides the index buffer data with our pointer.
3560 hr
= IWineD3DIndexBuffer_Lock(This
->indexbuffer
,
3561 0 /* OffSetToLock */,
3562 0 /* SizeToLock - doesn't matter */,
3563 (BYTE
**) &LockedIndices
,
3565 assert(IndexCount
< 0x100000);
3568 ERR("(%p) IWineD3DIndexBuffer::Lock failed with hr = %08x\n", This
, hr
);
3571 memcpy(LockedIndices
, Indices
, IndexCount
* sizeof(WORD
));
3572 hr
= IWineD3DIndexBuffer_Unlock(This
->indexbuffer
);
3575 ERR("(%p) IWineD3DIndexBuffer::Unlock failed with hr = %08x\n", This
, hr
);
3579 /* Set the index stream */
3580 hr
= IWineD3DDevice_SetIndices(This
->wineD3DDevice
,
3584 /* Set the vertex stream source */
3585 hr
= IWineD3DDevice_SetStreamSource(This
->wineD3DDevice
,
3586 0 /* StreamNumber */,
3587 vb
->wineD3DVertexBuffer
,
3588 0 /* offset, we pass this to DrawIndexedPrimitive */,
3592 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This
, hr
);
3597 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->wineD3DDevice
,
3608 static HRESULT WINAPI
3609 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevice3
*iface
,
3610 D3DPRIMITIVETYPE PrimitiveType
,
3611 IDirect3DVertexBuffer
*D3DVertexBuf
,
3616 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3617 IDirect3DVertexBufferImpl
*VB
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer
, D3DVertexBuf
);
3618 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VB
, Indices
, IndexCount
, Flags
);
3620 return IDirect3DDevice7_DrawIndexedPrimitiveVB(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3622 ICOM_INTERFACE(VB
, IDirect3DVertexBuffer7
),
3630 /*****************************************************************************
3631 * IDirect3DDevice7::ComputeSphereVisibility
3633 * Calculates the visibility of spheres in the current viewport. The spheres
3634 * are passed in the Centers and Radii arrays, the results are passed back
3635 * in the ReturnValues array. Return values are either completely visible,
3636 * partially visible or completely invisible.
3637 * The return value consist of a combination of D3DCLIP_* flags, or it's
3638 * 0 if the sphere is completely visible(according to the SDK, not checked)
3640 * Sounds like an overdose of math ;)
3645 * Centers: Array containing the sphere centers
3646 * Radii: Array containing the sphere radii
3647 * NumSpheres: The number of centers and radii in the arrays
3649 * ReturnValues: Array to write the results to
3652 * D3D_OK because it's a stub
3653 * (DDERR_INVALIDPARAMS if Centers, Radii or ReturnValues are NULL)
3654 * (D3DERR_INVALIDMATRIX if the combined world, view and proj matrix
3657 *****************************************************************************/
3658 static HRESULT WINAPI
3659 IDirect3DDeviceImpl_7_ComputeSphereVisibility(IDirect3DDevice7
*iface
,
3664 DWORD
*ReturnValues
)
3666 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3667 FIXME("(%p)->(%p,%p,%08x,%08x,%p): stub!\n", This
, Centers
, Radii
, NumSpheres
, Flags
, ReturnValues
);
3669 /* the DirectX 7 sdk says that the visibility is computed by
3670 * back-transforming the viewing frustum to model space
3671 * using the inverse of the combined world, view and projection
3672 * matrix. If the matrix can't be reversed, D3DERR_INVALIDMATRIX
3675 * Basic implementation idea:
3676 * 1) Check if the center is in the viewing frustum
3677 * 2) Cut the sphere with the planes of the viewing
3680 * ->Center inside the frustum, no intersections:
3682 * ->Center outside the frustum, no intersections:
3684 * ->Some intersections: Partially visible
3686 * Implement this call in WineD3D. Either implement the
3687 * matrix and vector stuff in WineD3D, or use some external
3694 static HRESULT WINAPI
3695 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility(IDirect3DDevice3
*iface
,
3700 DWORD
*ReturnValues
)
3702 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3703 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08x,%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, Centers
, Radii
, NumSpheres
, Flags
, ReturnValues
);
3704 return IDirect3DDevice7_ComputeSphereVisibility(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3712 /*****************************************************************************
3713 * IDirect3DDevice7::GetTexture
3715 * Returns the texture interface handle assigned to a texture stage.
3716 * The returned texture is AddRefed. This is taken from old ddraw,
3717 * not checked in Windows.
3722 * Stage: Texture stage to read the texture from
3723 * Texture: Address to store the interface pointer at
3727 * DDERR_INVALIDPARAMS if Texture is NULL
3728 * For details, see IWineD3DDevice::GetTexture
3730 *****************************************************************************/
3731 static HRESULT WINAPI
3732 IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7
*iface
,
3734 IDirectDrawSurface7
**Texture
)
3736 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3737 IWineD3DBaseTexture
*Surf
;
3739 TRACE("(%p)->(%d,%p): Relay\n", This
, Stage
, Texture
);
3743 TRACE("Texture == NULL, failing with DDERR_INVALIDPARAMS\n");
3744 return DDERR_INVALIDPARAMS
;
3747 hr
= IWineD3DDevice_GetTexture(This
->wineD3DDevice
, Stage
, (IWineD3DBaseTexture
**) &Surf
);
3748 if( (hr
!= D3D_OK
) || (!Surf
) )
3754 /* GetParent AddRef()s, which is perfectly OK.
3755 * We have passed the IDirectDrawSurface7 interface to WineD3D, so that's OK too.
3757 return IWineD3DBaseTexture_GetParent(Surf
,
3758 (IUnknown
**) Texture
);
3761 static HRESULT WINAPI
3762 Thunk_IDirect3DDeviceImpl_3_GetTexture(IDirect3DDevice3
*iface
,
3764 IDirect3DTexture2
**Texture2
)
3766 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3768 IDirectDrawSurface7
*ret_val
;
3770 TRACE_(ddraw_thunk
)("(%p)->(%d,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, Texture2
);
3771 ret
= IDirect3DDevice7_GetTexture(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3775 *Texture2
= COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirect3DTexture2
, ret_val
);
3777 TRACE_(ddraw_thunk
)(" returning interface %p.\n", *Texture2
);
3782 /*****************************************************************************
3783 * IDirect3DDevice7::SetTexture
3785 * Assigns a texture to a texture stage. Is the texture AddRef-ed?
3790 * Stage: The stage to assign the texture to
3791 * Texture: Interface pointer to the texture surface
3795 * For details, see IWineD3DDevice::SetTexture
3797 *****************************************************************************/
3798 static HRESULT WINAPI
3799 IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7
*iface
,
3801 IDirectDrawSurface7
*Texture
)
3803 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3804 IDirectDrawSurfaceImpl
*surf
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, Texture
);
3805 TRACE("(%p)->(%08x,%p): Relay!\n", This
, Stage
, surf
);
3807 /* Texture may be NULL here */
3808 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
3810 surf
? (IWineD3DBaseTexture
* ) surf
->wineD3DTexture
: NULL
);
3813 static HRESULT WINAPI
3814 Thunk_IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3
*iface
,
3816 IDirect3DTexture2
*Texture2
)
3818 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3819 IDirectDrawSurfaceImpl
*tex
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Texture2
);
3820 TRACE_(ddraw_thunk
)("(%p)->(%d,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, tex
);
3821 return IDirect3DDevice7_SetTexture(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3823 ICOM_INTERFACE(tex
, IDirectDrawSurface7
));
3826 /*****************************************************************************
3827 * IDirect3DDevice7::GetTextureStageState
3829 * Retrieves a state from a texture stage.
3834 * Stage: The stage to retrieve the state from
3835 * TexStageStateType: The state type to retrieve
3836 * State: Address to store the state's value at
3840 * DDERR_INVALIDPARAMS if State is NULL
3841 * For details, see IWineD3DDevice::GetTextureStageState
3843 *****************************************************************************/
3844 static HRESULT WINAPI
3845 IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7
*iface
,
3847 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3850 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3851 TRACE("(%p)->(%08x,%08x,%p): Relay!\n", This
, Stage
, TexStageStateType
, State
);
3854 return DDERR_INVALIDPARAMS
;
3856 return IWineD3DDevice_GetTextureStageState(This
->wineD3DDevice
,
3862 static HRESULT WINAPI
3863 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState(IDirect3DDevice3
*iface
,
3865 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3868 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3869 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, TexStageStateType
, State
);
3870 return IDirect3DDevice7_GetTextureStageState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3876 /*****************************************************************************
3877 * IDirect3DDevice7::SetTextureStageState
3879 * Sets a texture stage state. Some stage types need to be handled specially,
3880 * because they do not exist in WineD3D and were moved to another place
3885 * Stage: The stage to modify
3886 * TexStageStateType: The state to change
3887 * State: The new value for the state
3891 * For details, see IWineD3DDevice::SetTextureStageState
3893 *****************************************************************************/
3894 static HRESULT WINAPI
3895 IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7
*iface
,
3897 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3900 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3901 TRACE("(%p)->(%08x,%08x,%08x): Relay!\n", This
, Stage
, TexStageStateType
, State
);
3902 switch(TexStageStateType
)
3904 /* Mipfilter is a sampler state with different values */
3905 case D3DTSS_MIPFILTER
:
3907 WINED3DTEXTUREFILTERTYPE value
;
3910 case D3DTFP_NONE
: value
= WINED3DTEXF_NONE
; break;
3911 case D3DTFP_POINT
: value
= WINED3DTEXF_POINT
; break;
3912 case 0: /* Unchecked */
3913 case D3DTFP_LINEAR
: value
= WINED3DTEXF_LINEAR
; break;
3915 ERR("Unexpected mipfilter value %d\n", State
);
3916 value
= WINED3DTEXF_NONE
;
3918 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
3920 WINED3DSAMP_MIPFILTER
,
3924 /* Minfilter is a sampler state too, equal values */
3925 case D3DTSS_MINFILTER
:
3926 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
3928 WINED3DSAMP_MINFILTER
,
3930 /* Same for MAGFILTER */
3931 case D3DTSS_MAGFILTER
:
3932 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
3934 WINED3DSAMP_MAGFILTER
,
3939 return IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
,
3946 static HRESULT WINAPI
3947 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState(IDirect3DDevice3
*iface
,
3949 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3952 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3953 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, TexStageStateType
, State
);
3954 return IDirect3DDevice7_SetTextureStageState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3960 /*****************************************************************************
3961 * IDirect3DDevice7::ValidateDevice
3963 * SDK: "Reports the device's ability to render the currently set
3964 * texture-blending operations in a single pass". Whatever that means
3970 * NumPasses: Address to write the number of necessary passes for the
3971 * desired effect to.
3975 * See IWineD3DDevice::ValidateDevice for more details
3977 *****************************************************************************/
3978 static HRESULT WINAPI
3979 IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7
*iface
,
3982 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3983 TRACE("(%p)->(%p): Relay\n", This
, NumPasses
);
3985 return IWineD3DDevice_ValidateDevice(This
->wineD3DDevice
, NumPasses
);
3988 static HRESULT WINAPI
3989 Thunk_IDirect3DDeviceImpl_3_ValidateDevice(IDirect3DDevice3
*iface
,
3992 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3993 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Passes
);
3994 return IDirect3DDevice7_ValidateDevice(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3998 /*****************************************************************************
3999 * IDirect3DDevice7::Clear
4001 * Fills the render target, the z buffer and the stencil buffer with a
4002 * clear color / value
4007 * Count: Number of rectangles in Rects must be 0 if Rects is NULL
4008 * Rects: Rectangles to clear. If NULL, the whole surface is cleared
4009 * Flags: Some flags, as usual
4010 * Color: Clear color for the render target
4011 * Z: Clear value for the Z buffer
4012 * Stencil: Clear value to store in each stencil buffer entry
4016 * For details, see IWineD3DDevice::Clear
4018 *****************************************************************************/
4019 static HRESULT WINAPI
4020 IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7
*iface
,
4028 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4029 TRACE("(%p)->(%08x,%p,%08x,%08x,%f,%08x): Relay\n", This
, Count
, Rects
, Flags
, (DWORD
) Color
, Z
, Stencil
);
4031 return IWineD3DDevice_Clear(This
->wineD3DDevice
, Count
, Rects
, Flags
, Color
, Z
, Stencil
);
4034 /*****************************************************************************
4035 * IDirect3DDevice7::SetViewport
4037 * Sets the current viewport.
4039 * Version 7 only, but IDirect3DViewport uses this call for older
4043 * Data: The new viewport to set
4047 * DDERR_INVALIDPARAMS if Data is NULL
4048 * For more details, see IWineDDDevice::SetViewport
4050 *****************************************************************************/
4051 static HRESULT WINAPI
4052 IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7
*iface
,
4055 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4056 TRACE("(%p)->(%p) Relay!\n", This
, Data
);
4059 return DDERR_INVALIDPARAMS
;
4061 /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
4062 return IWineD3DDevice_SetViewport(This
->wineD3DDevice
,
4063 (WINED3DVIEWPORT
*) Data
);
4066 /*****************************************************************************
4067 * IDirect3DDevice::GetViewport
4069 * Returns the current viewport
4074 * Data: D3D7Viewport structure to write the viewport information to
4078 * DDERR_INVALIDPARAMS if Data is NULL
4079 * For more details, see IWineD3DDevice::GetViewport
4081 *****************************************************************************/
4082 static HRESULT WINAPI
4083 IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7
*iface
,
4086 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4088 TRACE("(%p)->(%p) Relay!\n", This
, Data
);
4091 return DDERR_INVALIDPARAMS
;
4093 /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
4094 hr
= IWineD3DDevice_GetViewport(This
->wineD3DDevice
,
4095 (WINED3DVIEWPORT
*) Data
);
4097 return hr_ddraw_from_wined3d(hr
);
4100 /*****************************************************************************
4101 * IDirect3DDevice7::SetMaterial
4108 * Mat: The material to set
4112 * DDERR_INVALIDPARAMS if Mat is NULL.
4113 * For more details, see IWineD3DDevice::SetMaterial
4115 *****************************************************************************/
4116 static HRESULT WINAPI
4117 IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7
*iface
,
4120 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4122 TRACE("(%p)->(%p): Relay!\n", This
, Mat
);
4124 /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
4125 hr
= IWineD3DDevice_SetMaterial(This
->wineD3DDevice
,
4126 (WINED3DMATERIAL
*) Mat
);
4128 return hr_ddraw_from_wined3d(hr
);
4131 /*****************************************************************************
4132 * IDirect3DDevice7::GetMaterial
4134 * Returns the current material
4139 * Mat: D3DMATERIAL7 structure to write the material parameters to
4143 * DDERR_INVALIDPARAMS if Mat is NULL
4144 * For more details, see IWineD3DDevice::GetMaterial
4146 *****************************************************************************/
4147 static HRESULT WINAPI
4148 IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7
*iface
,
4151 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4153 TRACE("(%p)->(%p): Relay!\n", This
, Mat
);
4155 /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
4156 hr
= IWineD3DDevice_GetMaterial(This
->wineD3DDevice
,
4157 (WINED3DMATERIAL
*) Mat
);
4159 return hr_ddraw_from_wined3d(hr
);
4162 /*****************************************************************************
4163 * IDirect3DDevice7::SetLight
4165 * Assigns a light to a light index, but doesn't activate it yet.
4167 * Version 7, IDirect3DLight uses this method for older versions
4170 * LightIndex: The index of the new light
4171 * Light: A D3DLIGHT7 structure describing the light
4175 * For more details, see IWineD3DDevice::SetLight
4177 *****************************************************************************/
4178 static HRESULT WINAPI
4179 IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7
*iface
,
4183 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4185 TRACE("(%p)->(%08x,%p): Relay!\n", This
, LightIndex
, Light
);
4187 /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
4188 hr
= IWineD3DDevice_SetLight(This
->wineD3DDevice
,
4190 (WINED3DLIGHT
*) Light
);
4192 return hr_ddraw_from_wined3d(hr
);
4195 /*****************************************************************************
4196 * IDirect3DDevice7::GetLight
4198 * Returns the light assigned to a light index
4201 * Light: Structure to write the light information to
4205 * DDERR_INVALIDPARAMS if Light is NULL
4206 * For details, see IWineD3DDevice::GetLight
4208 *****************************************************************************/
4209 static HRESULT WINAPI
4210 IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7
*iface
,
4214 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4216 TRACE("(%p)->(%08x,%p): Relay!\n", This
, LightIndex
, Light
);
4218 /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
4219 rc
= IWineD3DDevice_GetLight(This
->wineD3DDevice
,
4221 (WINED3DLIGHT
*) Light
);
4223 /* Translate the result. WineD3D returns other values than D3D7 */
4224 return hr_ddraw_from_wined3d(rc
);
4227 /*****************************************************************************
4228 * IDirect3DDevice7::BeginStateBlock
4230 * Begins recording to a stateblock
4236 * For details see IWineD3DDevice::BeginStateBlock
4238 *****************************************************************************/
4239 static HRESULT WINAPI
4240 IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7
*iface
)
4242 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4244 TRACE("(%p)->(): Relay!\n", This
);
4246 hr
= IWineD3DDevice_BeginStateBlock(This
->wineD3DDevice
);
4247 return hr_ddraw_from_wined3d(hr
);
4250 /*****************************************************************************
4251 * IDirect3DDevice7::EndStateBlock
4253 * Stops recording to a state block and returns the created stateblock
4254 * handle. The d3d7 stateblock handles are the interface pointers of the
4255 * IWineD3DStateBlock interface
4260 * BlockHandle: Address to store the stateblock's handle to
4264 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4265 * See IWineD3DDevice::EndStateBlock for more details
4267 *****************************************************************************/
4268 static HRESULT WINAPI
4269 IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7
*iface
,
4272 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4274 TRACE("(%p)->(%p): Relay!\n", This
, BlockHandle
);
4277 return DDERR_INVALIDPARAMS
;
4279 hr
= IWineD3DDevice_EndStateBlock(This
->wineD3DDevice
,
4280 (IWineD3DStateBlock
**) BlockHandle
);
4281 return hr_ddraw_from_wined3d(hr
);
4284 /*****************************************************************************
4285 * IDirect3DDevice7::PreLoad
4287 * Allows the app to signal that a texture will be used soon, to allow
4288 * the Direct3DDevice to load it to the video card in the meantime.
4293 * Texture: The texture to preload
4297 * DDERR_INVALIDPARAMS if Texture is NULL
4298 * See IWineD3DSurface::PreLoad for details
4300 *****************************************************************************/
4301 static HRESULT WINAPI
4302 IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7
*iface
,
4303 IDirectDrawSurface7
*Texture
)
4305 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4306 IDirectDrawSurfaceImpl
*surf
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, Texture
);
4308 TRACE("(%p)->(%p): Relay!\n", This
, surf
);
4311 return DDERR_INVALIDPARAMS
;
4313 IWineD3DSurface_PreLoad(surf
->WineD3DSurface
);
4317 /*****************************************************************************
4318 * IDirect3DDevice7::ApplyStateBlock
4320 * Activates the state stored in a state block handle.
4323 * BlockHandle: The stateblock handle to activate
4327 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4329 *****************************************************************************/
4330 static HRESULT WINAPI
4331 IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7
*iface
,
4334 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4336 TRACE("(%p)->(%08x): Relay!\n", This
, BlockHandle
);
4339 return D3DERR_INVALIDSTATEBLOCK
;
4341 hr
= IWineD3DStateBlock_Apply((IWineD3DStateBlock
*) BlockHandle
);
4342 return hr_ddraw_from_wined3d(hr
);
4345 /*****************************************************************************
4346 * IDirect3DDevice7::CaptureStateBlock
4348 * Updates a stateblock's values to the values currently set for the device
4353 * BlockHandle: Stateblock to update
4357 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4358 * See IWineD3DDevice::CaptureStateBlock for more details
4360 *****************************************************************************/
4361 static HRESULT WINAPI
4362 IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7
*iface
,
4365 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4367 TRACE("(%p)->(%08x): Relay!\n", This
, BlockHandle
);
4369 if(BlockHandle
== 0)
4370 return D3DERR_INVALIDSTATEBLOCK
;
4372 hr
= IWineD3DStateBlock_Capture((IWineD3DStateBlock
*) BlockHandle
);
4373 return hr_ddraw_from_wined3d(hr
);
4376 /*****************************************************************************
4377 * IDirect3DDevice7::DeleteStateBlock
4379 * Deletes a stateblock handle. This means releasing the WineD3DStateBlock
4384 * BlockHandle: Stateblock handle to delete
4388 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is 0
4390 *****************************************************************************/
4391 static HRESULT WINAPI
4392 IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7
*iface
,
4395 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4396 TRACE("(%p)->(%08x): Relay!\n", This
, BlockHandle
);
4398 if(BlockHandle
== 0)
4399 return D3DERR_INVALIDSTATEBLOCK
;
4401 IWineD3DStateBlock_Release((IWineD3DStateBlock
*) BlockHandle
);
4406 /*****************************************************************************
4407 * IDirect3DDevice7::CreateStateBlock
4409 * Creates a new state block handle.
4414 * Type: The state block type
4415 * BlockHandle: Address to write the created handle to
4419 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4421 *****************************************************************************/
4422 static HRESULT WINAPI
4423 IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7
*iface
,
4424 D3DSTATEBLOCKTYPE Type
,
4427 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4429 TRACE("(%p)->(%08x,%p)!\n", This
, Type
, BlockHandle
);
4432 return DDERR_INVALIDPARAMS
;
4434 /* The D3DSTATEBLOCKTYPE enum is fine here */
4435 hr
= IWineD3DDevice_CreateStateBlock(This
->wineD3DDevice
,
4437 (IWineD3DStateBlock
**) BlockHandle
,
4438 NULL
/* Parent, hope that works */);
4439 return hr_ddraw_from_wined3d(hr
);
4442 /*****************************************************************************
4443 * IDirect3DDevice7::Load
4445 * Loads a rectangular area from the source into the destination texture.
4446 * It can also copy the source to the faces of a cubic environment map
4451 * DestTex: Destination texture
4452 * DestPoint: Point in the destination where the source image should be
4454 * SrcTex: Source texture
4455 * SrcRect: Source rectangle
4460 * DDERR_INVALIDPARAMS if DestTex or SrcTex are NULL
4461 * See IDirect3DTexture2::Load for details
4463 *****************************************************************************/
4464 static HRESULT WINAPI
4465 IDirect3DDeviceImpl_7_Load(IDirect3DDevice7
*iface
,
4466 IDirectDrawSurface7
*DestTex
,
4468 IDirectDrawSurface7
*SrcTex
,
4472 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4473 IDirectDrawSurfaceImpl
*dest
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, DestTex
);
4474 IDirectDrawSurfaceImpl
*src
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, SrcTex
);
4475 FIXME("(%p)->(%p,%p,%p,%p,%08x): Partially Implemented!\n", This
, dest
, DestPoint
, src
, SrcRect
, Flags
);
4477 if( (!src
) || (!dest
) )
4478 return DDERR_INVALIDPARAMS
;
4480 IDirect3DTexture2_Load(ICOM_INTERFACE(dest
, IDirect3DTexture2
),
4481 ICOM_INTERFACE(src
, IDirect3DTexture2
));
4485 /*****************************************************************************
4486 * IDirect3DDevice7::LightEnable
4488 * Enables or disables a light
4490 * Version 7, IDirect3DLight uses this method too.
4493 * LightIndex: The index of the light to enable / disable
4494 * Enable: Enable or disable the light
4498 * For more details, see IWineD3DDevice::SetLightEnable
4500 *****************************************************************************/
4501 static HRESULT WINAPI
4502 IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7
*iface
,
4506 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4508 TRACE("(%p)->(%08x,%d): Relay!\n", This
, LightIndex
, Enable
);
4510 hr
= IWineD3DDevice_SetLightEnable(This
->wineD3DDevice
, LightIndex
, Enable
);
4511 return hr_ddraw_from_wined3d(hr
);
4514 /*****************************************************************************
4515 * IDirect3DDevice7::GetLightEnable
4517 * Retrieves if the light with the given index is enabled or not
4522 * LightIndex: Index of desired light
4523 * Enable: Pointer to a BOOL which contains the result
4527 * DDERR_INVALIDPARAMS if Enable is NULL
4528 * See IWineD3DDevice::GetLightEnable for more details
4530 *****************************************************************************/
4531 static HRESULT WINAPI
4532 IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7
*iface
,
4536 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4538 TRACE("(%p)->(%08x,%p): Relay\n", This
, LightIndex
, Enable
);
4541 return DDERR_INVALIDPARAMS
;
4543 hr
= IWineD3DDevice_GetLightEnable(This
->wineD3DDevice
, LightIndex
, Enable
);
4544 return hr_ddraw_from_wined3d(hr
);
4547 /*****************************************************************************
4548 * IDirect3DDevice7::SetClipPlane
4550 * Sets custom clipping plane
4555 * Index: The index of the clipping plane
4556 * PlaneEquation: An equation defining the clipping plane
4560 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4561 * See IWineD3DDevice::SetClipPlane for more details
4563 *****************************************************************************/
4564 static HRESULT WINAPI
4565 IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7
*iface
,
4567 D3DVALUE
* PlaneEquation
)
4569 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4570 TRACE("(%p)->(%08x,%p): Relay!\n", This
, Index
, PlaneEquation
);
4573 return DDERR_INVALIDPARAMS
;
4575 return IWineD3DDevice_SetClipPlane(This
->wineD3DDevice
, Index
, PlaneEquation
);
4578 /*****************************************************************************
4579 * IDirect3DDevice7::GetClipPlane
4581 * Returns the clipping plane with a specific index
4584 * Index: The index of the desired plane
4585 * PlaneEquation: Address to store the plane equation to
4589 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4590 * See IWineD3DDevice::GetClipPlane for more details
4592 *****************************************************************************/
4593 static HRESULT WINAPI
4594 IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7
*iface
,
4596 D3DVALUE
* PlaneEquation
)
4598 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4599 TRACE("(%p)->(%d,%p): Relay!\n", This
, Index
, PlaneEquation
);
4602 return DDERR_INVALIDPARAMS
;
4604 return IWineD3DDevice_GetClipPlane(This
->wineD3DDevice
, Index
, PlaneEquation
);
4607 /*****************************************************************************
4608 * IDirect3DDevice7::GetInfo
4610 * Retrieves some information about the device. The DirectX sdk says that
4611 * this version returns S_FALSE for all retail builds of DirectX, that's what
4612 * this implementation does.
4615 * DevInfoID: Information type requested
4616 * DevInfoStruct: Pointer to a structure to store the info to
4617 * Size: Size of the structure
4620 * S_FALSE, because it's a non-debug driver
4622 *****************************************************************************/
4623 static HRESULT WINAPI
4624 IDirect3DDeviceImpl_7_GetInfo(IDirect3DDevice7
*iface
,
4626 void *DevInfoStruct
,
4629 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4630 TRACE("(%p)->(%08x,%p,%08x)\n", This
, DevInfoID
, DevInfoStruct
, Size
);
4634 TRACE(" info requested : ");
4637 case D3DDEVINFOID_TEXTUREMANAGER
: TRACE("D3DDEVINFOID_TEXTUREMANAGER\n"); break;
4638 case D3DDEVINFOID_D3DTEXTUREMANAGER
: TRACE("D3DDEVINFOID_D3DTEXTUREMANAGER\n"); break;
4639 case D3DDEVINFOID_TEXTURING
: TRACE("D3DDEVINFOID_TEXTURING\n"); break;
4640 default: ERR(" invalid flag !!!\n"); return DDERR_INVALIDPARAMS
;
4644 return S_FALSE
; /* According to MSDN, this is valid for a non-debug driver */
4647 const IDirect3DDevice7Vtbl IDirect3DDevice7_Vtbl
=
4649 /*** IUnknown Methods ***/
4650 IDirect3DDeviceImpl_7_QueryInterface
,
4651 IDirect3DDeviceImpl_7_AddRef
,
4652 IDirect3DDeviceImpl_7_Release
,
4653 /*** IDirect3DDevice7 ***/
4654 IDirect3DDeviceImpl_7_GetCaps
,
4655 IDirect3DDeviceImpl_7_EnumTextureFormats
,
4656 IDirect3DDeviceImpl_7_BeginScene
,
4657 IDirect3DDeviceImpl_7_EndScene
,
4658 IDirect3DDeviceImpl_7_GetDirect3D
,
4659 IDirect3DDeviceImpl_7_SetRenderTarget
,
4660 IDirect3DDeviceImpl_7_GetRenderTarget
,
4661 IDirect3DDeviceImpl_7_Clear
,
4662 IDirect3DDeviceImpl_7_SetTransform
,
4663 IDirect3DDeviceImpl_7_GetTransform
,
4664 IDirect3DDeviceImpl_7_SetViewport
,
4665 IDirect3DDeviceImpl_7_MultiplyTransform
,
4666 IDirect3DDeviceImpl_7_GetViewport
,
4667 IDirect3DDeviceImpl_7_SetMaterial
,
4668 IDirect3DDeviceImpl_7_GetMaterial
,
4669 IDirect3DDeviceImpl_7_SetLight
,
4670 IDirect3DDeviceImpl_7_GetLight
,
4671 IDirect3DDeviceImpl_7_SetRenderState
,
4672 IDirect3DDeviceImpl_7_GetRenderState
,
4673 IDirect3DDeviceImpl_7_BeginStateBlock
,
4674 IDirect3DDeviceImpl_7_EndStateBlock
,
4675 IDirect3DDeviceImpl_7_PreLoad
,
4676 IDirect3DDeviceImpl_7_DrawPrimitive
,
4677 IDirect3DDeviceImpl_7_DrawIndexedPrimitive
,
4678 IDirect3DDeviceImpl_7_SetClipStatus
,
4679 IDirect3DDeviceImpl_7_GetClipStatus
,
4680 IDirect3DDeviceImpl_7_DrawPrimitiveStrided
,
4681 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided
,
4682 IDirect3DDeviceImpl_7_DrawPrimitiveVB
,
4683 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB
,
4684 IDirect3DDeviceImpl_7_ComputeSphereVisibility
,
4685 IDirect3DDeviceImpl_7_GetTexture
,
4686 IDirect3DDeviceImpl_7_SetTexture
,
4687 IDirect3DDeviceImpl_7_GetTextureStageState
,
4688 IDirect3DDeviceImpl_7_SetTextureStageState
,
4689 IDirect3DDeviceImpl_7_ValidateDevice
,
4690 IDirect3DDeviceImpl_7_ApplyStateBlock
,
4691 IDirect3DDeviceImpl_7_CaptureStateBlock
,
4692 IDirect3DDeviceImpl_7_DeleteStateBlock
,
4693 IDirect3DDeviceImpl_7_CreateStateBlock
,
4694 IDirect3DDeviceImpl_7_Load
,
4695 IDirect3DDeviceImpl_7_LightEnable
,
4696 IDirect3DDeviceImpl_7_GetLightEnable
,
4697 IDirect3DDeviceImpl_7_SetClipPlane
,
4698 IDirect3DDeviceImpl_7_GetClipPlane
,
4699 IDirect3DDeviceImpl_7_GetInfo
4702 const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl
=
4704 /*** IUnknown Methods ***/
4705 Thunk_IDirect3DDeviceImpl_3_QueryInterface
,
4706 Thunk_IDirect3DDeviceImpl_3_AddRef
,
4707 Thunk_IDirect3DDeviceImpl_3_Release
,
4708 /*** IDirect3DDevice3 ***/
4709 IDirect3DDeviceImpl_3_GetCaps
,
4710 IDirect3DDeviceImpl_3_GetStats
,
4711 IDirect3DDeviceImpl_3_AddViewport
,
4712 IDirect3DDeviceImpl_3_DeleteViewport
,
4713 IDirect3DDeviceImpl_3_NextViewport
,
4714 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats
,
4715 Thunk_IDirect3DDeviceImpl_3_BeginScene
,
4716 Thunk_IDirect3DDeviceImpl_3_EndScene
,
4717 Thunk_IDirect3DDeviceImpl_3_GetDirect3D
,
4718 IDirect3DDeviceImpl_3_SetCurrentViewport
,
4719 IDirect3DDeviceImpl_3_GetCurrentViewport
,
4720 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget
,
4721 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget
,
4722 IDirect3DDeviceImpl_3_Begin
,
4723 IDirect3DDeviceImpl_3_BeginIndexed
,
4724 IDirect3DDeviceImpl_3_Vertex
,
4725 IDirect3DDeviceImpl_3_Index
,
4726 IDirect3DDeviceImpl_3_End
,
4727 Thunk_IDirect3DDeviceImpl_3_GetRenderState
,
4728 Thunk_IDirect3DDeviceImpl_3_SetRenderState
,
4729 IDirect3DDeviceImpl_3_GetLightState
,
4730 IDirect3DDeviceImpl_3_SetLightState
,
4731 Thunk_IDirect3DDeviceImpl_3_SetTransform
,
4732 Thunk_IDirect3DDeviceImpl_3_GetTransform
,
4733 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform
,
4734 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive
,
4735 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive
,
4736 Thunk_IDirect3DDeviceImpl_3_SetClipStatus
,
4737 Thunk_IDirect3DDeviceImpl_3_GetClipStatus
,
4738 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided
,
4739 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided
,
4740 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB
,
4741 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB
,
4742 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility
,
4743 Thunk_IDirect3DDeviceImpl_3_GetTexture
,
4744 Thunk_IDirect3DDeviceImpl_3_SetTexture
,
4745 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState
,
4746 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState
,
4747 Thunk_IDirect3DDeviceImpl_3_ValidateDevice
4750 const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl
=
4752 /*** IUnknown Methods ***/
4753 Thunk_IDirect3DDeviceImpl_2_QueryInterface
,
4754 Thunk_IDirect3DDeviceImpl_2_AddRef
,
4755 Thunk_IDirect3DDeviceImpl_2_Release
,
4756 /*** IDirect3DDevice2 ***/
4757 Thunk_IDirect3DDeviceImpl_2_GetCaps
,
4758 IDirect3DDeviceImpl_2_SwapTextureHandles
,
4759 Thunk_IDirect3DDeviceImpl_2_GetStats
,
4760 Thunk_IDirect3DDeviceImpl_2_AddViewport
,
4761 Thunk_IDirect3DDeviceImpl_2_DeleteViewport
,
4762 Thunk_IDirect3DDeviceImpl_2_NextViewport
,
4763 IDirect3DDeviceImpl_2_EnumTextureFormats
,
4764 Thunk_IDirect3DDeviceImpl_2_BeginScene
,
4765 Thunk_IDirect3DDeviceImpl_2_EndScene
,
4766 Thunk_IDirect3DDeviceImpl_2_GetDirect3D
,
4767 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport
,
4768 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport
,
4769 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget
,
4770 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget
,
4771 Thunk_IDirect3DDeviceImpl_2_Begin
,
4772 Thunk_IDirect3DDeviceImpl_2_BeginIndexed
,
4773 Thunk_IDirect3DDeviceImpl_2_Vertex
,
4774 Thunk_IDirect3DDeviceImpl_2_Index
,
4775 Thunk_IDirect3DDeviceImpl_2_End
,
4776 Thunk_IDirect3DDeviceImpl_2_GetRenderState
,
4777 Thunk_IDirect3DDeviceImpl_2_SetRenderState
,
4778 Thunk_IDirect3DDeviceImpl_2_GetLightState
,
4779 Thunk_IDirect3DDeviceImpl_2_SetLightState
,
4780 Thunk_IDirect3DDeviceImpl_2_SetTransform
,
4781 Thunk_IDirect3DDeviceImpl_2_GetTransform
,
4782 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform
,
4783 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive
,
4784 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive
,
4785 Thunk_IDirect3DDeviceImpl_2_SetClipStatus
,
4786 Thunk_IDirect3DDeviceImpl_2_GetClipStatus
4789 const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl
=
4791 /*** IUnknown Methods ***/
4792 Thunk_IDirect3DDeviceImpl_1_QueryInterface
,
4793 Thunk_IDirect3DDeviceImpl_1_AddRef
,
4794 Thunk_IDirect3DDeviceImpl_1_Release
,
4795 /*** IDirect3DDevice1 ***/
4796 IDirect3DDeviceImpl_1_Initialize
,
4797 Thunk_IDirect3DDeviceImpl_1_GetCaps
,
4798 Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles
,
4799 IDirect3DDeviceImpl_1_CreateExecuteBuffer
,
4800 Thunk_IDirect3DDeviceImpl_1_GetStats
,
4801 IDirect3DDeviceImpl_1_Execute
,
4802 Thunk_IDirect3DDeviceImpl_1_AddViewport
,
4803 Thunk_IDirect3DDeviceImpl_1_DeleteViewport
,
4804 Thunk_IDirect3DDeviceImpl_1_NextViewport
,
4805 IDirect3DDeviceImpl_1_Pick
,
4806 IDirect3DDeviceImpl_1_GetPickRecords
,
4807 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats
,
4808 IDirect3DDeviceImpl_1_CreateMatrix
,
4809 IDirect3DDeviceImpl_1_SetMatrix
,
4810 IDirect3DDeviceImpl_1_GetMatrix
,
4811 IDirect3DDeviceImpl_1_DeleteMatrix
,
4812 Thunk_IDirect3DDeviceImpl_1_EndScene
,
4813 Thunk_IDirect3DDeviceImpl_1_BeginScene
,
4814 Thunk_IDirect3DDeviceImpl_1_GetDirect3D
4817 /*****************************************************************************
4818 * IDirect3DDeviceImpl_CreateHandle
4820 * Not called from the VTable
4822 * Some older interface versions operate with handles, which are basically
4823 * DWORDs which identify an interface, for example
4824 * IDirect3DDevice::SetRenderState with DIRECT3DRENDERSTATE_TEXTUREHANDLE
4826 * Those handle could be just casts to the interface pointers or vice versa,
4827 * but that is not 64 bit safe and would mean blindly derefering a DWORD
4828 * passed by the app. Instead there is a dynamic array in the device which
4829 * keeps a DWORD to pointer information and a type for the handle.
4831 * Basically this array only grows, when a handle is freed its pointer is
4832 * just set to NULL. There will be much more reads from the array than
4833 * insertion operations, so a dynamic array is fine.
4836 * This: D3DDevice implementation for which this handle should be created
4839 * A free handle on success
4842 *****************************************************************************/
4844 IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl
*This
)
4847 struct HandleEntry
*oldHandles
= This
->Handles
;
4849 TRACE("(%p)\n", This
);
4851 for(i
= 0; i
< This
->numHandles
; i
++)
4853 if(This
->Handles
[i
].ptr
== NULL
&&
4854 This
->Handles
[i
].type
== DDrawHandle_Unknown
)
4856 TRACE("Reusing freed handle %d\n", i
+ 1);
4861 TRACE("Growing the handle array\n");
4864 This
->Handles
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct HandleEntry
) * This
->numHandles
);
4867 ERR("Out of memory\n");
4868 This
->Handles
= oldHandles
;
4874 memcpy(This
->Handles
, oldHandles
, (This
->numHandles
- 1) * sizeof(struct HandleEntry
));
4875 HeapFree(GetProcessHeap(), 0, oldHandles
);
4878 TRACE("Returning %d\n", This
->numHandles
);
4879 return This
->numHandles
;