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 /* There is no need to unset the vertex buffer here, IWineD3DDevice_Uninit3D will do that when
304 * destroying the primary stateblock. If a vertex buffer is destroyed while it is bound
305 * IDirect3DVertexBuffer::Release will unset it.
308 /* Restore the render targets */
309 if(This
->OffScreenTarget
)
311 /* This->target is the offscreen target.
312 * This->ddraw->d3d_target is the target used by DDraw
314 TRACE("(%p) Release: Using %p as front buffer, %p as back buffer\n", This
, This
->ddraw
->d3d_target
, NULL
);
315 IWineD3DDevice_SetFrontBackBuffers(This
->wineD3DDevice
,
316 This
->ddraw
->d3d_target
->WineD3DSurface
,
320 /* Release the WineD3DDevice. This won't destroy it */
321 if(IWineD3DDevice_Release(This
->wineD3DDevice
) <= 0)
323 ERR(" (%p) The wineD3D device %p was destroyed unexpectadely. Prepare for trouble\n", This
, This
->wineD3DDevice
);
326 /* The texture handles should be unset by now, but there might be some bits
327 * missing in our reference counting(needs test). Do a sanity check
329 for(i
= 0; i
< This
->numHandles
; i
++)
331 if(This
->Handles
[i
].ptr
)
333 switch(This
->Handles
[i
].type
)
335 case DDrawHandle_Texture
:
337 IDirectDrawSurfaceImpl
*surf
= (IDirectDrawSurfaceImpl
*) This
->Handles
[i
].ptr
;
338 FIXME("Texture Handle %d not unset properly\n", i
+ 1);
343 case DDrawHandle_Material
:
345 IDirect3DMaterialImpl
*mat
= (IDirect3DMaterialImpl
*) This
->Handles
[i
].ptr
;
346 FIXME("Material handle %d not unset properly\n", i
+ 1);
351 case DDrawHandle_Matrix
:
353 /* No fixme here because this might happen because of sloppy apps */
354 WARN("Leftover matrix handle %d, deleting\n", i
+ 1);
355 IDirect3DDevice_DeleteMatrix(ICOM_INTERFACE(This
, IDirect3DDevice
),
360 case DDrawHandle_StateBlock
:
362 /* No fixme here because this might happen because of sloppy apps */
363 WARN("Leftover stateblock handle %d, deleting\n", i
+ 1);
364 IDirect3DDevice7_DeleteStateBlock(ICOM_INTERFACE(This
, IDirect3DDevice7
),
370 FIXME("Unknown handle %d not unset properly\n", i
+ 1);
375 HeapFree(GetProcessHeap(), 0, This
->Handles
);
377 /* Release the render target and the WineD3D render target
378 * (See IDirect3D7::CreateDevice for more comments on this)
380 IDirectDrawSurface7_Release(ICOM_INTERFACE(This
->target
, IDirectDrawSurface7
));
381 IDirectDrawSurface7_Release(ICOM_INTERFACE(This
->ddraw
->d3d_target
,IDirectDrawSurface7
));
383 This
->ddraw
->d3ddevice
= NULL
;
385 /* Now free the structure */
386 HeapFree(GetProcessHeap(), 0, This
);
393 Thunk_IDirect3DDeviceImpl_3_Release(IDirect3DDevice3
*iface
)
395 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
396 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
397 return IDirect3DDevice7_Release(ICOM_INTERFACE(This
, IDirect3DDevice7
));
401 Thunk_IDirect3DDeviceImpl_2_Release(IDirect3DDevice2
*iface
)
403 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
404 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
405 return IDirect3DDevice7_Release(ICOM_INTERFACE(This
, IDirect3DDevice7
));
409 Thunk_IDirect3DDeviceImpl_1_Release(IDirect3DDevice
*iface
)
411 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
412 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
413 return IDirect3DDevice7_Release(ICOM_INTERFACE(This
, IDirect3DDevice7
));
416 /*****************************************************************************
417 * IDirect3DDevice Methods
418 *****************************************************************************/
420 /*****************************************************************************
421 * IDirect3DDevice::Initialize
423 * Initializes a Direct3DDevice. This implementation is a no-op, as all
424 * initialization is done at create time.
426 * Exists in Version 1
429 * No idea what they mean, as the MSDN page is gone
433 *****************************************************************************/
434 static HRESULT WINAPI
435 IDirect3DDeviceImpl_1_Initialize(IDirect3DDevice
*iface
,
436 IDirect3D
*Direct3D
, GUID
*guid
,
439 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
441 /* It shouldn't be crucial, but print a FIXME, I'm interested if
442 * any game calls it and when
444 FIXME("(%p)->(%p,%p,%p): No-op!\n", This
, Direct3D
, guid
, Desc
);
449 /*****************************************************************************
450 * IDirect3DDevice7::GetCaps
452 * Retrieves the device's capabilities
454 * This implementation is used for Version 7 only, the older versions have
455 * their own implementation.
458 * Desc: Pointer to a D3DDEVICEDESC7 structure to fill
462 * D3DERR_* if a problem occurs. See WineD3D
464 *****************************************************************************/
465 static HRESULT WINAPI
466 IDirect3DDeviceImpl_7_GetCaps(IDirect3DDevice7
*iface
,
467 D3DDEVICEDESC7
*Desc
)
469 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
470 D3DDEVICEDESC OldDesc
;
471 TRACE("(%p)->(%p)\n", This
, Desc
);
473 /* Call the same function used by IDirect3D, this saves code */
474 return IDirect3DImpl_GetCaps(This
->ddraw
->wineD3D
, &OldDesc
, Desc
);
477 /*****************************************************************************
478 * IDirect3DDevice3::GetCaps
480 * Retrieves the capabilities of the hardware device and the emulation
481 * device. For Wine, hardware and emulation are the same (it's all HW).
483 * This implementation is used for Version 1, 2, and 3. Version 7 has its own
486 * HWDesc: Structure to fill with the HW caps
487 * HelDesc: Structure to fill with the hardare emulation caps
491 * D3DERR_* if a problem occurs. See WineD3D
493 *****************************************************************************/
494 static HRESULT WINAPI
495 IDirect3DDeviceImpl_3_GetCaps(IDirect3DDevice3
*iface
,
496 D3DDEVICEDESC
*HWDesc
,
497 D3DDEVICEDESC
*HelDesc
)
499 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
500 D3DDEVICEDESC7 newDesc
;
502 TRACE("(%p)->(%p,%p)\n", iface
, HWDesc
, HelDesc
);
504 hr
= IDirect3DImpl_GetCaps(This
->ddraw
->wineD3D
, HWDesc
, &newDesc
);
505 if(hr
!= D3D_OK
) return hr
;
511 static HRESULT WINAPI
512 Thunk_IDirect3DDeviceImpl_2_GetCaps(IDirect3DDevice2
*iface
,
513 D3DDEVICEDESC
*D3DHWDevDesc
,
514 D3DDEVICEDESC
*D3DHELDevDesc
)
516 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
517 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice3 interface.\n", This
, D3DHWDevDesc
, D3DHELDevDesc
);
518 return IDirect3DDevice3_GetCaps(ICOM_INTERFACE(This
, IDirect3DDevice3
),
523 static HRESULT WINAPI
524 Thunk_IDirect3DDeviceImpl_1_GetCaps(IDirect3DDevice
*iface
,
525 D3DDEVICEDESC
*D3DHWDevDesc
,
526 D3DDEVICEDESC
*D3DHELDevDesc
)
528 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
529 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice3 interface.\n", This
, D3DHWDevDesc
, D3DHELDevDesc
);
530 return IDirect3DDevice3_GetCaps(ICOM_INTERFACE(This
, IDirect3DDevice3
),
535 /*****************************************************************************
536 * IDirect3DDevice2::SwapTextureHandles
538 * Swaps the texture handles of 2 Texture interfaces. Version 1 and 2
541 * Tex1, Tex2: The 2 Textures to swap
546 *****************************************************************************/
547 static HRESULT WINAPI
548 IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2
*iface
,
549 IDirect3DTexture2
*Tex1
,
550 IDirect3DTexture2
*Tex2
)
552 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
554 IDirectDrawSurfaceImpl
*surf1
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Tex1
);
555 IDirectDrawSurfaceImpl
*surf2
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Tex2
);
556 TRACE("(%p)->(%p,%p)\n", This
, surf1
, surf2
);
558 This
->Handles
[surf1
->Handle
- 1].ptr
= surf2
;
559 This
->Handles
[surf2
->Handle
- 1].ptr
= surf1
;
561 swap
= surf2
->Handle
;
562 surf2
->Handle
= surf1
->Handle
;
563 surf1
->Handle
= swap
;
568 static HRESULT WINAPI
569 Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles(IDirect3DDevice
*iface
,
570 IDirect3DTexture
*D3DTex1
,
571 IDirect3DTexture
*D3DTex2
)
573 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
574 IDirectDrawSurfaceImpl
*surf1
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture
, D3DTex1
);
575 IDirectDrawSurfaceImpl
*surf2
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture
, D3DTex2
);
576 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", This
, surf1
, surf2
);
577 return IDirect3DDevice2_SwapTextureHandles(ICOM_INTERFACE(This
, IDirect3DDevice2
),
578 ICOM_INTERFACE(surf1
, IDirect3DTexture2
),
579 ICOM_INTERFACE(surf2
, IDirect3DTexture2
));
582 /*****************************************************************************
583 * IDirect3DDevice3::GetStats
585 * This method seems to retrieve some stats from the device.
586 * The MSDN documentation doesn't exist any more, but the D3DSTATS
587 * structure suggests that the amout of drawn primitives and processed
588 * vertices is returned.
590 * Exists in Version 1, 2 and 3
593 * Stats: Pointer to a D3DSTATS structure to be filled
597 * DDERR_INVALIDPARAMS if Stats == NULL
599 *****************************************************************************/
600 static HRESULT WINAPI
601 IDirect3DDeviceImpl_3_GetStats(IDirect3DDevice3
*iface
,
604 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
605 FIXME("(%p)->(%p): Stub!\n", This
, Stats
);
608 return DDERR_INVALIDPARAMS
;
610 /* Fill the Stats with 0 */
611 Stats
->dwTrianglesDrawn
= 0;
612 Stats
->dwLinesDrawn
= 0;
613 Stats
->dwPointsDrawn
= 0;
614 Stats
->dwSpansDrawn
= 0;
615 Stats
->dwVerticesProcessed
= 0;
620 static HRESULT WINAPI
621 Thunk_IDirect3DDeviceImpl_2_GetStats(IDirect3DDevice2
*iface
,
624 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
625 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Stats
);
626 return IDirect3DDevice3_GetStats(ICOM_INTERFACE(This
, IDirect3DDevice3
),
630 static HRESULT WINAPI
631 Thunk_IDirect3DDeviceImpl_1_GetStats(IDirect3DDevice
*iface
,
634 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
635 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Stats
);
636 return IDirect3DDevice3_GetStats(ICOM_INTERFACE(This
, IDirect3DDevice3
),
640 /*****************************************************************************
641 * IDirect3DDevice::CreateExecuteBuffer
643 * Creates an IDirect3DExecuteBuffer, used for rendering with a
649 * Desc: Buffer description
650 * ExecuteBuffer: Address to return the Interface pointer at
651 * UnkOuter: Must be NULL. Basically for aggregation, which ddraw doesn't
655 * CLASS_E_NOAGGREGATION if UnkOuter != NULL
656 * DDERR_OUTOFMEMORY if we ran out of memory
659 *****************************************************************************/
660 static HRESULT WINAPI
661 IDirect3DDeviceImpl_1_CreateExecuteBuffer(IDirect3DDevice
*iface
,
662 D3DEXECUTEBUFFERDESC
*Desc
,
663 IDirect3DExecuteBuffer
**ExecuteBuffer
,
666 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
667 IDirect3DExecuteBufferImpl
* object
;
668 TRACE("(%p)->(%p,%p,%p)!\n", This
, Desc
, ExecuteBuffer
, UnkOuter
);
671 return CLASS_E_NOAGGREGATION
;
673 /* Allocate the new Execute Buffer */
674 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DExecuteBufferImpl
));
677 ERR("Out of memory when allocating a IDirect3DExecuteBufferImpl structure\n");
678 return DDERR_OUTOFMEMORY
;
681 ICOM_INIT_INTERFACE(object
, IDirect3DExecuteBuffer
, IDirect3DExecuteBuffer_Vtbl
);
684 object
->d3ddev
= This
;
686 /* Initializes memory */
687 memcpy(&object
->desc
, Desc
, Desc
->dwSize
);
689 /* No buffer given */
690 if ((object
->desc
.dwFlags
& D3DDEB_LPDATA
) == 0)
691 object
->desc
.lpData
= NULL
;
693 /* No buffer size given */
694 if ((object
->desc
.dwFlags
& D3DDEB_BUFSIZE
) == 0)
695 object
->desc
.dwBufferSize
= 0;
697 /* Create buffer if asked */
698 if ((object
->desc
.lpData
== NULL
) && (object
->desc
.dwBufferSize
> 0))
700 object
->need_free
= TRUE
;
701 object
->desc
.lpData
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,object
->desc
.dwBufferSize
);
702 if(!object
->desc
.lpData
)
704 ERR("Out of memory when allocating the execute buffer data\n");
705 HeapFree(GetProcessHeap(), 0, object
);
706 return DDERR_OUTOFMEMORY
;
711 object
->need_free
= FALSE
;
714 /* No vertices for the moment */
715 object
->vertex_data
= NULL
;
717 object
->desc
.dwFlags
|= D3DDEB_LPDATA
;
719 object
->indices
= NULL
;
720 object
->nb_indices
= 0;
722 *ExecuteBuffer
= ICOM_INTERFACE(object
, IDirect3DExecuteBuffer
);
724 TRACE(" Returning IDirect3DExecuteBuffer at %p, implementation is at %p\n", *ExecuteBuffer
, object
);
729 /*****************************************************************************
730 * IDirect3DDevice::Execute
732 * Executes all the stuff in an execute buffer.
735 * ExecuteBuffer: The buffer to execute
736 * Viewport: The viewport used for rendering
740 * DDERR_INVALIDPARAMS if ExecuteBuffer == NULL
743 *****************************************************************************/
744 static HRESULT WINAPI
745 IDirect3DDeviceImpl_1_Execute(IDirect3DDevice
*iface
,
746 IDirect3DExecuteBuffer
*ExecuteBuffer
,
747 IDirect3DViewport
*Viewport
,
750 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
751 IDirect3DExecuteBufferImpl
*Direct3DExecuteBufferImpl
= ICOM_OBJECT(IDirect3DExecuteBufferImpl
, IDirect3DExecuteBuffer
, ExecuteBuffer
);
752 IDirect3DViewportImpl
*Direct3DViewportImpl
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
754 TRACE("(%p)->(%p,%p,%08x)\n", This
, Direct3DExecuteBufferImpl
, Direct3DViewportImpl
, Flags
);
756 if(!Direct3DExecuteBufferImpl
)
757 return DDERR_INVALIDPARAMS
;
760 IDirect3DExecuteBufferImpl_Execute(Direct3DExecuteBufferImpl
, This
, Direct3DViewportImpl
);
765 /*****************************************************************************
766 * IDirect3DDevice3::AddViewport
768 * Add a Direct3DViewport to the device's viewport list. These viewports
769 * are wrapped to IDirect3DDevice7 viewports in viewport.c
771 * Exists in Version 1, 2 and 3. Note that IDirect3DViewport 1, 2 and 3
772 * are the same interfaces.
775 * Viewport: The viewport to add
778 * DDERR_INVALIDPARAMS if Viewport == NULL
781 *****************************************************************************/
782 static HRESULT WINAPI
783 IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3
*iface
,
784 IDirect3DViewport3
*Viewport
)
786 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
787 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
789 TRACE("(%p)->(%p)\n", This
, vp
);
793 return DDERR_INVALIDPARAMS
;
795 vp
->next
= This
->viewport_list
;
796 This
->viewport_list
= vp
;
801 static HRESULT WINAPI
802 Thunk_IDirect3DDeviceImpl_2_AddViewport(IDirect3DDevice2
*iface
,
803 IDirect3DViewport2
*Direct3DViewport2
)
805 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
806 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
807 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
808 return IDirect3DDevice3_AddViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
809 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
812 static HRESULT WINAPI
813 Thunk_IDirect3DDeviceImpl_1_AddViewport(IDirect3DDevice
*iface
,
814 IDirect3DViewport
*Direct3DViewport
)
816 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
817 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport
);
818 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
819 return IDirect3DDevice3_AddViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
820 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
823 /*****************************************************************************
824 * IDirect3DDevice3::DeleteViewport
826 * Deletes a Direct3DViewport from the device's viewport list.
828 * Exists in Version 1, 2 and 3. Note that all Viewport interface versions
832 * Viewport: The viewport to delete
836 * DDERR_INVALIDPARAMS if the viewport wasn't found in the list
838 *****************************************************************************/
839 static HRESULT WINAPI
840 IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3
*iface
,
841 IDirect3DViewport3
*Viewport
)
843 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
844 IDirect3DViewportImpl
*vp
= (IDirect3DViewportImpl
*) Viewport
;
845 IDirect3DViewportImpl
*cur_viewport
, *prev_viewport
= NULL
;
847 TRACE("(%p)->(%p)\n", This
, vp
);
849 cur_viewport
= This
->viewport_list
;
850 while (cur_viewport
!= NULL
)
852 if (cur_viewport
== vp
)
854 if (prev_viewport
== NULL
) This
->viewport_list
= cur_viewport
->next
;
855 else prev_viewport
->next
= cur_viewport
->next
;
856 /* TODO : add desactivate of the viewport and all associated lights... */
859 prev_viewport
= cur_viewport
;
860 cur_viewport
= cur_viewport
->next
;
863 return DDERR_INVALIDPARAMS
;
866 static HRESULT WINAPI
867 Thunk_IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2
*iface
,
868 IDirect3DViewport2
*Direct3DViewport2
)
870 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
871 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
872 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
873 return IDirect3DDevice3_DeleteViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
874 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
877 static HRESULT WINAPI
878 Thunk_IDirect3DDeviceImpl_1_DeleteViewport(IDirect3DDevice
*iface
,
879 IDirect3DViewport
*Direct3DViewport
)
881 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
882 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport
);
883 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
884 return IDirect3DDevice3_DeleteViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
885 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
888 /*****************************************************************************
889 * IDirect3DDevice3::NextViewport
891 * Returns a viewport from the viewport list, depending on the
892 * passed viewport and the flags.
894 * Exists in Version 1, 2 and 3. Note that all Viewport interface versions
898 * Viewport: Viewport to use for beginning the search
899 * Flags: D3DNEXT_NEXT, D3DNEXT_HEAD or D3DNEXT_TAIL
903 * DDERR_INVALIDPARAMS if the flags were wrong, or Viewport was NULL
905 *****************************************************************************/
906 static HRESULT WINAPI
907 IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3
*iface
,
908 IDirect3DViewport3
*Viewport3
,
909 IDirect3DViewport3
**lplpDirect3DViewport3
,
912 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
913 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport3
);
914 IDirect3DViewportImpl
*res
= NULL
;
916 TRACE("(%p)->(%p,%p,%08x)\n", This
, vp
, lplpDirect3DViewport3
, Flags
);
920 *lplpDirect3DViewport3
= NULL
;
921 return DDERR_INVALIDPARAMS
;
934 res
= This
->viewport_list
;
939 IDirect3DViewportImpl
*cur_viewport
= This
->viewport_list
;
940 if (cur_viewport
!= NULL
)
942 while (cur_viewport
->next
!= NULL
) cur_viewport
= cur_viewport
->next
;
948 *lplpDirect3DViewport3
= NULL
;
949 return DDERR_INVALIDPARAMS
;
952 *lplpDirect3DViewport3
= ICOM_INTERFACE(res
, IDirect3DViewport3
);
956 static HRESULT WINAPI
957 Thunk_IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2
*iface
,
958 IDirect3DViewport2
*Viewport2
,
959 IDirect3DViewport2
**lplpDirect3DViewport2
,
962 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
963 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport2
);
964 IDirect3DViewport3
*res
;
966 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08x) thunking to IDirect3DDevice3 interface.\n", This
, vp
, lplpDirect3DViewport2
, Flags
);
967 hr
= IDirect3DDevice3_NextViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
968 ICOM_INTERFACE(vp
, IDirect3DViewport3
),
971 *lplpDirect3DViewport2
= (IDirect3DViewport2
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, res
);
975 static HRESULT WINAPI
976 Thunk_IDirect3DDeviceImpl_1_NextViewport(IDirect3DDevice
*iface
,
977 IDirect3DViewport
*Viewport
,
978 IDirect3DViewport
**lplpDirect3DViewport
,
981 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
982 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
983 IDirect3DViewport3
*res
;
985 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08x) thunking to IDirect3DDevice3 interface.\n", This
, vp
, lplpDirect3DViewport
, Flags
);
986 hr
= IDirect3DDevice3_NextViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
987 ICOM_INTERFACE(vp
, IDirect3DViewport3
),
990 *lplpDirect3DViewport
= (IDirect3DViewport
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, res
);
994 /*****************************************************************************
995 * IDirect3DDevice::Pick
997 * Executes an execute buffer without performing rendering. Instead, a
998 * list of primitives that intersect with (x1,y1) of the passed rectangle
999 * is created. IDirect3DDevice::GetPickRecords can be used to retrieve
1005 * ExecuteBuffer: Buffer to execute
1006 * Viewport: Viewport to use for execution
1007 * Flags: None are defined, according to the SDK
1008 * Rect: Specifies the coordinates to be picked. Only x1 and y2 are used,
1009 * x2 and y2 are ignored.
1012 * D3D_OK because it's a stub
1014 *****************************************************************************/
1015 static HRESULT WINAPI
1016 IDirect3DDeviceImpl_1_Pick(IDirect3DDevice
*iface
,
1017 IDirect3DExecuteBuffer
*ExecuteBuffer
,
1018 IDirect3DViewport
*Viewport
,
1022 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1023 IDirect3DExecuteBufferImpl
*execbuf
= ICOM_OBJECT(IDirect3DExecuteBufferImpl
, IDirect3DExecuteBuffer
, ExecuteBuffer
);
1024 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
1025 FIXME("(%p)->(%p,%p,%08x,%p): stub!\n", This
, execbuf
, vp
, Flags
, Rect
);
1030 /*****************************************************************************
1031 * IDirect3DDevice::GetPickRecords
1033 * Retrieves the pick records generated by IDirect3DDevice::GetPickRecords
1038 * Count: Pointer to a DWORD containing the numbers of pick records to
1040 * D3DPickRec: Address to store the resulting D3DPICKRECORD arry.
1043 * D3D_OK, because it's a stub
1045 *****************************************************************************/
1046 static HRESULT WINAPI
1047 IDirect3DDeviceImpl_1_GetPickRecords(IDirect3DDevice
*iface
,
1049 D3DPICKRECORD
*D3DPickRec
)
1051 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1052 FIXME("(%p)->(%p,%p): stub!\n", This
, Count
, D3DPickRec
);
1057 /*****************************************************************************
1058 * IDirect3DDevice7::EnumTextureformats
1060 * Enumerates the supported texture formats. It has a list of all possible
1061 * formats and calls IWineD3D::CheckDeviceFormat for each format to see if
1062 * WineD3D supports it. If so, then it is passed to the app.
1064 * This is for Version 7 and 3, older versions have a different
1065 * callback function and their own implementation
1068 * Callback: Callback to call for each enumerated format
1069 * Arg: Argument to pass to the callback
1073 * DDERR_INVALIDPARAMS if Callback == NULL
1075 *****************************************************************************/
1076 static HRESULT WINAPI
1077 IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7
*iface
,
1078 LPD3DENUMPIXELFORMATSCALLBACK Callback
,
1081 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1085 WINED3DFORMAT FormatList
[] = {
1087 WINED3DFMT_A8R8G8B8
,
1088 WINED3DFMT_X8R8G8B8
,
1092 WINED3DFMT_A1R5G5B5
,
1093 WINED3DFMT_A4R4G4B4
,
1095 WINED3DFMT_X1R5G5B5
,
1105 TRACE("(%p)->(%p,%p): Relay\n", This
, Callback
, Arg
);
1108 return DDERR_INVALIDPARAMS
;
1110 for(i
= 0; i
< sizeof(FormatList
) / sizeof(WINED3DFORMAT
); i
++)
1112 hr
= IWineD3D_CheckDeviceFormat(This
->ddraw
->wineD3D
,
1115 0 /* AdapterFormat */,
1117 0 /* ResourceType */,
1121 DDPIXELFORMAT pformat
;
1123 memset(&pformat
, 0, sizeof(pformat
));
1124 pformat
.dwSize
= sizeof(pformat
);
1125 PixelFormat_WineD3DtoDD(&pformat
, FormatList
[i
]);
1127 TRACE("Enumerating WineD3DFormat %d\n", FormatList
[i
]);
1128 hr
= Callback(&pformat
, Arg
);
1129 if(hr
!= DDENUMRET_OK
)
1131 TRACE("Format enumeration cancelled by application\n");
1136 TRACE("End of enumeration\n");
1140 static HRESULT WINAPI
1141 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats(IDirect3DDevice3
*iface
,
1142 LPD3DENUMPIXELFORMATSCALLBACK Callback
,
1145 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1146 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice7 interface.\n", This
, Callback
, Arg
);
1147 return IDirect3DDevice7_EnumTextureFormats(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1152 /*****************************************************************************
1153 * IDirect3DDevice2::EnumTextureformats
1155 * EnumTextureFormats for Version 1 and 2, see
1156 * IDirect3DDevice7::EnumTexureFormats for a more detailed description.
1158 * This version has a different callback and does not enumerate FourCC
1161 *****************************************************************************/
1162 static HRESULT WINAPI
1163 IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2
*iface
,
1164 LPD3DENUMTEXTUREFORMATSCALLBACK Callback
,
1167 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1171 WINED3DFORMAT FormatList
[] = {
1173 WINED3DFMT_A8R8G8B8
,
1174 WINED3DFMT_X8R8G8B8
,
1178 WINED3DFMT_A1R5G5B5
,
1179 WINED3DFMT_A4R4G4B4
,
1181 WINED3DFMT_X1R5G5B5
,
1185 /* FOURCC codes - Not in this version*/
1188 TRACE("(%p)->(%p,%p): Relay\n", This
, Callback
, Arg
);
1191 return DDERR_INVALIDPARAMS
;
1193 for(i
= 0; i
< sizeof(FormatList
) / sizeof(WINED3DFORMAT
); i
++)
1195 hr
= IWineD3D_CheckDeviceFormat(This
->ddraw
->wineD3D
,
1198 0 /* AdapterFormat */,
1200 0 /* ResourceType */,
1204 DDSURFACEDESC sdesc
;
1206 memset(&sdesc
, 0, sizeof(sdesc
));
1207 sdesc
.dwSize
= sizeof(sdesc
);
1208 sdesc
.dwFlags
= DDSD_PIXELFORMAT
| DDSD_CAPS
;
1209 sdesc
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
;
1210 sdesc
.ddpfPixelFormat
.dwSize
= sizeof(sdesc
.ddpfPixelFormat
.dwSize
);
1211 PixelFormat_WineD3DtoDD(&sdesc
.ddpfPixelFormat
, FormatList
[i
]);
1213 TRACE("Enumerating WineD3DFormat %d\n", FormatList
[i
]);
1214 hr
= Callback(&sdesc
, Arg
);
1215 if(hr
!= DDENUMRET_OK
)
1217 TRACE("Format enumeration cancelled by application\n");
1222 TRACE("End of enumeration\n");
1226 static HRESULT WINAPI
1227 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats(IDirect3DDevice
*iface
,
1228 LPD3DENUMTEXTUREFORMATSCALLBACK Callback
,
1231 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1232 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", This
, Callback
, Arg
);
1233 return IDirect3DDevice2_EnumTextureFormats(ICOM_INTERFACE(This
, IDirect3DDevice2
),
1238 /*****************************************************************************
1239 * IDirect3DDevice::CreateMatrix
1241 * Creates a matrix handle. A handle is created and memory for a D3DMATRIX is
1242 * allocated for the handle.
1247 * D3DMatHandle: Address to return the handle at
1251 * DDERR_INVALIDPARAMS if D3DMatHandle = NULL
1253 *****************************************************************************/
1254 static HRESULT WINAPI
1255 IDirect3DDeviceImpl_1_CreateMatrix(IDirect3DDevice
*iface
, D3DMATRIXHANDLE
*D3DMatHandle
)
1257 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1259 TRACE("(%p)->(%p)\n", This
, D3DMatHandle
);
1262 return DDERR_INVALIDPARAMS
;
1264 Matrix
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(D3DMATRIX
));
1267 ERR("Out of memory when allocating a D3DMATRIX\n");
1268 return DDERR_OUTOFMEMORY
;
1270 *D3DMatHandle
= IDirect3DDeviceImpl_CreateHandle(This
);
1271 if(!(*D3DMatHandle
))
1273 ERR("Failed to create a matrix handle\n");
1274 HeapFree(GetProcessHeap(), 0, Matrix
);
1275 return DDERR_OUTOFMEMORY
;
1277 This
->Handles
[(DWORD
) *D3DMatHandle
- 1].ptr
= Matrix
;
1278 This
->Handles
[(DWORD
) *D3DMatHandle
- 1].type
= DDrawHandle_Matrix
;
1279 TRACE(" returning matrix handle %d\n", *D3DMatHandle
);
1284 /*****************************************************************************
1285 * IDirect3DDevice::SetMatrix
1287 * Sets a matrix for a matrix handle. The matrix is copied into the memory
1288 * allocated for the handle
1293 * D3DMatHandle: Handle to set the matrix to
1294 * D3DMatrix: Matrix to set
1298 * DDERR_INVALIDPARAMS if the handle of the matrix is invalid or the matrix
1301 *****************************************************************************/
1302 static HRESULT WINAPI
1303 IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice
*iface
,
1304 D3DMATRIXHANDLE D3DMatHandle
,
1305 D3DMATRIX
*D3DMatrix
)
1307 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1308 TRACE("(%p)->(%08x,%p)\n", This
, (DWORD
) D3DMatHandle
, D3DMatrix
);
1310 if( (!D3DMatHandle
) || (!D3DMatrix
) )
1311 return DDERR_INVALIDPARAMS
;
1313 if(D3DMatHandle
> This
->numHandles
)
1315 ERR("Handle %d out of range\n", D3DMatHandle
);
1316 return DDERR_INVALIDPARAMS
;
1318 else if(This
->Handles
[D3DMatHandle
- 1].type
!= DDrawHandle_Matrix
)
1320 ERR("Handle %d is not a matrix handle\n", D3DMatHandle
);
1321 return DDERR_INVALIDPARAMS
;
1325 dump_D3DMATRIX(D3DMatrix
);
1327 *((D3DMATRIX
*) This
->Handles
[D3DMatHandle
- 1].ptr
) = *D3DMatrix
;
1332 /*****************************************************************************
1333 * IDirect3DDevice::SetMatrix
1335 * Returns the content of a D3DMATRIX handle
1340 * D3DMatHandle: Matrix handle to read the content from
1341 * D3DMatrix: Address to store the content at
1345 * DDERR_INVALIDPARAMS if D3DMatHandle is invalid or D3DMatrix is NULL
1347 *****************************************************************************/
1348 static HRESULT WINAPI
1349 IDirect3DDeviceImpl_1_GetMatrix(IDirect3DDevice
*iface
,
1350 D3DMATRIXHANDLE D3DMatHandle
,
1351 D3DMATRIX
*D3DMatrix
)
1353 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1354 TRACE("(%p)->(%08x,%p)\n", This
, (DWORD
) D3DMatHandle
, D3DMatrix
);
1357 return DDERR_INVALIDPARAMS
;
1359 return DDERR_INVALIDPARAMS
;
1361 if(D3DMatHandle
> This
->numHandles
)
1363 ERR("Handle %d out of range\n", D3DMatHandle
);
1364 return DDERR_INVALIDPARAMS
;
1366 else if(This
->Handles
[D3DMatHandle
- 1].type
!= DDrawHandle_Matrix
)
1368 ERR("Handle %d is not a matrix handle\n", D3DMatHandle
);
1369 return DDERR_INVALIDPARAMS
;
1372 /* The handle is simply a pointer to a D3DMATRIX structure */
1373 *D3DMatrix
= *((D3DMATRIX
*) This
->Handles
[D3DMatHandle
- 1].ptr
);
1378 /*****************************************************************************
1379 * IDirect3DDevice::DeleteMatrix
1381 * Destroys a Matrix handle. Frees the memory and unsets the handle data
1386 * D3DMatHandle: Handle to destroy
1390 * DDERR_INVALIDPARAMS if D3DMatHandle is invalid
1392 *****************************************************************************/
1393 static HRESULT WINAPI
1394 IDirect3DDeviceImpl_1_DeleteMatrix(IDirect3DDevice
*iface
,
1395 D3DMATRIXHANDLE D3DMatHandle
)
1397 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1398 TRACE("(%p)->(%08x)\n", This
, (DWORD
) D3DMatHandle
);
1401 return DDERR_INVALIDPARAMS
;
1403 if(D3DMatHandle
> This
->numHandles
)
1405 ERR("Handle %d out of range\n", D3DMatHandle
);
1406 return DDERR_INVALIDPARAMS
;
1408 else if(This
->Handles
[D3DMatHandle
- 1].type
!= DDrawHandle_Matrix
)
1410 ERR("Handle %d is not a matrix handle\n", D3DMatHandle
);
1411 return DDERR_INVALIDPARAMS
;
1414 HeapFree(GetProcessHeap(), 0, This
->Handles
[D3DMatHandle
- 1].ptr
);
1415 This
->Handles
[D3DMatHandle
- 1].ptr
= NULL
;
1416 This
->Handles
[D3DMatHandle
- 1].type
= DDrawHandle_Unknown
;
1421 /*****************************************************************************
1422 * IDirect3DDevice7::BeginScene
1424 * This method must be called before any rendering is performed.
1425 * IDirect3DDevice::EndScene has to be called after the scene is complete
1427 * Version 1, 2, 3 and 7
1430 * D3D_OK on success, for details see IWineD3DDevice::BeginScene
1432 *****************************************************************************/
1433 static HRESULT WINAPI
1434 IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7
*iface
)
1436 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1437 TRACE("(%p): Relay\n", This
);
1439 return IWineD3DDevice_BeginScene(This
->wineD3DDevice
);
1442 static HRESULT WINAPI
1443 Thunk_IDirect3DDeviceImpl_3_BeginScene(IDirect3DDevice3
*iface
)
1445 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1446 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1447 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1450 static HRESULT WINAPI
1451 Thunk_IDirect3DDeviceImpl_2_BeginScene(IDirect3DDevice2
*iface
)
1453 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1454 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1455 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1458 static HRESULT WINAPI
1459 Thunk_IDirect3DDeviceImpl_1_BeginScene(IDirect3DDevice
*iface
)
1461 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1462 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1463 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1466 /*****************************************************************************
1467 * IDirect3DDevice7::EndScene
1469 * Ends a scene that has been begun with IDirect3DDevice7::BeginScene.
1470 * This method must be called after rendering is finished.
1472 * Version 1, 2, 3 and 7
1475 * D3D_OK on success, for details see IWineD3DDevice::EndScene
1477 *****************************************************************************/
1478 static HRESULT WINAPI
1479 IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7
*iface
)
1481 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1482 TRACE("(%p): Relay\n", This
);
1484 IWineD3DDevice_EndScene(This
->wineD3DDevice
);
1488 static HRESULT WINAPI
1489 Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3
*iface
)
1491 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1492 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1493 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1496 static HRESULT WINAPI
1497 Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2
*iface
)
1499 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1500 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1501 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1504 static HRESULT WINAPI
1505 Thunk_IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice
*iface
)
1507 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1508 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1509 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1512 /*****************************************************************************
1513 * IDirect3DDevice7::GetDirect3D
1515 * Returns the IDirect3D(= interface to the DirectDraw object) used to create
1519 * Direct3D7: Address to store the interface pointer at
1523 * DDERR_INVALIDPARAMS if Direct3D7 == NULL
1525 *****************************************************************************/
1526 static HRESULT WINAPI
1527 IDirect3DDeviceImpl_7_GetDirect3D(IDirect3DDevice7
*iface
,
1528 IDirect3D7
**Direct3D7
)
1530 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1531 TRACE("(%p)->(%p)\n", This
, Direct3D7
);
1534 return DDERR_INVALIDPARAMS
;
1536 *Direct3D7
= ICOM_INTERFACE(This
->ddraw
, IDirect3D7
);
1537 IDirect3D7_AddRef(*Direct3D7
);
1539 TRACE(" returning interface %p\n", *Direct3D7
);
1543 static HRESULT WINAPI
1544 Thunk_IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3
*iface
,
1545 IDirect3D3
**Direct3D3
)
1547 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1549 IDirect3D7
*ret_ptr
;
1551 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D3
);
1552 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1556 *Direct3D3
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D3
, ret_ptr
);
1557 TRACE(" returning interface %p\n", *Direct3D3
);
1561 static HRESULT WINAPI
1562 Thunk_IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2
*iface
,
1563 IDirect3D2
**Direct3D2
)
1565 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1567 IDirect3D7
*ret_ptr
;
1569 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D2
);
1570 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1574 *Direct3D2
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D2
, ret_ptr
);
1575 TRACE(" returning interface %p\n", *Direct3D2
);
1579 static HRESULT WINAPI
1580 Thunk_IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice
*iface
,
1581 IDirect3D
**Direct3D
)
1583 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1585 IDirect3D7
*ret_ptr
;
1587 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D
);
1588 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1592 *Direct3D
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D
, ret_ptr
);
1593 TRACE(" returning interface %p\n", *Direct3D
);
1597 /*****************************************************************************
1598 * IDirect3DDevice3::SetCurrentViewport
1600 * Sets a Direct3DViewport as the current viewport.
1601 * For the thunks note that all viewport interface versions are equal
1604 * Direct3DViewport3: The viewport to set
1610 * (Is a NULL viewport valid?)
1612 *****************************************************************************/
1613 static HRESULT WINAPI
1614 IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3
*iface
,
1615 IDirect3DViewport3
*Direct3DViewport3
)
1617 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1618 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport3
);
1619 TRACE("(%p)->(%p)\n", This
, Direct3DViewport3
);
1621 /* Do nothing if the specified viewport is the same as the current one */
1622 if (This
->current_viewport
== vp
)
1625 /* Should check if the viewport was added or not */
1627 /* Release previous viewport and AddRef the new one */
1628 if (This
->current_viewport
)
1630 TRACE("ViewportImpl is at %p, interface is at %p\n", This
->current_viewport
, ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
));
1631 IDirect3DViewport3_Release( ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
) );
1633 IDirect3DViewport3_AddRef(Direct3DViewport3
);
1635 /* Set this viewport as the current viewport */
1636 This
->current_viewport
= vp
;
1638 /* Activate this viewport */
1639 This
->current_viewport
->active_device
= This
;
1640 This
->current_viewport
->activate(This
->current_viewport
);
1645 static HRESULT WINAPI
1646 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2
*iface
,
1647 IDirect3DViewport2
*Direct3DViewport2
)
1649 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1650 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
1651 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
1652 return IDirect3DDevice3_SetCurrentViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1653 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
1656 /*****************************************************************************
1657 * IDirect3DDevice3::GetCurrentViewport
1659 * Returns the currently active viewport.
1664 * Direct3DViewport3: Address to return the interface pointer at
1668 * DDERR_INVALIDPARAMS if Direct3DViewport == NULL
1670 *****************************************************************************/
1671 static HRESULT WINAPI
1672 IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3
*iface
,
1673 IDirect3DViewport3
**Direct3DViewport3
)
1675 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1676 TRACE("(%p)->(%p)\n", This
, Direct3DViewport3
);
1678 if(!Direct3DViewport3
)
1679 return DDERR_INVALIDPARAMS
;
1681 *Direct3DViewport3
= ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
);
1683 /* AddRef the returned viewport */
1684 if(*Direct3DViewport3
) IDirect3DViewport3_AddRef(*Direct3DViewport3
);
1686 TRACE(" returning interface %p\n", *Direct3DViewport3
);
1691 static HRESULT WINAPI
1692 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(IDirect3DDevice2
*iface
,
1693 IDirect3DViewport2
**Direct3DViewport2
)
1695 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1697 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Direct3DViewport2
);
1698 hr
= IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1699 (IDirect3DViewport3
**) Direct3DViewport2
);
1700 if(hr
!= D3D_OK
) return hr
;
1701 *Direct3DViewport2
= (IDirect3DViewport2
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, *Direct3DViewport2
);
1705 /*****************************************************************************
1706 * IDirect3DDevice7::SetRenderTarget
1708 * Sets the render target for the Direct3DDevice.
1709 * For the thunks note that IDirectDrawSurface7 == IDirectDrawSurface4 and
1710 * IDirectDrawSurface3 == IDirectDrawSurface
1712 * Version 2, 3 and 7
1715 * NewTarget: Pointer to an IDirectDrawSurface7 interface to set as the new
1720 * D3D_OK on success, for details see IWineD3DDevice::SetRenderTarget
1722 *****************************************************************************/
1723 static HRESULT WINAPI
1724 IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7
*iface
,
1725 IDirectDrawSurface7
*NewTarget
,
1728 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1729 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, NewTarget
);
1730 TRACE("(%p)->(%p,%08x): Relay\n", This
, NewTarget
, Flags
);
1732 /* Flags: Not used */
1734 return IWineD3DDevice_SetRenderTarget(This
->wineD3DDevice
,
1736 Target
? Target
->WineD3DSurface
: NULL
);
1739 static HRESULT WINAPI
1740 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3
*iface
,
1741 IDirectDrawSurface4
*NewRenderTarget
,
1744 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1745 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, NewRenderTarget
);
1746 TRACE_(ddraw_thunk
)("(%p)->(%p,%08x) thunking to IDirect3DDevice7 interface.\n", This
, Target
, Flags
);
1747 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1748 ICOM_INTERFACE(Target
, IDirectDrawSurface7
),
1752 static HRESULT WINAPI
1753 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2
*iface
,
1754 IDirectDrawSurface
*NewRenderTarget
,
1757 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1758 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface3
, NewRenderTarget
);
1759 TRACE_(ddraw_thunk
)("(%p)->(%p,%08x) thunking to IDirect3DDevice7 interface.\n", This
, Target
, Flags
);
1760 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1761 ICOM_INTERFACE(Target
, IDirectDrawSurface7
),
1765 /*****************************************************************************
1766 * IDirect3DDevice7::GetRenderTarget
1768 * Returns the current render target.
1769 * This is handled locally, because the WineD3D render target's parent
1772 * Version 2, 3 and 7
1775 * RenderTarget: Address to store the surface interface pointer
1779 * DDERR_INVALIDPARAMS if RenderTarget == NULL
1781 *****************************************************************************/
1782 static HRESULT WINAPI
1783 IDirect3DDeviceImpl_7_GetRenderTarget(IDirect3DDevice7
*iface
,
1784 IDirectDrawSurface7
**RenderTarget
)
1786 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1787 TRACE("(%p)->(%p): Relay\n", This
, RenderTarget
);
1790 return DDERR_INVALIDPARAMS
;
1792 *RenderTarget
= ICOM_INTERFACE(This
->target
, IDirectDrawSurface7
);
1793 IDirectDrawSurface7_AddRef(*RenderTarget
);
1798 static HRESULT WINAPI
1799 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3
*iface
,
1800 IDirectDrawSurface4
**RenderTarget
)
1802 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, 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
= (IDirectDrawSurface4
*) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirectDrawSurface7
, *RenderTarget
);
1812 static HRESULT WINAPI
1813 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(IDirect3DDevice2
*iface
,
1814 IDirectDrawSurface
**RenderTarget
)
1816 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1818 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, RenderTarget
);
1819 hr
= IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1820 (IDirectDrawSurface7
**) RenderTarget
);
1821 if(hr
!= D3D_OK
) return hr
;
1822 *RenderTarget
= (IDirectDrawSurface
*) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirectDrawSurface3
, *RenderTarget
);
1826 /*****************************************************************************
1827 * IDirect3DDevice3::Begin
1829 * Begins a description block of vertices. This is similar to glBegin()
1830 * and glEnd(). After a call to IDirect3DDevice3::End, the vertices
1831 * described with IDirect3DDevice::Vertex are drawn.
1836 * PrimitiveType: The type of primitives to draw
1837 * VertexTypeDesc: A flexible vertex format description of the vertices
1838 * Flags: Some flags..
1843 *****************************************************************************/
1844 static HRESULT WINAPI
1845 IDirect3DDeviceImpl_3_Begin(IDirect3DDevice3
*iface
,
1846 D3DPRIMITIVETYPE PrimitiveType
,
1847 DWORD VertexTypeDesc
,
1850 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1851 TRACE("(%p)->(%d,%d,%08x)\n", This
, PrimitiveType
, VertexTypeDesc
, Flags
);
1853 This
->primitive_type
= PrimitiveType
;
1854 This
->vertex_type
= VertexTypeDesc
;
1855 This
->render_flags
= Flags
;
1856 This
->vertex_size
= get_flexible_vertex_size(This
->vertex_type
);
1857 This
->nb_vertices
= 0;
1862 static HRESULT WINAPI
1863 Thunk_IDirect3DDeviceImpl_2_Begin(IDirect3DDevice2
*iface
,
1864 D3DPRIMITIVETYPE d3dpt
,
1865 D3DVERTEXTYPE dwVertexTypeDesc
,
1869 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1870 TRACE_(ddraw_thunk
)("(%p/%p)->(%08x,%08x,%08x): Thunking to IDirect3DDevice3\n", This
, iface
, d3dpt
, dwVertexTypeDesc
, dwFlags
);
1872 switch(dwVertexTypeDesc
)
1874 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
1875 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
1876 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
1878 ERR("Unexpected vertex type %d\n", dwVertexTypeDesc
);
1879 return DDERR_INVALIDPARAMS
; /* Should never happen */
1882 return IDirect3DDevice3_Begin(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1888 /*****************************************************************************
1889 * IDirect3DDevice3::BeginIndexed
1891 * Draws primitives based on vertices in a vertex array which are specified
1897 * PrimitiveType: Primitive type to draw
1898 * VertexType: A FVF description of the vertex format
1899 * Vertices: pointer to an array containing the vertices
1900 * NumVertices: The number of vertices in the vertex array
1901 * Flags: Some flags ...
1904 * D3D_OK, because it's a stub
1906 *****************************************************************************/
1907 static HRESULT WINAPI
1908 IDirect3DDeviceImpl_3_BeginIndexed(IDirect3DDevice3
*iface
,
1909 D3DPRIMITIVETYPE PrimitiveType
,
1915 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1916 FIXME("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This
, PrimitiveType
, VertexType
, Vertices
, NumVertices
, Flags
);
1921 static HRESULT WINAPI
1922 Thunk_IDirect3DDeviceImpl_2_BeginIndexed(IDirect3DDevice2
*iface
,
1923 D3DPRIMITIVETYPE d3dptPrimitiveType
,
1924 D3DVERTEXTYPE d3dvtVertexType
,
1926 DWORD dwNumVertices
,
1930 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1931 TRACE_(ddraw_thunk
)("(%p/%p)->(%08x,%08x,%p,%08x,%08x): Thunking to IDirect3DDevice3\n", This
, iface
, d3dptPrimitiveType
, d3dvtVertexType
, lpvVertices
, dwNumVertices
, dwFlags
);
1933 switch(d3dvtVertexType
)
1935 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
1936 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
1937 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
1939 ERR("Unexpected vertex type %d\n", d3dvtVertexType
);
1940 return DDERR_INVALIDPARAMS
; /* Should never happen */
1943 return IDirect3DDevice3_BeginIndexed(ICOM_INTERFACE(This
,IDirect3DDevice3
),
1951 /*****************************************************************************
1952 * IDirect3DDevice3::Vertex
1954 * Draws a vertex as described by IDirect3DDevice3::Begin. It places all
1955 * drawn vertices in a vertex buffer. If the buffer is too small, its
1956 * size is increased.
1961 * Vertex: Pointer to the vertex
1964 * D3D_OK, on success
1965 * DDERR_INVALIDPARAMS if Vertex is NULL
1967 *****************************************************************************/
1968 static HRESULT WINAPI
1969 IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3
*iface
,
1972 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1973 TRACE("(%p)->(%p)\n", This
, Vertex
);
1976 return DDERR_INVALIDPARAMS
;
1978 if ((This
->nb_vertices
+1)*This
->vertex_size
> This
->buffer_size
)
1981 This
->buffer_size
= This
->buffer_size
? This
->buffer_size
* 2 : This
->vertex_size
* 3;
1982 old_buffer
= This
->vertex_buffer
;
1983 This
->vertex_buffer
= HeapAlloc(GetProcessHeap(), 0, This
->buffer_size
);
1986 CopyMemory(This
->vertex_buffer
, old_buffer
, This
->nb_vertices
* This
->vertex_size
);
1987 HeapFree(GetProcessHeap(), 0, old_buffer
);
1991 CopyMemory(This
->vertex_buffer
+ This
->nb_vertices
++ * This
->vertex_size
, Vertex
, This
->vertex_size
);
1996 static HRESULT WINAPI
1997 Thunk_IDirect3DDeviceImpl_2_Vertex(IDirect3DDevice2
*iface
,
2000 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2001 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, lpVertexType
);
2002 return IDirect3DDevice3_Vertex(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2006 /*****************************************************************************
2007 * IDirect3DDevice3::Index
2009 * Specifies an index to a vertex to be drawn. The vertex array has to
2010 * be specified with BeginIndexed first.
2013 * VertexIndex: The index of the vertex to draw
2016 * D3D_OK because it's a stub
2018 *****************************************************************************/
2019 static HRESULT WINAPI
2020 IDirect3DDeviceImpl_3_Index(IDirect3DDevice3
*iface
,
2023 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2024 FIXME("(%p)->(%04x): stub!\n", This
, VertexIndex
);
2028 static HRESULT WINAPI
2029 Thunk_IDirect3DDeviceImpl_2_Index(IDirect3DDevice2
*iface
,
2032 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2033 TRACE_(ddraw_thunk
)("(%p)->(%04x) thunking to IDirect3DDevice3 interface.\n", This
, wVertexIndex
);
2034 return IDirect3DDevice3_Index(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2038 /*****************************************************************************
2039 * IDirect3DDevice3::End
2041 * Ends a draw begun with IDirect3DDevice3::Begin or
2042 * IDirect3DDevice::BeginIndexed. The vertices specified with
2043 * IDirect3DDevice::Vertex or IDirect3DDevice::Index are drawn using
2044 * the IDirect3DDevice7::DrawPrimitive method. So far only
2045 * non-indexed mode is supported
2050 * Flags: Some flags, as usual. Don't know which are defined
2053 * The return value of IDirect3DDevice7::DrawPrimitive
2055 *****************************************************************************/
2056 static HRESULT WINAPI
2057 IDirect3DDeviceImpl_3_End(IDirect3DDevice3
*iface
,
2060 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2061 TRACE("(%p)->(%08x)\n", This
, Flags
);
2063 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2064 This
->primitive_type
, This
->vertex_type
,
2065 This
->vertex_buffer
, This
->nb_vertices
,
2066 This
->render_flags
);
2069 static HRESULT WINAPI
2070 Thunk_IDirect3DDeviceImpl_2_End(IDirect3DDevice2
*iface
,
2073 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2074 TRACE_(ddraw_thunk
)("(%p)->(%08x) thunking to IDirect3DDevice3 interface.\n", This
, dwFlags
);
2075 return IDirect3DDevice3_End(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2079 /*****************************************************************************
2080 * IDirect3DDevice7::GetRenderState
2082 * Returns the value of a render state. The possible render states are
2083 * defined in include/d3dtypes.h
2085 * Version 2, 3 and 7
2088 * RenderStateType: Render state to return the current setting of
2089 * Value: Address to store the value at
2092 * D3D_OK on success, for details see IWineD3DDevice::GetRenderState
2093 * DDERR_INVALIDPARAMS if Value == NULL
2095 *****************************************************************************/
2096 static HRESULT WINAPI
2097 IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7
*iface
,
2098 D3DRENDERSTATETYPE RenderStateType
,
2101 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2103 TRACE("(%p)->(%08x,%p): Relay\n", This
, RenderStateType
, Value
);
2106 return DDERR_INVALIDPARAMS
;
2108 switch(RenderStateType
)
2110 case D3DRENDERSTATE_TEXTUREHANDLE
:
2112 /* This state is wrapped to SetTexture in SetRenderState, so
2113 * it has to be wrapped to GetTexture here
2115 IWineD3DBaseTexture
*tex
= NULL
;
2118 hr
= IWineD3DDevice_GetTexture(This
->wineD3DDevice
,
2122 if(hr
== WINED3D_OK
&& tex
)
2124 IDirectDrawSurface7
*parent
= NULL
;
2125 hr
= IWineD3DBaseTexture_GetParent(tex
,
2126 (IUnknown
**) &parent
);
2129 /* The parent of the texture is the IDirectDrawSurface7 interface
2130 * of the ddraw surface
2132 IDirectDrawSurfaceImpl
*texImpl
= ICOM_OBJECT(IDirectDrawSurfaceImpl
,
2133 IDirectDrawSurface7
,
2135 *Value
= texImpl
->Handle
;
2136 IDirectDrawSurface7_Release(parent
);
2138 IWineD3DBaseTexture_Release(tex
);
2143 case D3DRENDERSTATE_TEXTUREMAG
:
2145 WINED3DTEXTUREFILTERTYPE tex_mag
;
2147 hr
= IWineD3DDevice_GetSamplerState(This
->wineD3DDevice
,
2148 0, WINED3DSAMP_MAGFILTER
,
2153 case WINED3DTEXF_POINT
:
2154 *Value
= D3DFILTER_NEAREST
;
2156 case WINED3DTEXF_LINEAR
:
2157 *Value
= D3DFILTER_LINEAR
;
2160 ERR("Unhandled texture mag %d !\n",tex_mag
);
2166 case D3DRENDERSTATE_TEXTUREMIN
:
2168 WINED3DTEXTUREFILTERTYPE tex_min
;
2170 hr
= IWineD3DDevice_GetSamplerState(This
->wineD3DDevice
,
2171 0, WINED3DSAMP_MINFILTER
,
2176 case WINED3DTEXF_POINT
:
2177 *Value
= D3DFILTER_NEAREST
;
2179 case WINED3DTEXF_LINEAR
:
2180 *Value
= D3DFILTER_LINEAR
;
2183 ERR("Unhandled texture mag %d !\n",tex_min
);
2189 case D3DRENDERSTATE_TEXTUREADDRESSU
:
2190 case D3DRENDERSTATE_TEXTUREADDRESSV
:
2191 case D3DRENDERSTATE_TEXTUREADDRESS
:
2193 WINED3DTEXTURESTAGESTATETYPE TexStageStateType
;
2195 if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESS
)
2197 TexStageStateType
= WINED3DTSS_ADDRESS
;
2199 else if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESSU
)
2201 TexStageStateType
= WINED3DTSS_ADDRESSU
;
2205 TexStageStateType
= WINED3DTSS_ADDRESSV
;
2207 return IWineD3DDevice_GetTextureStageState(This
->wineD3DDevice
,
2208 0, TexStageStateType
,
2213 /* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
2214 return IWineD3DDevice_GetRenderState(This
->wineD3DDevice
,
2220 static HRESULT WINAPI
2221 Thunk_IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3
*iface
,
2222 D3DRENDERSTATETYPE dwRenderStateType
,
2223 DWORD
*lpdwRenderState
)
2225 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2226 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, dwRenderStateType
, lpdwRenderState
);
2227 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2232 static HRESULT WINAPI
2233 Thunk_IDirect3DDeviceImpl_2_GetRenderState(IDirect3DDevice2
*iface
,
2234 D3DRENDERSTATETYPE dwRenderStateType
,
2235 DWORD
*lpdwRenderState
)
2237 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2238 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, dwRenderStateType
, lpdwRenderState
);
2239 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2244 /*****************************************************************************
2245 * IDirect3DDevice7::SetRenderState
2247 * Sets a render state. The possible render states are defined in
2248 * include/d3dtypes.h
2250 * Version 2, 3 and 7
2253 * RenderStateType: State to set
2254 * Value: Value to assign to that state
2257 * D3D_OK on success,
2258 * for details see IWineD3DDevice::SetRenderState
2260 *****************************************************************************/
2261 static HRESULT WINAPI
2262 IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7
*iface
,
2263 D3DRENDERSTATETYPE RenderStateType
,
2266 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2267 TRACE("(%p)->(%08x,%d): Relay\n", This
, RenderStateType
, Value
);
2269 /* Some render states need special care */
2270 switch(RenderStateType
)
2272 case D3DRENDERSTATE_TEXTUREHANDLE
:
2276 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
2281 if(Value
> This
->numHandles
)
2283 FIXME("Specified handle %d out of range\n", Value
);
2284 return DDERR_INVALIDPARAMS
;
2286 if(This
->Handles
[Value
- 1].type
!= DDrawHandle_Texture
)
2288 FIXME("Handle %d isn't a texture handle\n", Value
);
2289 return DDERR_INVALIDPARAMS
;
2293 IDirectDrawSurfaceImpl
*surf
= (IDirectDrawSurfaceImpl
*) This
->Handles
[Value
- 1].ptr
;
2294 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
2296 (IWineD3DBaseTexture
*) surf
->wineD3DTexture
);
2300 case D3DRENDERSTATE_TEXTUREMAG
:
2302 WINED3DTEXTUREFILTERTYPE tex_mag
= WINED3DTEXF_NONE
;
2304 switch ((D3DTEXTUREFILTER
) Value
)
2306 case D3DFILTER_NEAREST
:
2307 tex_mag
= WINED3DTEXF_POINT
;
2309 case D3DFILTER_LINEAR
:
2310 tex_mag
= WINED3DTEXF_LINEAR
;
2313 ERR("Unhandled texture mag %d !\n",Value
);
2316 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
2317 0, WINED3DSAMP_MAGFILTER
,
2321 case D3DRENDERSTATE_TEXTUREMIN
:
2323 WINED3DTEXTUREFILTERTYPE tex_min
= WINED3DTEXF_NONE
;
2325 switch ((D3DTEXTUREFILTER
) Value
)
2327 case D3DFILTER_NEAREST
:
2328 tex_min
= WINED3DTEXF_POINT
;
2330 case D3DFILTER_LINEAR
:
2331 tex_min
= WINED3DTEXF_LINEAR
;
2334 ERR("Unhandled texture mag %d !\n",Value
);
2337 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
2338 0, WINED3DSAMP_MINFILTER
,
2342 case D3DRENDERSTATE_TEXTUREADDRESSU
:
2343 case D3DRENDERSTATE_TEXTUREADDRESSV
:
2344 case D3DRENDERSTATE_TEXTUREADDRESS
:
2346 WINED3DTEXTURESTAGESTATETYPE TexStageStateType
;
2348 if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESS
)
2350 TexStageStateType
= WINED3DTSS_ADDRESS
;
2352 else if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESSU
)
2354 TexStageStateType
= WINED3DTSS_ADDRESSU
;
2358 TexStageStateType
= WINED3DTSS_ADDRESSV
;
2361 return IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
,
2362 0, TexStageStateType
,
2366 case D3DRENDERSTATE_TEXTUREMAPBLEND
:
2368 /* Old texture combine setup style, superseded by texture stage states
2369 * in D3D7. It is safe for us to wrap it to texture stage states.
2371 switch ( (D3DTEXTUREBLEND
) Value
)
2373 case D3DTBLEND_MODULATE
:
2374 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLORARG1
, WINED3DTA_TEXTURE
);
2375 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG1
, WINED3DTA_TEXTURE
);
2376 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLORARG2
, WINED3DTA_CURRENT
);
2377 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLOROP
, WINED3DTOP_MODULATE
);
2378 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAOP
, WINED3DTOP_SELECTARG1
);
2381 case D3DTBLEND_MODULATEALPHA
:
2382 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLORARG1
, WINED3DTA_TEXTURE
);
2383 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG1
, WINED3DTA_TEXTURE
);
2384 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLORARG2
, WINED3DTA_CURRENT
);
2385 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG2
, WINED3DTA_CURRENT
);
2386 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLOROP
, WINED3DTOP_MODULATE
);
2387 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAOP
, WINED3DTOP_MODULATE
);
2390 case D3DTBLEND_DECAL
:
2391 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLORARG1
, WINED3DTA_TEXTURE
);
2392 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG1
, WINED3DTA_TEXTURE
);
2393 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLOROP
, WINED3DTOP_SELECTARG1
);
2394 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAOP
, WINED3DTOP_SELECTARG1
);
2397 case D3DTBLEND_DECALALPHA
:
2398 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLORARG1
, WINED3DTA_TEXTURE
);
2399 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG1
, WINED3DTA_TEXTURE
);
2400 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG2
, WINED3DTA_CURRENT
);
2401 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLOROP
, WINED3DTOP_SELECTARG1
);
2402 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAOP
, WINED3DTOP_MODULATE
);
2406 ERR("Unhandled texture environment %d !\n",Value
);
2414 /* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
2416 return IWineD3DDevice_SetRenderState(This
->wineD3DDevice
,
2422 static HRESULT WINAPI
2423 Thunk_IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3
*iface
,
2424 D3DRENDERSTATETYPE RenderStateType
,
2427 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2428 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, RenderStateType
, Value
);
2429 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2434 static HRESULT WINAPI
2435 Thunk_IDirect3DDeviceImpl_2_SetRenderState(IDirect3DDevice2
*iface
,
2436 D3DRENDERSTATETYPE RenderStateType
,
2439 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2440 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, RenderStateType
, Value
);
2441 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2446 /*****************************************************************************
2447 * Direct3DDevice3::SetLightState
2449 * Sets a light state for Direct3DDevice3 and Direct3DDevice2. The
2450 * light states are forwarded to Direct3DDevice7 render states
2455 * LightStateType: The light state to change
2456 * Value: The value to assign to that light state
2460 * DDERR_INVALIDPARAMS if the parameters were incorrect
2461 * Also check IDirect3DDevice7::SetRenderState
2463 *****************************************************************************/
2464 static HRESULT WINAPI
2465 IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3
*iface
,
2466 D3DLIGHTSTATETYPE LightStateType
,
2469 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2471 TRACE("(%p)->(%08x,%08x)\n", This
, LightStateType
, Value
);
2473 if (!LightStateType
&& (LightStateType
> D3DLIGHTSTATE_COLORVERTEX
))
2475 TRACE("Unexpected Light State Type\n");
2476 return DDERR_INVALIDPARAMS
;
2479 if (LightStateType
== D3DLIGHTSTATE_MATERIAL
/* 1 */)
2481 IDirect3DMaterialImpl
*mat
;
2483 if(Value
== 0) mat
= NULL
;
2484 else if(Value
> This
->numHandles
)
2486 ERR("Material handle out of range(%d)\n", Value
);
2487 return DDERR_INVALIDPARAMS
;
2489 else if(This
->Handles
[Value
- 1].type
!= DDrawHandle_Material
)
2491 ERR("Invalid handle %d\n", Value
);
2492 return DDERR_INVALIDPARAMS
;
2496 mat
= (IDirect3DMaterialImpl
*) This
->Handles
[Value
- 1].ptr
;
2501 TRACE(" activating material %p.\n", mat
);
2506 FIXME(" D3DLIGHTSTATE_MATERIAL called with NULL material !!!\n");
2508 This
->material
= Value
;
2510 else if (LightStateType
== D3DLIGHTSTATE_COLORMODEL
/* 3 */)
2515 ERR("DDCOLOR_MONO should not happen!\n");
2518 /* We are already in this mode */
2519 TRACE("Setting color model to RGB (no-op).\n");
2522 ERR("Unknown color model!\n");
2523 return DDERR_INVALIDPARAMS
;
2528 D3DRENDERSTATETYPE rs
;
2529 switch (LightStateType
)
2531 case D3DLIGHTSTATE_AMBIENT
: /* 2 */
2532 rs
= D3DRENDERSTATE_AMBIENT
;
2534 case D3DLIGHTSTATE_FOGMODE
: /* 4 */
2535 rs
= D3DRENDERSTATE_FOGVERTEXMODE
;
2537 case D3DLIGHTSTATE_FOGSTART
: /* 5 */
2538 rs
= D3DRENDERSTATE_FOGSTART
;
2540 case D3DLIGHTSTATE_FOGEND
: /* 6 */
2541 rs
= D3DRENDERSTATE_FOGEND
;
2543 case D3DLIGHTSTATE_FOGDENSITY
: /* 7 */
2544 rs
= D3DRENDERSTATE_FOGDENSITY
;
2546 case D3DLIGHTSTATE_COLORVERTEX
: /* 8 */
2547 rs
= D3DRENDERSTATE_COLORVERTEX
;
2550 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType
);
2551 return DDERR_INVALIDPARAMS
;
2554 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2562 static HRESULT WINAPI
2563 Thunk_IDirect3DDeviceImpl_2_SetLightState(IDirect3DDevice2
*iface
,
2564 D3DLIGHTSTATETYPE LightStateType
,
2567 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2568 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x) thunking to IDirect3DDevice3 interface.\n", This
, LightStateType
, Value
);
2569 return IDirect3DDevice3_SetLightState(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2574 /*****************************************************************************
2575 * IDirect3DDevice3::GetLightState
2577 * Returns the current setting of a light state. The state is read from
2578 * the Direct3DDevice7 render state.
2583 * LightStateType: The light state to return
2584 * Value: The address to store the light state setting at
2588 * DDDERR_INVALIDPARAMS if the parameters were incorrect
2589 * Also see IDirect3DDevice7::GetRenderState
2591 *****************************************************************************/
2592 static HRESULT WINAPI
2593 IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3
*iface
,
2594 D3DLIGHTSTATETYPE LightStateType
,
2597 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2599 TRACE("(%p)->(%08x,%p)\n", This
, LightStateType
, Value
);
2601 if (!LightStateType
&& (LightStateType
> D3DLIGHTSTATE_COLORVERTEX
))
2603 TRACE("Unexpected Light State Type\n");
2604 return DDERR_INVALIDPARAMS
;
2608 return DDERR_INVALIDPARAMS
;
2610 if (LightStateType
== D3DLIGHTSTATE_MATERIAL
/* 1 */)
2612 *Value
= This
->material
;
2614 else if (LightStateType
== D3DLIGHTSTATE_COLORMODEL
/* 3 */)
2616 *Value
= D3DCOLOR_RGB
;
2620 D3DRENDERSTATETYPE rs
;
2621 switch (LightStateType
)
2623 case D3DLIGHTSTATE_AMBIENT
: /* 2 */
2624 rs
= D3DRENDERSTATE_AMBIENT
;
2626 case D3DLIGHTSTATE_FOGMODE
: /* 4 */
2627 rs
= D3DRENDERSTATE_FOGVERTEXMODE
;
2629 case D3DLIGHTSTATE_FOGSTART
: /* 5 */
2630 rs
= D3DRENDERSTATE_FOGSTART
;
2632 case D3DLIGHTSTATE_FOGEND
: /* 6 */
2633 rs
= D3DRENDERSTATE_FOGEND
;
2635 case D3DLIGHTSTATE_FOGDENSITY
: /* 7 */
2636 rs
= D3DRENDERSTATE_FOGDENSITY
;
2638 case D3DLIGHTSTATE_COLORVERTEX
: /* 8 */
2639 rs
= D3DRENDERSTATE_COLORVERTEX
;
2642 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType
);
2643 return DDERR_INVALIDPARAMS
;
2646 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2654 static HRESULT WINAPI
2655 Thunk_IDirect3DDeviceImpl_2_GetLightState(IDirect3DDevice2
*iface
,
2656 D3DLIGHTSTATETYPE LightStateType
,
2659 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2660 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice3 interface.\n", This
, LightStateType
, Value
);
2661 return IDirect3DDevice3_GetLightState(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2666 /*****************************************************************************
2667 * IDirect3DDevice7::SetTransform
2669 * Assigns a D3DMATRIX to a transform type. The transform types are defined
2670 * in include/d3dtypes.h.
2671 * The D3DTRANSFORMSTATE_WORLD (=1) is translated to D3DTS_WORLDMATRIX(0)
2672 * (=255) for wined3d, because the 1 transform state was removed in d3d8
2673 * and WineD3D already understands the replacement D3DTS_WORLDMATRIX(0)
2675 * Version 2, 3 and 7
2678 * TransformStateType: transform state to set
2679 * Matrix: Matrix to assign to the state
2683 * DDERR_INVALIDPARAMS if Matrix == NULL
2684 * For details see IWineD3DDevice::SetTransform
2686 *****************************************************************************/
2687 static HRESULT WINAPI
2688 IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7
*iface
,
2689 D3DTRANSFORMSTATETYPE TransformStateType
,
2692 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2693 D3DTRANSFORMSTATETYPE type
= TransformStateType
;
2694 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, Matrix
);
2697 return DDERR_INVALIDPARAMS
;
2699 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2700 * use D3DTS_WORLDMATRIX(0) instead
2701 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2703 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2704 type
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2707 Unhandled: D3DTRANSFORMSTATE_WORLD1
2708 Unhandled: D3DTRANSFORMSTATE_WORLD2
2709 Unhandled: D3DTRANSFORMSTATE_WORLD3
2712 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
2713 return IWineD3DDevice_SetTransform(This
->wineD3DDevice
,
2715 (WINED3DMATRIX
*) Matrix
);
2718 static HRESULT WINAPI
2719 Thunk_IDirect3DDeviceImpl_3_SetTransform(IDirect3DDevice3
*iface
,
2720 D3DTRANSFORMSTATETYPE TransformStateType
,
2721 D3DMATRIX
*D3DMatrix
)
2723 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2724 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2725 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2730 static HRESULT WINAPI
2731 Thunk_IDirect3DDeviceImpl_2_SetTransform(IDirect3DDevice2
*iface
,
2732 D3DTRANSFORMSTATETYPE TransformStateType
,
2733 D3DMATRIX
*D3DMatrix
)
2735 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2736 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2737 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2742 /*****************************************************************************
2743 * IDirect3DDevice7::GetTransform
2745 * Returns the matrix assigned to a transform state
2746 * D3DTRANSFORMSTATE_WORLD is translated to D3DTS_WORLDMATRIX(0), see
2750 * TransformStateType: State to read the matrix from
2751 * Matrix: Address to store the matrix at
2755 * DDERR_INVALIDPARAMS if Matrix == NULL
2756 * For details, see IWineD3DDevice::GetTransform
2758 *****************************************************************************/
2759 static HRESULT WINAPI
2760 IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7
*iface
,
2761 D3DTRANSFORMSTATETYPE TransformStateType
,
2764 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2765 D3DTRANSFORMSTATETYPE type
= TransformStateType
;
2766 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, Matrix
);
2769 return DDERR_INVALIDPARAMS
;
2771 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2772 * use D3DTS_WORLDMATRIX(0) instead
2773 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2775 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2776 type
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2779 Unhandled: D3DTRANSFORMSTATE_WORLD1
2780 Unhandled: D3DTRANSFORMSTATE_WORLD2
2781 Unhandled: D3DTRANSFORMSTATE_WORLD3
2784 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
2785 return IWineD3DDevice_GetTransform(This
->wineD3DDevice
, type
, (WINED3DMATRIX
*) Matrix
);
2788 static HRESULT WINAPI
2789 Thunk_IDirect3DDeviceImpl_3_GetTransform(IDirect3DDevice3
*iface
,
2790 D3DTRANSFORMSTATETYPE TransformStateType
,
2791 D3DMATRIX
*D3DMatrix
)
2793 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2794 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2795 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2800 static HRESULT WINAPI
2801 Thunk_IDirect3DDeviceImpl_2_GetTransform(IDirect3DDevice2
*iface
,
2802 D3DTRANSFORMSTATETYPE TransformStateType
,
2803 D3DMATRIX
*D3DMatrix
)
2805 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2806 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2807 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2812 /*****************************************************************************
2813 * IDirect3DDevice7::MultiplyTransform
2815 * Multiplies the already-set transform matrix of a transform state
2816 * with another matrix. For the world matrix, see SetTransform
2818 * Version 2, 3 and 7
2821 * TransformStateType: Transform state to multiply
2822 * D3DMatrix Matrix to multiply with.
2826 * DDERR_INVALIDPARAMS if D3DMatrix is NULL
2827 * For details, see IWineD3DDevice::MultiplyTransform
2829 *****************************************************************************/
2830 static HRESULT WINAPI
2831 IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7
*iface
,
2832 D3DTRANSFORMSTATETYPE TransformStateType
,
2833 D3DMATRIX
*D3DMatrix
)
2835 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2836 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, D3DMatrix
);
2838 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2839 * use D3DTS_WORLDMATRIX(0) instead
2840 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2842 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2843 TransformStateType
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2846 Unhandled: D3DTRANSFORMSTATE_WORLD1
2847 Unhandled: D3DTRANSFORMSTATE_WORLD2
2848 Unhandled: D3DTRANSFORMSTATE_WORLD3
2851 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
2852 return IWineD3DDevice_MultiplyTransform(This
->wineD3DDevice
,
2854 (WINED3DMATRIX
*) D3DMatrix
);
2857 static HRESULT WINAPI
2858 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(IDirect3DDevice3
*iface
,
2859 D3DTRANSFORMSTATETYPE TransformStateType
,
2860 D3DMATRIX
*D3DMatrix
)
2862 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2863 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2864 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2869 static HRESULT WINAPI
2870 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform(IDirect3DDevice2
*iface
,
2871 D3DTRANSFORMSTATETYPE TransformStateType
,
2872 D3DMATRIX
*D3DMatrix
)
2874 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2875 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2876 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2881 /*****************************************************************************
2882 * IDirect3DDevice7::DrawPrimitive
2884 * Draws primitives based on vertices in an application-provided pointer
2886 * Version 2, 3 and 7. The IDirect3DDevice2 thunk converts the fixed vertex type into
2887 * an FVF format for D3D7
2890 * PrimitiveType: The type of the primitives to draw
2891 * Vertex type: Flexible vertex format vertex description
2892 * Vertices: Pointer to the vertex array
2893 * VertexCount: The number of vertices to draw
2894 * Flags: As usual a few flags
2898 * DDERR_INVALIDPARAMS if Vertices is NULL
2899 * For details, see IWineD3DDevice::DrawPrimitiveUP
2901 *****************************************************************************/
2902 static HRESULT WINAPI
2903 IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7
*iface
,
2904 D3DPRIMITIVETYPE PrimitiveType
,
2910 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2911 UINT PrimitiveCount
, stride
;
2913 TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): Relay!\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2916 return DDERR_INVALIDPARAMS
;
2918 /* Get the vertex count */
2919 switch(PrimitiveType
)
2921 case D3DPT_POINTLIST
:
2922 PrimitiveCount
= VertexCount
;
2925 case D3DPT_LINELIST
:
2926 PrimitiveCount
= VertexCount
/ 2;
2929 case D3DPT_LINESTRIP
:
2930 PrimitiveCount
= VertexCount
- 1;
2933 case D3DPT_TRIANGLELIST
:
2934 PrimitiveCount
= VertexCount
/ 3;
2937 case D3DPT_TRIANGLESTRIP
:
2938 PrimitiveCount
= VertexCount
- 2;
2941 case D3DPT_TRIANGLEFAN
:
2942 PrimitiveCount
= VertexCount
- 2;
2945 default: return DDERR_INVALIDPARAMS
;
2948 /* Get the stride */
2949 stride
= get_flexible_vertex_size(VertexType
);
2952 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, VertexType
);
2953 if(hr
!= D3D_OK
) return hr
;
2955 /* This method translates to the user pointer draw of WineD3D */
2956 return IWineD3DDevice_DrawPrimitiveUP(This
->wineD3DDevice
,
2963 static HRESULT WINAPI
2964 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(IDirect3DDevice3
*iface
,
2965 D3DPRIMITIVETYPE PrimitiveType
,
2971 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2972 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2973 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2981 static HRESULT WINAPI
2982 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive(IDirect3DDevice2
*iface
,
2983 D3DPRIMITIVETYPE PrimitiveType
,
2984 D3DVERTEXTYPE VertexType
,
2989 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2991 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2995 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
2996 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
2997 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
2999 ERR("Unexpected vertex type %d\n", VertexType
);
3000 return DDERR_INVALIDPARAMS
; /* Should never happen */
3003 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3011 /*****************************************************************************
3012 * IDirect3DDevice7::DrawIndexedPrimitive
3014 * Draws vertices from an application-provided pointer, based on the index
3015 * numbers in a WORD array.
3017 * Version 2, 3 and 7. The version 7 thunk translates the vertex type into
3018 * an FVF format for D3D7
3021 * PrimitiveType: The primitive type to draw
3022 * VertexType: The FVF vertex description
3023 * Vertices: Pointer to the vertex array
3025 * Indices: Pointer to the index array
3026 * IndexCount: Number of indices = Number of vertices to draw
3027 * Flags: As usual, some flags
3031 * DDERR_INVALIDPARAMS if Vertices or Indices is NULL
3032 * For details, see IWineD3DDevice::DrawIndexedPrimitiveUP
3034 *****************************************************************************/
3035 static HRESULT WINAPI
3036 IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7
*iface
,
3037 D3DPRIMITIVETYPE PrimitiveType
,
3045 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3046 UINT PrimitiveCount
= 0;
3048 TRACE("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): Relay!\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
3049 /* Get the primitive number */
3050 switch(PrimitiveType
)
3052 case D3DPT_POINTLIST
:
3053 PrimitiveCount
= IndexCount
;
3056 case D3DPT_LINELIST
:
3057 PrimitiveCount
= IndexCount
/ 2;
3060 case D3DPT_LINESTRIP
:
3061 PrimitiveCount
= IndexCount
- 1;
3064 case D3DPT_TRIANGLELIST
:
3065 PrimitiveCount
= IndexCount
/ 3;
3068 case D3DPT_TRIANGLESTRIP
:
3069 PrimitiveCount
= IndexCount
- 2;
3072 case D3DPT_TRIANGLEFAN
:
3073 PrimitiveCount
= IndexCount
- 2;
3076 default: return DDERR_INVALIDPARAMS
;
3079 /* Set the D3DDevice's FVF */
3080 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, VertexType
);
3083 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This
, hr
);
3087 return IWineD3DDevice_DrawIndexedPrimitiveUP(This
->wineD3DDevice
,
3089 0 /* MinVertexIndex */,
3090 VertexCount
/* UINT NumVertexIndex */,
3095 get_flexible_vertex_size(VertexType
));
3098 static HRESULT WINAPI
3099 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(IDirect3DDevice3
*iface
,
3100 D3DPRIMITIVETYPE PrimitiveType
,
3108 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3109 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
3110 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3120 static HRESULT WINAPI
3121 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(IDirect3DDevice2
*iface
,
3122 D3DPRIMITIVETYPE PrimitiveType
,
3123 D3DVERTEXTYPE VertexType
,
3131 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3132 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
3136 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
3137 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
3138 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
3140 ERR("Unexpected vertex type %d\n", VertexType
);
3141 return DDERR_INVALIDPARAMS
; /* Should never happen */
3144 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3154 /*****************************************************************************
3155 * IDirect3DDevice7::SetClipStatus
3157 * Sets the clip status. This defines things as clipping conditions and
3158 * the extents of the clipping region.
3160 * Version 2, 3 and 7
3166 * D3D_OK because it's a stub
3167 * (DDERR_INVALIDPARAMS if ClipStatus == NULL)
3169 *****************************************************************************/
3170 static HRESULT WINAPI
3171 IDirect3DDeviceImpl_7_SetClipStatus(IDirect3DDevice7
*iface
,
3172 D3DCLIPSTATUS
*ClipStatus
)
3174 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3175 FIXME("(%p)->(%p): Stub!\n", This
, ClipStatus
);
3177 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them
3178 * Perhaps this needs a new data type and an additional IWineD3DDevice method
3180 /* return IWineD3DDevice_SetClipStatus(This->wineD3DDevice, ClipStatus);*/
3184 static HRESULT WINAPI
3185 Thunk_IDirect3DDeviceImpl_3_SetClipStatus(IDirect3DDevice3
*iface
,
3186 D3DCLIPSTATUS
*ClipStatus
)
3188 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3189 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3190 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3194 static HRESULT WINAPI
3195 Thunk_IDirect3DDeviceImpl_2_SetClipStatus(IDirect3DDevice2
*iface
,
3196 D3DCLIPSTATUS
*ClipStatus
)
3198 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3199 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3200 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3204 /*****************************************************************************
3205 * IDirect3DDevice7::GetClipStatus
3207 * Returns the clip status
3210 * ClipStatus: Address to write the clip status to
3213 * D3D_OK because it's a stub
3215 *****************************************************************************/
3216 static HRESULT WINAPI
3217 IDirect3DDeviceImpl_7_GetClipStatus(IDirect3DDevice7
*iface
,
3218 D3DCLIPSTATUS
*ClipStatus
)
3220 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3221 FIXME("(%p)->(%p): Stub!\n", This
, ClipStatus
);
3223 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them */
3224 /* return IWineD3DDevice_GetClipStatus(This->wineD3DDevice, ClipStatus);*/
3228 static HRESULT WINAPI
3229 Thunk_IDirect3DDeviceImpl_3_GetClipStatus(IDirect3DDevice3
*iface
,
3230 D3DCLIPSTATUS
*ClipStatus
)
3232 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3233 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3234 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3238 static HRESULT WINAPI
3239 Thunk_IDirect3DDeviceImpl_2_GetClipStatus(IDirect3DDevice2
*iface
,
3240 D3DCLIPSTATUS
*ClipStatus
)
3242 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3243 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3244 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3248 /*****************************************************************************
3249 * IDirect3DDevice::DrawPrimitiveStrided
3251 * Draws vertices described by a D3DDRAWPRIMITIVESTRIDEDDATA structure.
3256 * PrimitiveType: The primitive type to draw
3257 * VertexType: The FVF description of the vertices to draw (for the stride??)
3258 * D3DDrawPrimStrideData: A D3DDRAWPRIMITIVESTRIDEDDATA structure describing
3259 * the vertex data locations
3260 * VertexCount: The number of vertices to draw
3264 * D3D_OK, because it's a stub
3265 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3266 * (For details, see IWineD3DDevice::DrawPrimitiveStrided)
3268 *****************************************************************************/
3269 static HRESULT WINAPI
3270 IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7
*iface
,
3271 D3DPRIMITIVETYPE PrimitiveType
,
3273 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3277 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3278 WineDirect3DVertexStridedData WineD3DStrided
;
3280 UINT PrimitiveCount
;
3282 TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Flags
);
3284 memset(&WineD3DStrided
, 0, sizeof(WineD3DStrided
));
3285 /* Get the strided data right. the wined3d structure is a bit bigger
3286 * Watch out: The contents of the strided data are determined by the fvf,
3287 * not by the members set in D3DDrawPrimStrideData. So it's valid
3288 * to have diffuse.lpvData set to 0xdeadbeef if the diffuse flag is
3289 * not set in the fvf.
3291 if(VertexType
& D3DFVF_POSITION_MASK
)
3293 WineD3DStrided
.u
.s
.position
.lpData
= D3DDrawPrimStrideData
->position
.lpvData
;
3294 WineD3DStrided
.u
.s
.position
.dwStride
= D3DDrawPrimStrideData
->position
.dwStride
;
3295 WineD3DStrided
.u
.s
.position
.dwType
= WINED3DDECLTYPE_FLOAT3
;
3296 if (VertexType
& D3DFVF_XYZRHW
)
3298 WineD3DStrided
.u
.s
.position
.dwType
= WINED3DDECLTYPE_FLOAT4
;
3299 WineD3DStrided
.u
.s
.position_transformed
= TRUE
;
3301 WineD3DStrided
.u
.s
.position_transformed
= FALSE
;
3304 if(VertexType
& D3DFVF_NORMAL
)
3306 WineD3DStrided
.u
.s
.normal
.lpData
= D3DDrawPrimStrideData
->normal
.lpvData
;
3307 WineD3DStrided
.u
.s
.normal
.dwStride
= D3DDrawPrimStrideData
->normal
.dwStride
;
3308 WineD3DStrided
.u
.s
.normal
.dwType
= WINED3DDECLTYPE_FLOAT3
;
3311 if(VertexType
& D3DFVF_DIFFUSE
)
3313 WineD3DStrided
.u
.s
.diffuse
.lpData
= D3DDrawPrimStrideData
->diffuse
.lpvData
;
3314 WineD3DStrided
.u
.s
.diffuse
.dwStride
= D3DDrawPrimStrideData
->diffuse
.dwStride
;
3315 WineD3DStrided
.u
.s
.diffuse
.dwType
= WINED3DDECLTYPE_SHORT4
;
3318 if(VertexType
& D3DFVF_SPECULAR
)
3320 WineD3DStrided
.u
.s
.specular
.lpData
= D3DDrawPrimStrideData
->specular
.lpvData
;
3321 WineD3DStrided
.u
.s
.specular
.dwStride
= D3DDrawPrimStrideData
->specular
.dwStride
;
3322 WineD3DStrided
.u
.s
.specular
.dwType
= WINED3DDECLTYPE_SHORT4
;
3325 for( i
= 0; i
< GET_TEXCOUNT_FROM_FVF(VertexType
); i
++)
3327 WineD3DStrided
.u
.s
.texCoords
[i
].lpData
= D3DDrawPrimStrideData
->textureCoords
[i
].lpvData
;
3328 WineD3DStrided
.u
.s
.texCoords
[i
].dwStride
= D3DDrawPrimStrideData
->textureCoords
[i
].dwStride
;
3329 switch(GET_TEXCOORD_SIZE_FROM_FVF(VertexType
, i
))
3331 case 1: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT1
; break;
3332 case 2: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT2
; break;
3333 case 3: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT3
; break;
3334 case 4: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT4
; break;
3335 default: ERR("Unexpected texture coordinate size %d\n",
3336 GET_TEXCOORD_SIZE_FROM_FVF(VertexType
, i
));
3340 /* Get the primitive count */
3341 switch(PrimitiveType
)
3343 case D3DPT_POINTLIST
:
3344 PrimitiveCount
= VertexCount
;
3347 case D3DPT_LINELIST
:
3348 PrimitiveCount
= VertexCount
/ 2;
3351 case D3DPT_LINESTRIP
:
3352 PrimitiveCount
= VertexCount
- 1;
3355 case D3DPT_TRIANGLELIST
:
3356 PrimitiveCount
= VertexCount
/ 3;
3359 case D3DPT_TRIANGLESTRIP
:
3360 PrimitiveCount
= VertexCount
- 2;
3363 case D3DPT_TRIANGLEFAN
:
3364 PrimitiveCount
= VertexCount
- 2;
3367 default: return DDERR_INVALIDPARAMS
;
3370 IWineD3DDevice_SetFVF(This
->wineD3DDevice
,
3373 return IWineD3DDevice_DrawPrimitiveStrided(This
->wineD3DDevice
,
3379 static HRESULT WINAPI
3380 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided(IDirect3DDevice3
*iface
,
3381 D3DPRIMITIVETYPE PrimitiveType
,
3383 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3387 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3388 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Flags
);
3389 return IDirect3DDevice7_DrawPrimitiveStrided(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3392 D3DDrawPrimStrideData
,
3397 /*****************************************************************************
3398 * IDirect3DDevice7::DrawIndexedPrimitiveStrided
3400 * Draws primitives specified by strided data locations based on indices
3408 * D3D_OK, because it's a stub
3409 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3410 * (DDERR_INVALIDPARAMS if Indices is NULL)
3411 * (For more details, see IWineD3DDevice::DrawIndexedPrimitiveStrided)
3413 *****************************************************************************/
3414 static HRESULT WINAPI
3415 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7
*iface
,
3416 D3DPRIMITIVETYPE PrimitiveType
,
3418 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3424 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3425 FIXME("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): stub!\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Indices
, IndexCount
, Flags
);
3427 /* I'll implement it as soon as I find a app to test it.
3428 * This needs an additional method in IWineD3DDevice.
3433 static HRESULT WINAPI
3434 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(IDirect3DDevice3
*iface
,
3435 D3DPRIMITIVETYPE PrimitiveType
,
3437 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3443 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3444 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", iface
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Indices
, IndexCount
, Flags
);
3445 return IDirect3DDevice7_DrawIndexedPrimitiveStrided(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3448 D3DDrawPrimStrideData
,
3455 /*****************************************************************************
3456 * IDirect3DDevice7::DrawPrimitiveVB
3458 * Draws primitives from a vertex buffer to the screen.
3463 * PrimitiveType: Type of primitive to be rendered.
3464 * D3DVertexBuf: Source Vertex Buffer
3465 * StartVertex: Index of the first vertex from the buffer to be rendered
3466 * NumVertices: Number of vertices to be rendered
3467 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3471 * DDERR_INVALIDPARAMS if D3DVertexBuf is NULL
3473 *****************************************************************************/
3474 static HRESULT WINAPI
3475 IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7
*iface
,
3476 D3DPRIMITIVETYPE PrimitiveType
,
3477 IDirect3DVertexBuffer7
*D3DVertexBuf
,
3482 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3483 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer7
, D3DVertexBuf
);
3484 UINT PrimitiveCount
;
3487 WINED3DVERTEXBUFFER_DESC Desc
;
3489 TRACE("(%p)->(%08x,%p,%08x,%08x,%08x)\n", This
, PrimitiveType
, D3DVertexBuf
, StartVertex
, NumVertices
, Flags
);
3494 ERR("(%p) No Vertex buffer specified\n", This
);
3495 return DDERR_INVALIDPARAMS
;
3498 /* Get the primitive count */
3499 switch(PrimitiveType
)
3501 case D3DPT_POINTLIST
:
3502 PrimitiveCount
= NumVertices
;
3505 case D3DPT_LINELIST
:
3506 PrimitiveCount
= NumVertices
/ 2;
3509 case D3DPT_LINESTRIP
:
3510 PrimitiveCount
= NumVertices
- 1;
3513 case D3DPT_TRIANGLELIST
:
3514 PrimitiveCount
= NumVertices
/ 3;
3517 case D3DPT_TRIANGLESTRIP
:
3518 PrimitiveCount
= NumVertices
- 2;
3521 case D3DPT_TRIANGLEFAN
:
3522 PrimitiveCount
= NumVertices
- 2;
3525 default: return DDERR_INVALIDPARAMS
;
3528 /* Get the FVF of the vertex buffer, and its stride */
3529 hr
= IWineD3DVertexBuffer_GetDesc(vb
->wineD3DVertexBuffer
,
3533 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x\n", This
, hr
);
3536 stride
= get_flexible_vertex_size(Desc
.FVF
);
3538 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, Desc
.FVF
);
3541 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This
, hr
);
3545 /* Set the vertex stream source */
3546 hr
= IWineD3DDevice_SetStreamSource(This
->wineD3DDevice
,
3547 0 /* StreamNumber */,
3548 vb
->wineD3DVertexBuffer
,
3549 0 /* StartVertex - we pass this to DrawPrimitive */,
3553 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This
, hr
);
3557 /* Now draw the primitives */
3558 return IWineD3DDevice_DrawPrimitive(This
->wineD3DDevice
,
3564 static HRESULT WINAPI
3565 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3
*iface
,
3566 D3DPRIMITIVETYPE PrimitiveType
,
3567 IDirect3DVertexBuffer
*D3DVertexBuf
,
3572 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3573 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer
, D3DVertexBuf
);
3574 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p,%08x,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, vb
, StartVertex
, NumVertices
, Flags
);
3575 return IDirect3DDevice7_DrawPrimitiveVB(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3577 ICOM_INTERFACE(vb
, IDirect3DVertexBuffer7
),
3584 /*****************************************************************************
3585 * IDirect3DDevice7::DrawIndexedPrimitiveVB
3587 * Draws primitives from a vertex buffer to the screen
3590 * PrimitiveType: Type of primitive to be rendered.
3591 * D3DVertexBuf: Source Vertex Buffer
3592 * StartVertex: Index of the first vertex from the buffer to be rendered
3593 * NumVertices: Number of vertices to be rendered
3594 * Indices: Array of DWORDs used to index into the Vertices
3595 * IndexCount: Number of indices in Indices
3596 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3600 *****************************************************************************/
3601 static HRESULT WINAPI
3602 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7
*iface
,
3603 D3DPRIMITIVETYPE PrimitiveType
,
3604 IDirect3DVertexBuffer7
*D3DVertexBuf
,
3611 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3612 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer7
, D3DVertexBuf
);
3614 UINT PrimitiveCount
;
3615 WORD
*LockedIndices
;
3617 WINED3DVERTEXBUFFER_DESC Desc
;
3619 TRACE("(%p)->(%08x,%p,%d,%d,%p,%d,%08x)\n", This
, PrimitiveType
, vb
, StartVertex
, NumVertices
, Indices
, IndexCount
, Flags
);
3622 * 1) Calculate some things: Vertex count -> Primitive count, stride, ...
3623 * 2) Upload the Indices to the index buffer
3624 * 3) Set the index source
3625 * 4) Set the Vertex Buffer as the Stream source
3626 * 5) Call IWineD3DDevice::DrawIndexedPrimitive
3629 /* Get the primitive count */
3630 switch(PrimitiveType
)
3632 case D3DPT_POINTLIST
:
3633 PrimitiveCount
= IndexCount
;
3636 case D3DPT_LINELIST
:
3637 PrimitiveCount
= IndexCount
/ 2;
3640 case D3DPT_LINESTRIP
:
3641 PrimitiveCount
= IndexCount
- 1;
3644 case D3DPT_TRIANGLELIST
:
3645 PrimitiveCount
= IndexCount
/ 3;
3648 case D3DPT_TRIANGLESTRIP
:
3649 PrimitiveCount
= IndexCount
- 2;
3652 case D3DPT_TRIANGLEFAN
:
3653 PrimitiveCount
= IndexCount
- 2;
3656 default: return DDERR_INVALIDPARAMS
;
3659 /* Get the FVF of the vertex buffer, and its stride */
3660 hr
= IWineD3DVertexBuffer_GetDesc(vb
->wineD3DVertexBuffer
,
3664 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x\n", This
, hr
);
3667 stride
= get_flexible_vertex_size(Desc
.FVF
);
3668 TRACE("Vertex buffer FVF = %08x, stride=%d\n", Desc
.FVF
, stride
);
3670 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, Desc
.FVF
);
3673 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This
, hr
);
3677 /* copy the index stream into the index buffer.
3678 * A new IWineD3DDevice method could be created
3679 * which takes an user pointer containing the indices
3680 * or a SetData-Method for the index buffer, which
3681 * overrides the index buffer data with our pointer.
3683 hr
= IWineD3DIndexBuffer_Lock(This
->indexbuffer
,
3684 0 /* OffSetToLock */,
3685 0 /* SizeToLock - doesn't matter */,
3686 (BYTE
**) &LockedIndices
,
3688 assert(IndexCount
< 0x100000);
3691 ERR("(%p) IWineD3DIndexBuffer::Lock failed with hr = %08x\n", This
, hr
);
3694 memcpy(LockedIndices
, Indices
, IndexCount
* sizeof(WORD
));
3695 hr
= IWineD3DIndexBuffer_Unlock(This
->indexbuffer
);
3698 ERR("(%p) IWineD3DIndexBuffer::Unlock failed with hr = %08x\n", This
, hr
);
3702 /* Set the index stream */
3703 hr
= IWineD3DDevice_SetIndices(This
->wineD3DDevice
,
3707 /* Set the vertex stream source */
3708 hr
= IWineD3DDevice_SetStreamSource(This
->wineD3DDevice
,
3709 0 /* StreamNumber */,
3710 vb
->wineD3DVertexBuffer
,
3711 0 /* offset, we pass this to DrawIndexedPrimitive */,
3715 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This
, hr
);
3720 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->wineD3DDevice
,
3730 static HRESULT WINAPI
3731 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevice3
*iface
,
3732 D3DPRIMITIVETYPE PrimitiveType
,
3733 IDirect3DVertexBuffer
*D3DVertexBuf
,
3738 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3739 IDirect3DVertexBufferImpl
*VB
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer
, D3DVertexBuf
);
3740 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VB
, Indices
, IndexCount
, Flags
);
3742 return IDirect3DDevice7_DrawIndexedPrimitiveVB(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3744 ICOM_INTERFACE(VB
, IDirect3DVertexBuffer7
),
3752 /*****************************************************************************
3753 * IDirect3DDevice7::ComputeSphereVisibility
3755 * Calculates the visibility of spheres in the current viewport. The spheres
3756 * are passed in the Centers and Radii arrays, the results are passed back
3757 * in the ReturnValues array. Return values are either completely visible,
3758 * partially visible or completely invisible.
3759 * The return value consist of a combination of D3DCLIP_* flags, or it's
3760 * 0 if the sphere is completely visible(according to the SDK, not checked)
3762 * Sounds like an overdose of math ;)
3767 * Centers: Array containing the sphere centers
3768 * Radii: Array containing the sphere radii
3769 * NumSpheres: The number of centers and radii in the arrays
3771 * ReturnValues: Array to write the results to
3774 * D3D_OK because it's a stub
3775 * (DDERR_INVALIDPARAMS if Centers, Radii or ReturnValues are NULL)
3776 * (D3DERR_INVALIDMATRIX if the combined world, view and proj matrix
3779 *****************************************************************************/
3780 static HRESULT WINAPI
3781 IDirect3DDeviceImpl_7_ComputeSphereVisibility(IDirect3DDevice7
*iface
,
3786 DWORD
*ReturnValues
)
3788 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3789 FIXME("(%p)->(%p,%p,%08x,%08x,%p): stub!\n", This
, Centers
, Radii
, NumSpheres
, Flags
, ReturnValues
);
3791 /* the DirectX 7 sdk says that the visibility is computed by
3792 * back-transforming the viewing frustum to model space
3793 * using the inverse of the combined world, view and projection
3794 * matrix. If the matrix can't be reversed, D3DERR_INVALIDMATRIX
3797 * Basic implementation idea:
3798 * 1) Check if the center is in the viewing frustum
3799 * 2) Cut the sphere with the planes of the viewing
3802 * ->Center inside the frustum, no intersections:
3804 * ->Center outside the frustum, no intersections:
3806 * ->Some intersections: Partially visible
3808 * Implement this call in WineD3D. Either implement the
3809 * matrix and vector stuff in WineD3D, or use some external
3816 static HRESULT WINAPI
3817 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility(IDirect3DDevice3
*iface
,
3822 DWORD
*ReturnValues
)
3824 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3825 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08x,%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, Centers
, Radii
, NumSpheres
, Flags
, ReturnValues
);
3826 return IDirect3DDevice7_ComputeSphereVisibility(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3834 /*****************************************************************************
3835 * IDirect3DDevice7::GetTexture
3837 * Returns the texture interface handle assigned to a texture stage.
3838 * The returned texture is AddRefed. This is taken from old ddraw,
3839 * not checked in Windows.
3844 * Stage: Texture stage to read the texture from
3845 * Texture: Address to store the interface pointer at
3849 * DDERR_INVALIDPARAMS if Texture is NULL
3850 * For details, see IWineD3DDevice::GetTexture
3852 *****************************************************************************/
3853 static HRESULT WINAPI
3854 IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7
*iface
,
3856 IDirectDrawSurface7
**Texture
)
3858 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3859 IWineD3DBaseTexture
*Surf
;
3861 TRACE("(%p)->(%d,%p): Relay\n", This
, Stage
, Texture
);
3865 TRACE("Texture == NULL, failing with DDERR_INVALIDPARAMS\n");
3866 return DDERR_INVALIDPARAMS
;
3869 hr
= IWineD3DDevice_GetTexture(This
->wineD3DDevice
, Stage
, (IWineD3DBaseTexture
**) &Surf
);
3870 if( (hr
!= D3D_OK
) || (!Surf
) )
3876 /* GetParent AddRef()s, which is perfectly OK.
3877 * We have passed the IDirectDrawSurface7 interface to WineD3D, so that's OK too.
3879 return IWineD3DBaseTexture_GetParent(Surf
,
3880 (IUnknown
**) Texture
);
3883 static HRESULT WINAPI
3884 Thunk_IDirect3DDeviceImpl_3_GetTexture(IDirect3DDevice3
*iface
,
3886 IDirect3DTexture2
**Texture2
)
3888 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3890 IDirectDrawSurface7
*ret_val
;
3892 TRACE_(ddraw_thunk
)("(%p)->(%d,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, Texture2
);
3893 ret
= IDirect3DDevice7_GetTexture(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3897 *Texture2
= COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirect3DTexture2
, ret_val
);
3899 TRACE_(ddraw_thunk
)(" returning interface %p.\n", *Texture2
);
3904 /*****************************************************************************
3905 * IDirect3DDevice7::SetTexture
3907 * Assigns a texture to a texture stage. Is the texture AddRef-ed?
3912 * Stage: The stage to assign the texture to
3913 * Texture: Interface pointer to the texture surface
3917 * For details, see IWineD3DDevice::SetTexture
3919 *****************************************************************************/
3920 static HRESULT WINAPI
3921 IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7
*iface
,
3923 IDirectDrawSurface7
*Texture
)
3925 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3926 IDirectDrawSurfaceImpl
*surf
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, Texture
);
3927 TRACE("(%p)->(%08x,%p): Relay!\n", This
, Stage
, surf
);
3929 /* Texture may be NULL here */
3930 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
3932 surf
? (IWineD3DBaseTexture
* ) surf
->wineD3DTexture
: NULL
);
3935 static HRESULT WINAPI
3936 Thunk_IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3
*iface
,
3938 IDirect3DTexture2
*Texture2
)
3940 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3941 IDirectDrawSurfaceImpl
*tex
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Texture2
);
3942 TRACE_(ddraw_thunk
)("(%p)->(%d,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, tex
);
3943 return IDirect3DDevice7_SetTexture(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3945 ICOM_INTERFACE(tex
, IDirectDrawSurface7
));
3948 /*****************************************************************************
3949 * IDirect3DDevice7::GetTextureStageState
3951 * Retrieves a state from a texture stage.
3956 * Stage: The stage to retrieve the state from
3957 * TexStageStateType: The state type to retrieve
3958 * State: Address to store the state's value at
3962 * DDERR_INVALIDPARAMS if State is NULL
3963 * For details, see IWineD3DDevice::GetTextureStageState
3965 *****************************************************************************/
3966 static HRESULT WINAPI
3967 IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7
*iface
,
3969 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3972 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3973 TRACE("(%p)->(%08x,%08x,%p): Relay!\n", This
, Stage
, TexStageStateType
, State
);
3976 return DDERR_INVALIDPARAMS
;
3978 switch(TexStageStateType
)
3980 /* Mipfilter is a sampler state with different values */
3981 case D3DTSS_MIPFILTER
:
3984 WINED3DTEXTUREFILTERTYPE value
;
3986 hr
= IWineD3DDevice_GetSamplerState(This
->wineD3DDevice
,
3988 WINED3DSAMP_MIPFILTER
,
3992 case WINED3DTEXF_NONE
: *State
= D3DTFP_NONE
; break;
3993 case WINED3DTEXF_POINT
: *State
= D3DTFP_POINT
; break;
3994 case WINED3DTEXF_LINEAR
: *State
= D3DTFP_LINEAR
; break;
3996 ERR("Unexpected mipfilter value %d\n", value
);
3997 *State
= D3DTFP_NONE
;
4002 /* Minfilter is a sampler state too, equal values */
4003 case D3DTSS_MINFILTER
:
4004 return IWineD3DDevice_GetSamplerState(This
->wineD3DDevice
,
4006 WINED3DSAMP_MINFILTER
,
4008 /* Same for MAGFILTER */
4009 case D3DTSS_MAGFILTER
:
4010 return IWineD3DDevice_GetSamplerState(This
->wineD3DDevice
,
4012 WINED3DSAMP_MAGFILTER
,
4015 return IWineD3DDevice_GetTextureStageState(This
->wineD3DDevice
,
4022 static HRESULT WINAPI
4023 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState(IDirect3DDevice3
*iface
,
4025 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
4028 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
4029 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, TexStageStateType
, State
);
4030 return IDirect3DDevice7_GetTextureStageState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
4036 /*****************************************************************************
4037 * IDirect3DDevice7::SetTextureStageState
4039 * Sets a texture stage state. Some stage types need to be handled specially,
4040 * because they do not exist in WineD3D and were moved to another place
4045 * Stage: The stage to modify
4046 * TexStageStateType: The state to change
4047 * State: The new value for the state
4051 * For details, see IWineD3DDevice::SetTextureStageState
4053 *****************************************************************************/
4054 static HRESULT WINAPI
4055 IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7
*iface
,
4057 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
4060 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4061 TRACE("(%p)->(%08x,%08x,%08x): Relay!\n", This
, Stage
, TexStageStateType
, State
);
4062 switch(TexStageStateType
)
4064 /* Mipfilter is a sampler state with different values */
4065 case D3DTSS_MIPFILTER
:
4067 WINED3DTEXTUREFILTERTYPE value
;
4070 case D3DTFP_NONE
: value
= WINED3DTEXF_NONE
; break;
4071 case D3DTFP_POINT
: value
= WINED3DTEXF_POINT
; break;
4072 case 0: /* Unchecked */
4073 case D3DTFP_LINEAR
: value
= WINED3DTEXF_LINEAR
; break;
4075 ERR("Unexpected mipfilter value %d\n", State
);
4076 value
= WINED3DTEXF_NONE
;
4078 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
4080 WINED3DSAMP_MIPFILTER
,
4084 /* Minfilter is a sampler state too, equal values */
4085 case D3DTSS_MINFILTER
:
4086 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
4088 WINED3DSAMP_MINFILTER
,
4090 /* Same for MAGFILTER */
4091 case D3DTSS_MAGFILTER
:
4092 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
4094 WINED3DSAMP_MAGFILTER
,
4099 return IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
,
4106 static HRESULT WINAPI
4107 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState(IDirect3DDevice3
*iface
,
4109 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
4112 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
4113 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, TexStageStateType
, State
);
4114 return IDirect3DDevice7_SetTextureStageState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
4120 /*****************************************************************************
4121 * IDirect3DDevice7::ValidateDevice
4123 * SDK: "Reports the device's ability to render the currently set
4124 * texture-blending operations in a single pass". Whatever that means
4130 * NumPasses: Address to write the number of necessary passes for the
4131 * desired effect to.
4135 * See IWineD3DDevice::ValidateDevice for more details
4137 *****************************************************************************/
4138 static HRESULT WINAPI
4139 IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7
*iface
,
4142 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4143 TRACE("(%p)->(%p): Relay\n", This
, NumPasses
);
4145 return IWineD3DDevice_ValidateDevice(This
->wineD3DDevice
, NumPasses
);
4148 static HRESULT WINAPI
4149 Thunk_IDirect3DDeviceImpl_3_ValidateDevice(IDirect3DDevice3
*iface
,
4152 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
4153 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Passes
);
4154 return IDirect3DDevice7_ValidateDevice(ICOM_INTERFACE(This
, IDirect3DDevice7
),
4158 /*****************************************************************************
4159 * IDirect3DDevice7::Clear
4161 * Fills the render target, the z buffer and the stencil buffer with a
4162 * clear color / value
4167 * Count: Number of rectangles in Rects must be 0 if Rects is NULL
4168 * Rects: Rectangles to clear. If NULL, the whole surface is cleared
4169 * Flags: Some flags, as usual
4170 * Color: Clear color for the render target
4171 * Z: Clear value for the Z buffer
4172 * Stencil: Clear value to store in each stencil buffer entry
4176 * For details, see IWineD3DDevice::Clear
4178 *****************************************************************************/
4179 static HRESULT WINAPI
4180 IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7
*iface
,
4188 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4189 TRACE("(%p)->(%08x,%p,%08x,%08x,%f,%08x): Relay\n", This
, Count
, Rects
, Flags
, (DWORD
) Color
, Z
, Stencil
);
4191 /* Note; D3DRECT is compatible with WINED3DRECT */
4192 return IWineD3DDevice_Clear(This
->wineD3DDevice
, Count
, (WINED3DRECT
*) Rects
, Flags
, Color
, Z
, Stencil
);
4195 /*****************************************************************************
4196 * IDirect3DDevice7::SetViewport
4198 * Sets the current viewport.
4200 * Version 7 only, but IDirect3DViewport uses this call for older
4204 * Data: The new viewport to set
4208 * DDERR_INVALIDPARAMS if Data is NULL
4209 * For more details, see IWineDDDevice::SetViewport
4211 *****************************************************************************/
4212 static HRESULT WINAPI
4213 IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7
*iface
,
4216 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4217 TRACE("(%p)->(%p) Relay!\n", This
, Data
);
4220 return DDERR_INVALIDPARAMS
;
4222 /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
4223 return IWineD3DDevice_SetViewport(This
->wineD3DDevice
,
4224 (WINED3DVIEWPORT
*) Data
);
4227 /*****************************************************************************
4228 * IDirect3DDevice::GetViewport
4230 * Returns the current viewport
4235 * Data: D3D7Viewport structure to write the viewport information to
4239 * DDERR_INVALIDPARAMS if Data is NULL
4240 * For more details, see IWineD3DDevice::GetViewport
4242 *****************************************************************************/
4243 static HRESULT WINAPI
4244 IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7
*iface
,
4247 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4249 TRACE("(%p)->(%p) Relay!\n", This
, Data
);
4252 return DDERR_INVALIDPARAMS
;
4254 /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
4255 hr
= IWineD3DDevice_GetViewport(This
->wineD3DDevice
,
4256 (WINED3DVIEWPORT
*) Data
);
4258 return hr_ddraw_from_wined3d(hr
);
4261 /*****************************************************************************
4262 * IDirect3DDevice7::SetMaterial
4269 * Mat: The material to set
4273 * DDERR_INVALIDPARAMS if Mat is NULL.
4274 * For more details, see IWineD3DDevice::SetMaterial
4276 *****************************************************************************/
4277 static HRESULT WINAPI
4278 IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7
*iface
,
4281 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4283 TRACE("(%p)->(%p): Relay!\n", This
, Mat
);
4285 /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
4286 hr
= IWineD3DDevice_SetMaterial(This
->wineD3DDevice
,
4287 (WINED3DMATERIAL
*) Mat
);
4289 return hr_ddraw_from_wined3d(hr
);
4292 /*****************************************************************************
4293 * IDirect3DDevice7::GetMaterial
4295 * Returns the current material
4300 * Mat: D3DMATERIAL7 structure to write the material parameters to
4304 * DDERR_INVALIDPARAMS if Mat is NULL
4305 * For more details, see IWineD3DDevice::GetMaterial
4307 *****************************************************************************/
4308 static HRESULT WINAPI
4309 IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7
*iface
,
4312 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4314 TRACE("(%p)->(%p): Relay!\n", This
, Mat
);
4316 /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
4317 hr
= IWineD3DDevice_GetMaterial(This
->wineD3DDevice
,
4318 (WINED3DMATERIAL
*) Mat
);
4320 return hr_ddraw_from_wined3d(hr
);
4323 /*****************************************************************************
4324 * IDirect3DDevice7::SetLight
4326 * Assigns a light to a light index, but doesn't activate it yet.
4328 * Version 7, IDirect3DLight uses this method for older versions
4331 * LightIndex: The index of the new light
4332 * Light: A D3DLIGHT7 structure describing the light
4336 * For more details, see IWineD3DDevice::SetLight
4338 *****************************************************************************/
4339 static HRESULT WINAPI
4340 IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7
*iface
,
4344 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4346 TRACE("(%p)->(%08x,%p): Relay!\n", This
, LightIndex
, Light
);
4348 /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
4349 hr
= IWineD3DDevice_SetLight(This
->wineD3DDevice
,
4351 (WINED3DLIGHT
*) Light
);
4353 return hr_ddraw_from_wined3d(hr
);
4356 /*****************************************************************************
4357 * IDirect3DDevice7::GetLight
4359 * Returns the light assigned to a light index
4362 * Light: Structure to write the light information to
4366 * DDERR_INVALIDPARAMS if Light is NULL
4367 * For details, see IWineD3DDevice::GetLight
4369 *****************************************************************************/
4370 static HRESULT WINAPI
4371 IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7
*iface
,
4375 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4377 TRACE("(%p)->(%08x,%p): Relay!\n", This
, LightIndex
, Light
);
4379 /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
4380 rc
= IWineD3DDevice_GetLight(This
->wineD3DDevice
,
4382 (WINED3DLIGHT
*) Light
);
4384 /* Translate the result. WineD3D returns other values than D3D7 */
4385 return hr_ddraw_from_wined3d(rc
);
4388 /*****************************************************************************
4389 * IDirect3DDevice7::BeginStateBlock
4391 * Begins recording to a stateblock
4397 * For details see IWineD3DDevice::BeginStateBlock
4399 *****************************************************************************/
4400 static HRESULT WINAPI
4401 IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7
*iface
)
4403 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4405 TRACE("(%p)->(): Relay!\n", This
);
4407 hr
= IWineD3DDevice_BeginStateBlock(This
->wineD3DDevice
);
4408 return hr_ddraw_from_wined3d(hr
);
4411 /*****************************************************************************
4412 * IDirect3DDevice7::EndStateBlock
4414 * Stops recording to a state block and returns the created stateblock
4420 * BlockHandle: Address to store the stateblock's handle to
4424 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4425 * See IWineD3DDevice::EndStateBlock for more details
4427 *****************************************************************************/
4428 static HRESULT WINAPI
4429 IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7
*iface
,
4432 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4434 TRACE("(%p)->(%p): Relay!\n", This
, BlockHandle
);
4438 WARN("BlockHandle == NULL, returning DDERR_INVALIDPARAMS\n");
4439 return DDERR_INVALIDPARAMS
;
4442 *BlockHandle
= IDirect3DDeviceImpl_CreateHandle(This
);
4445 ERR("Cannot get a handle number for the stateblock\n");
4446 return DDERR_OUTOFMEMORY
;
4448 This
->Handles
[*BlockHandle
- 1].type
= DDrawHandle_StateBlock
;
4449 hr
= IWineD3DDevice_EndStateBlock(This
->wineD3DDevice
,
4450 (IWineD3DStateBlock
**) &This
->Handles
[*BlockHandle
- 1].ptr
);
4451 return hr_ddraw_from_wined3d(hr
);
4454 /*****************************************************************************
4455 * IDirect3DDevice7::PreLoad
4457 * Allows the app to signal that a texture will be used soon, to allow
4458 * the Direct3DDevice to load it to the video card in the meantime.
4463 * Texture: The texture to preload
4467 * DDERR_INVALIDPARAMS if Texture is NULL
4468 * See IWineD3DSurface::PreLoad for details
4470 *****************************************************************************/
4471 static HRESULT WINAPI
4472 IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7
*iface
,
4473 IDirectDrawSurface7
*Texture
)
4475 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4476 IDirectDrawSurfaceImpl
*surf
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, Texture
);
4478 TRACE("(%p)->(%p): Relay!\n", This
, surf
);
4481 return DDERR_INVALIDPARAMS
;
4483 IWineD3DSurface_PreLoad(surf
->WineD3DSurface
);
4487 /*****************************************************************************
4488 * IDirect3DDevice7::ApplyStateBlock
4490 * Activates the state stored in a state block handle.
4493 * BlockHandle: The stateblock handle to activate
4497 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4499 *****************************************************************************/
4500 static HRESULT WINAPI
4501 IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7
*iface
,
4504 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4506 TRACE("(%p)->(%08x): Relay!\n", This
, BlockHandle
);
4508 if(!BlockHandle
|| BlockHandle
> This
->numHandles
)
4510 WARN("Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4511 return D3DERR_INVALIDSTATEBLOCK
;
4513 if(This
->Handles
[BlockHandle
- 1].type
!= DDrawHandle_StateBlock
)
4515 WARN("Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4516 return D3DERR_INVALIDSTATEBLOCK
;
4519 hr
= IWineD3DStateBlock_Apply((IWineD3DStateBlock
*) This
->Handles
[BlockHandle
- 1].ptr
);
4520 return hr_ddraw_from_wined3d(hr
);
4523 /*****************************************************************************
4524 * IDirect3DDevice7::CaptureStateBlock
4526 * Updates a stateblock's values to the values currently set for the device
4531 * BlockHandle: Stateblock to update
4535 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4536 * See IWineD3DDevice::CaptureStateBlock for more details
4538 *****************************************************************************/
4539 static HRESULT WINAPI
4540 IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7
*iface
,
4543 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4545 TRACE("(%p)->(%08x): Relay!\n", This
, BlockHandle
);
4547 if(BlockHandle
== 0 || BlockHandle
> This
->numHandles
)
4549 WARN("Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4550 return D3DERR_INVALIDSTATEBLOCK
;
4552 if(This
->Handles
[BlockHandle
- 1].type
!= DDrawHandle_StateBlock
)
4554 WARN("Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4555 return D3DERR_INVALIDSTATEBLOCK
;
4558 hr
= IWineD3DStateBlock_Capture((IWineD3DStateBlock
*) This
->Handles
[BlockHandle
- 1].ptr
);
4559 return hr_ddraw_from_wined3d(hr
);
4562 /*****************************************************************************
4563 * IDirect3DDevice7::DeleteStateBlock
4565 * Deletes a stateblock handle. This means releasing the WineD3DStateBlock
4570 * BlockHandle: Stateblock handle to delete
4574 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is 0
4576 *****************************************************************************/
4577 static HRESULT WINAPI
4578 IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7
*iface
,
4581 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4583 TRACE("(%p)->(%08x): Relay!\n", This
, BlockHandle
);
4585 if(BlockHandle
== 0 || BlockHandle
> This
->numHandles
)
4587 WARN("Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4588 return D3DERR_INVALIDSTATEBLOCK
;
4590 if(This
->Handles
[BlockHandle
- 1].type
!= DDrawHandle_StateBlock
)
4592 WARN("Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4593 return D3DERR_INVALIDSTATEBLOCK
;
4596 ref
= IWineD3DStateBlock_Release((IWineD3DStateBlock
*) This
->Handles
[BlockHandle
- 1].ptr
);
4599 ERR("Something is still holding the stateblock %p(Handle %d). Ref = %d\n", This
->Handles
[BlockHandle
- 1].ptr
, BlockHandle
, ref
);
4601 This
->Handles
[BlockHandle
- 1].ptr
= NULL
;
4602 This
->Handles
[BlockHandle
- 1].type
= DDrawHandle_Unknown
;
4607 /*****************************************************************************
4608 * IDirect3DDevice7::CreateStateBlock
4610 * Creates a new state block handle.
4615 * Type: The state block type
4616 * BlockHandle: Address to write the created handle to
4620 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4622 *****************************************************************************/
4623 static HRESULT WINAPI
4624 IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7
*iface
,
4625 D3DSTATEBLOCKTYPE Type
,
4628 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4630 TRACE("(%p)->(%08x,%p)!\n", This
, Type
, BlockHandle
);
4634 WARN("BlockHandle == NULL, returning DDERR_INVALIDPARAMS\n");
4635 return DDERR_INVALIDPARAMS
;
4638 *BlockHandle
= IDirect3DDeviceImpl_CreateHandle(This
);
4641 ERR("Cannot get a handle number for the stateblock\n");
4642 return DDERR_OUTOFMEMORY
;
4644 This
->Handles
[*BlockHandle
- 1].type
= DDrawHandle_StateBlock
;
4646 /* The D3DSTATEBLOCKTYPE enum is fine here */
4647 hr
= IWineD3DDevice_CreateStateBlock(This
->wineD3DDevice
,
4649 (IWineD3DStateBlock
**) &This
->Handles
[*BlockHandle
- 1].ptr
,
4650 NULL
/* Parent, hope that works */);
4651 return hr_ddraw_from_wined3d(hr
);
4654 /*****************************************************************************
4655 * IDirect3DDevice7::Load
4657 * Loads a rectangular area from the source into the destination texture.
4658 * It can also copy the source to the faces of a cubic environment map
4663 * DestTex: Destination texture
4664 * DestPoint: Point in the destination where the source image should be
4666 * SrcTex: Source texture
4667 * SrcRect: Source rectangle
4672 * DDERR_INVALIDPARAMS if DestTex or SrcTex are NULL
4673 * See IDirect3DTexture2::Load for details
4675 *****************************************************************************/
4676 static HRESULT WINAPI
4677 IDirect3DDeviceImpl_7_Load(IDirect3DDevice7
*iface
,
4678 IDirectDrawSurface7
*DestTex
,
4680 IDirectDrawSurface7
*SrcTex
,
4684 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4685 IDirectDrawSurfaceImpl
*dest
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, DestTex
);
4686 IDirectDrawSurfaceImpl
*src
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, SrcTex
);
4687 FIXME("(%p)->(%p,%p,%p,%p,%08x): Partially Implemented!\n", This
, dest
, DestPoint
, src
, SrcRect
, Flags
);
4689 if( (!src
) || (!dest
) )
4690 return DDERR_INVALIDPARAMS
;
4692 IDirect3DTexture2_Load(ICOM_INTERFACE(dest
, IDirect3DTexture2
),
4693 ICOM_INTERFACE(src
, IDirect3DTexture2
));
4697 /*****************************************************************************
4698 * IDirect3DDevice7::LightEnable
4700 * Enables or disables a light
4702 * Version 7, IDirect3DLight uses this method too.
4705 * LightIndex: The index of the light to enable / disable
4706 * Enable: Enable or disable the light
4710 * For more details, see IWineD3DDevice::SetLightEnable
4712 *****************************************************************************/
4713 static HRESULT WINAPI
4714 IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7
*iface
,
4718 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4720 TRACE("(%p)->(%08x,%d): Relay!\n", This
, LightIndex
, Enable
);
4722 hr
= IWineD3DDevice_SetLightEnable(This
->wineD3DDevice
, LightIndex
, Enable
);
4723 return hr_ddraw_from_wined3d(hr
);
4726 /*****************************************************************************
4727 * IDirect3DDevice7::GetLightEnable
4729 * Retrieves if the light with the given index is enabled or not
4734 * LightIndex: Index of desired light
4735 * Enable: Pointer to a BOOL which contains the result
4739 * DDERR_INVALIDPARAMS if Enable is NULL
4740 * See IWineD3DDevice::GetLightEnable for more details
4742 *****************************************************************************/
4743 static HRESULT WINAPI
4744 IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7
*iface
,
4748 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4750 TRACE("(%p)->(%08x,%p): Relay\n", This
, LightIndex
, Enable
);
4753 return DDERR_INVALIDPARAMS
;
4755 hr
= IWineD3DDevice_GetLightEnable(This
->wineD3DDevice
, LightIndex
, Enable
);
4756 return hr_ddraw_from_wined3d(hr
);
4759 /*****************************************************************************
4760 * IDirect3DDevice7::SetClipPlane
4762 * Sets custom clipping plane
4767 * Index: The index of the clipping plane
4768 * PlaneEquation: An equation defining the clipping plane
4772 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4773 * See IWineD3DDevice::SetClipPlane for more details
4775 *****************************************************************************/
4776 static HRESULT WINAPI
4777 IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7
*iface
,
4779 D3DVALUE
* PlaneEquation
)
4781 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4782 TRACE("(%p)->(%08x,%p): Relay!\n", This
, Index
, PlaneEquation
);
4785 return DDERR_INVALIDPARAMS
;
4787 return IWineD3DDevice_SetClipPlane(This
->wineD3DDevice
, Index
, PlaneEquation
);
4790 /*****************************************************************************
4791 * IDirect3DDevice7::GetClipPlane
4793 * Returns the clipping plane with a specific index
4796 * Index: The index of the desired plane
4797 * PlaneEquation: Address to store the plane equation to
4801 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4802 * See IWineD3DDevice::GetClipPlane for more details
4804 *****************************************************************************/
4805 static HRESULT WINAPI
4806 IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7
*iface
,
4808 D3DVALUE
* PlaneEquation
)
4810 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4811 TRACE("(%p)->(%d,%p): Relay!\n", This
, Index
, PlaneEquation
);
4814 return DDERR_INVALIDPARAMS
;
4816 return IWineD3DDevice_GetClipPlane(This
->wineD3DDevice
, Index
, PlaneEquation
);
4819 /*****************************************************************************
4820 * IDirect3DDevice7::GetInfo
4822 * Retrieves some information about the device. The DirectX sdk says that
4823 * this version returns S_FALSE for all retail builds of DirectX, that's what
4824 * this implementation does.
4827 * DevInfoID: Information type requested
4828 * DevInfoStruct: Pointer to a structure to store the info to
4829 * Size: Size of the structure
4832 * S_FALSE, because it's a non-debug driver
4834 *****************************************************************************/
4835 static HRESULT WINAPI
4836 IDirect3DDeviceImpl_7_GetInfo(IDirect3DDevice7
*iface
,
4838 void *DevInfoStruct
,
4841 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4842 TRACE("(%p)->(%08x,%p,%08x)\n", This
, DevInfoID
, DevInfoStruct
, Size
);
4846 TRACE(" info requested : ");
4849 case D3DDEVINFOID_TEXTUREMANAGER
: TRACE("D3DDEVINFOID_TEXTUREMANAGER\n"); break;
4850 case D3DDEVINFOID_D3DTEXTUREMANAGER
: TRACE("D3DDEVINFOID_D3DTEXTUREMANAGER\n"); break;
4851 case D3DDEVINFOID_TEXTURING
: TRACE("D3DDEVINFOID_TEXTURING\n"); break;
4852 default: ERR(" invalid flag !!!\n"); return DDERR_INVALIDPARAMS
;
4856 return S_FALSE
; /* According to MSDN, this is valid for a non-debug driver */
4859 const IDirect3DDevice7Vtbl IDirect3DDevice7_Vtbl
=
4861 /*** IUnknown Methods ***/
4862 IDirect3DDeviceImpl_7_QueryInterface
,
4863 IDirect3DDeviceImpl_7_AddRef
,
4864 IDirect3DDeviceImpl_7_Release
,
4865 /*** IDirect3DDevice7 ***/
4866 IDirect3DDeviceImpl_7_GetCaps
,
4867 IDirect3DDeviceImpl_7_EnumTextureFormats
,
4868 IDirect3DDeviceImpl_7_BeginScene
,
4869 IDirect3DDeviceImpl_7_EndScene
,
4870 IDirect3DDeviceImpl_7_GetDirect3D
,
4871 IDirect3DDeviceImpl_7_SetRenderTarget
,
4872 IDirect3DDeviceImpl_7_GetRenderTarget
,
4873 IDirect3DDeviceImpl_7_Clear
,
4874 IDirect3DDeviceImpl_7_SetTransform
,
4875 IDirect3DDeviceImpl_7_GetTransform
,
4876 IDirect3DDeviceImpl_7_SetViewport
,
4877 IDirect3DDeviceImpl_7_MultiplyTransform
,
4878 IDirect3DDeviceImpl_7_GetViewport
,
4879 IDirect3DDeviceImpl_7_SetMaterial
,
4880 IDirect3DDeviceImpl_7_GetMaterial
,
4881 IDirect3DDeviceImpl_7_SetLight
,
4882 IDirect3DDeviceImpl_7_GetLight
,
4883 IDirect3DDeviceImpl_7_SetRenderState
,
4884 IDirect3DDeviceImpl_7_GetRenderState
,
4885 IDirect3DDeviceImpl_7_BeginStateBlock
,
4886 IDirect3DDeviceImpl_7_EndStateBlock
,
4887 IDirect3DDeviceImpl_7_PreLoad
,
4888 IDirect3DDeviceImpl_7_DrawPrimitive
,
4889 IDirect3DDeviceImpl_7_DrawIndexedPrimitive
,
4890 IDirect3DDeviceImpl_7_SetClipStatus
,
4891 IDirect3DDeviceImpl_7_GetClipStatus
,
4892 IDirect3DDeviceImpl_7_DrawPrimitiveStrided
,
4893 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided
,
4894 IDirect3DDeviceImpl_7_DrawPrimitiveVB
,
4895 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB
,
4896 IDirect3DDeviceImpl_7_ComputeSphereVisibility
,
4897 IDirect3DDeviceImpl_7_GetTexture
,
4898 IDirect3DDeviceImpl_7_SetTexture
,
4899 IDirect3DDeviceImpl_7_GetTextureStageState
,
4900 IDirect3DDeviceImpl_7_SetTextureStageState
,
4901 IDirect3DDeviceImpl_7_ValidateDevice
,
4902 IDirect3DDeviceImpl_7_ApplyStateBlock
,
4903 IDirect3DDeviceImpl_7_CaptureStateBlock
,
4904 IDirect3DDeviceImpl_7_DeleteStateBlock
,
4905 IDirect3DDeviceImpl_7_CreateStateBlock
,
4906 IDirect3DDeviceImpl_7_Load
,
4907 IDirect3DDeviceImpl_7_LightEnable
,
4908 IDirect3DDeviceImpl_7_GetLightEnable
,
4909 IDirect3DDeviceImpl_7_SetClipPlane
,
4910 IDirect3DDeviceImpl_7_GetClipPlane
,
4911 IDirect3DDeviceImpl_7_GetInfo
4914 const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl
=
4916 /*** IUnknown Methods ***/
4917 Thunk_IDirect3DDeviceImpl_3_QueryInterface
,
4918 Thunk_IDirect3DDeviceImpl_3_AddRef
,
4919 Thunk_IDirect3DDeviceImpl_3_Release
,
4920 /*** IDirect3DDevice3 ***/
4921 IDirect3DDeviceImpl_3_GetCaps
,
4922 IDirect3DDeviceImpl_3_GetStats
,
4923 IDirect3DDeviceImpl_3_AddViewport
,
4924 IDirect3DDeviceImpl_3_DeleteViewport
,
4925 IDirect3DDeviceImpl_3_NextViewport
,
4926 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats
,
4927 Thunk_IDirect3DDeviceImpl_3_BeginScene
,
4928 Thunk_IDirect3DDeviceImpl_3_EndScene
,
4929 Thunk_IDirect3DDeviceImpl_3_GetDirect3D
,
4930 IDirect3DDeviceImpl_3_SetCurrentViewport
,
4931 IDirect3DDeviceImpl_3_GetCurrentViewport
,
4932 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget
,
4933 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget
,
4934 IDirect3DDeviceImpl_3_Begin
,
4935 IDirect3DDeviceImpl_3_BeginIndexed
,
4936 IDirect3DDeviceImpl_3_Vertex
,
4937 IDirect3DDeviceImpl_3_Index
,
4938 IDirect3DDeviceImpl_3_End
,
4939 Thunk_IDirect3DDeviceImpl_3_GetRenderState
,
4940 Thunk_IDirect3DDeviceImpl_3_SetRenderState
,
4941 IDirect3DDeviceImpl_3_GetLightState
,
4942 IDirect3DDeviceImpl_3_SetLightState
,
4943 Thunk_IDirect3DDeviceImpl_3_SetTransform
,
4944 Thunk_IDirect3DDeviceImpl_3_GetTransform
,
4945 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform
,
4946 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive
,
4947 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive
,
4948 Thunk_IDirect3DDeviceImpl_3_SetClipStatus
,
4949 Thunk_IDirect3DDeviceImpl_3_GetClipStatus
,
4950 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided
,
4951 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided
,
4952 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB
,
4953 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB
,
4954 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility
,
4955 Thunk_IDirect3DDeviceImpl_3_GetTexture
,
4956 Thunk_IDirect3DDeviceImpl_3_SetTexture
,
4957 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState
,
4958 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState
,
4959 Thunk_IDirect3DDeviceImpl_3_ValidateDevice
4962 const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl
=
4964 /*** IUnknown Methods ***/
4965 Thunk_IDirect3DDeviceImpl_2_QueryInterface
,
4966 Thunk_IDirect3DDeviceImpl_2_AddRef
,
4967 Thunk_IDirect3DDeviceImpl_2_Release
,
4968 /*** IDirect3DDevice2 ***/
4969 Thunk_IDirect3DDeviceImpl_2_GetCaps
,
4970 IDirect3DDeviceImpl_2_SwapTextureHandles
,
4971 Thunk_IDirect3DDeviceImpl_2_GetStats
,
4972 Thunk_IDirect3DDeviceImpl_2_AddViewport
,
4973 Thunk_IDirect3DDeviceImpl_2_DeleteViewport
,
4974 Thunk_IDirect3DDeviceImpl_2_NextViewport
,
4975 IDirect3DDeviceImpl_2_EnumTextureFormats
,
4976 Thunk_IDirect3DDeviceImpl_2_BeginScene
,
4977 Thunk_IDirect3DDeviceImpl_2_EndScene
,
4978 Thunk_IDirect3DDeviceImpl_2_GetDirect3D
,
4979 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport
,
4980 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport
,
4981 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget
,
4982 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget
,
4983 Thunk_IDirect3DDeviceImpl_2_Begin
,
4984 Thunk_IDirect3DDeviceImpl_2_BeginIndexed
,
4985 Thunk_IDirect3DDeviceImpl_2_Vertex
,
4986 Thunk_IDirect3DDeviceImpl_2_Index
,
4987 Thunk_IDirect3DDeviceImpl_2_End
,
4988 Thunk_IDirect3DDeviceImpl_2_GetRenderState
,
4989 Thunk_IDirect3DDeviceImpl_2_SetRenderState
,
4990 Thunk_IDirect3DDeviceImpl_2_GetLightState
,
4991 Thunk_IDirect3DDeviceImpl_2_SetLightState
,
4992 Thunk_IDirect3DDeviceImpl_2_SetTransform
,
4993 Thunk_IDirect3DDeviceImpl_2_GetTransform
,
4994 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform
,
4995 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive
,
4996 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive
,
4997 Thunk_IDirect3DDeviceImpl_2_SetClipStatus
,
4998 Thunk_IDirect3DDeviceImpl_2_GetClipStatus
5001 const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl
=
5003 /*** IUnknown Methods ***/
5004 Thunk_IDirect3DDeviceImpl_1_QueryInterface
,
5005 Thunk_IDirect3DDeviceImpl_1_AddRef
,
5006 Thunk_IDirect3DDeviceImpl_1_Release
,
5007 /*** IDirect3DDevice1 ***/
5008 IDirect3DDeviceImpl_1_Initialize
,
5009 Thunk_IDirect3DDeviceImpl_1_GetCaps
,
5010 Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles
,
5011 IDirect3DDeviceImpl_1_CreateExecuteBuffer
,
5012 Thunk_IDirect3DDeviceImpl_1_GetStats
,
5013 IDirect3DDeviceImpl_1_Execute
,
5014 Thunk_IDirect3DDeviceImpl_1_AddViewport
,
5015 Thunk_IDirect3DDeviceImpl_1_DeleteViewport
,
5016 Thunk_IDirect3DDeviceImpl_1_NextViewport
,
5017 IDirect3DDeviceImpl_1_Pick
,
5018 IDirect3DDeviceImpl_1_GetPickRecords
,
5019 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats
,
5020 IDirect3DDeviceImpl_1_CreateMatrix
,
5021 IDirect3DDeviceImpl_1_SetMatrix
,
5022 IDirect3DDeviceImpl_1_GetMatrix
,
5023 IDirect3DDeviceImpl_1_DeleteMatrix
,
5024 Thunk_IDirect3DDeviceImpl_1_EndScene
,
5025 Thunk_IDirect3DDeviceImpl_1_BeginScene
,
5026 Thunk_IDirect3DDeviceImpl_1_GetDirect3D
5029 /*****************************************************************************
5030 * IDirect3DDeviceImpl_CreateHandle
5032 * Not called from the VTable
5034 * Some older interface versions operate with handles, which are basically
5035 * DWORDs which identify an interface, for example
5036 * IDirect3DDevice::SetRenderState with DIRECT3DRENDERSTATE_TEXTUREHANDLE
5038 * Those handle could be just casts to the interface pointers or vice versa,
5039 * but that is not 64 bit safe and would mean blindly derefering a DWORD
5040 * passed by the app. Instead there is a dynamic array in the device which
5041 * keeps a DWORD to pointer information and a type for the handle.
5043 * Basically this array only grows, when a handle is freed its pointer is
5044 * just set to NULL. There will be much more reads from the array than
5045 * insertion operations, so a dynamic array is fine.
5048 * This: D3DDevice implementation for which this handle should be created
5051 * A free handle on success
5054 *****************************************************************************/
5056 IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl
*This
)
5059 struct HandleEntry
*oldHandles
= This
->Handles
;
5061 TRACE("(%p)\n", This
);
5063 for(i
= 0; i
< This
->numHandles
; i
++)
5065 if(This
->Handles
[i
].ptr
== NULL
&&
5066 This
->Handles
[i
].type
== DDrawHandle_Unknown
)
5068 TRACE("Reusing freed handle %d\n", i
+ 1);
5073 TRACE("Growing the handle array\n");
5076 This
->Handles
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct HandleEntry
) * This
->numHandles
);
5079 ERR("Out of memory\n");
5080 This
->Handles
= oldHandles
;
5086 memcpy(This
->Handles
, oldHandles
, (This
->numHandles
- 1) * sizeof(struct HandleEntry
));
5087 HeapFree(GetProcessHeap(), 0, oldHandles
);
5090 TRACE("Returning %d\n", This
->numHandles
);
5091 return This
->numHandles
;