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
1431 * D3DERR_SCENE_IN_SCENE if WineD3D returns an error(Only in case of an already
1434 *****************************************************************************/
1435 static HRESULT WINAPI
1436 IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7
*iface
)
1438 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1440 TRACE("(%p): Relay\n", This
);
1442 hr
= IWineD3DDevice_BeginScene(This
->wineD3DDevice
);
1443 if(hr
== WINED3D_OK
) return D3D_OK
;
1444 else return D3DERR_SCENE_IN_SCENE
; /* TODO: Other possible causes of failure */
1447 static HRESULT WINAPI
1448 Thunk_IDirect3DDeviceImpl_3_BeginScene(IDirect3DDevice3
*iface
)
1450 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1451 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1452 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1455 static HRESULT WINAPI
1456 Thunk_IDirect3DDeviceImpl_2_BeginScene(IDirect3DDevice2
*iface
)
1458 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1459 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1460 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1463 static HRESULT WINAPI
1464 Thunk_IDirect3DDeviceImpl_1_BeginScene(IDirect3DDevice
*iface
)
1466 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1467 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1468 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1471 /*****************************************************************************
1472 * IDirect3DDevice7::EndScene
1474 * Ends a scene that has been begun with IDirect3DDevice7::BeginScene.
1475 * This method must be called after rendering is finished.
1477 * Version 1, 2, 3 and 7
1480 * D3D_OK on success, for details see IWineD3DDevice::EndScene
1481 * D3DERR_SCENE_NOT_IN_SCENE is returned if WineD3D returns an error. It does
1482 * that only if the scene was already ended.
1484 *****************************************************************************/
1485 static HRESULT WINAPI
1486 IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7
*iface
)
1488 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1490 TRACE("(%p): Relay\n", This
);
1492 hr
= IWineD3DDevice_EndScene(This
->wineD3DDevice
);
1493 if(hr
== WINED3D_OK
) return D3D_OK
;
1494 else return D3DERR_SCENE_NOT_IN_SCENE
;
1497 static HRESULT WINAPI
1498 Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3
*iface
)
1500 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1501 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1502 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1505 static HRESULT WINAPI
1506 Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2
*iface
)
1508 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1509 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1510 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1513 static HRESULT WINAPI
1514 Thunk_IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice
*iface
)
1516 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1517 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1518 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1521 /*****************************************************************************
1522 * IDirect3DDevice7::GetDirect3D
1524 * Returns the IDirect3D(= interface to the DirectDraw object) used to create
1528 * Direct3D7: Address to store the interface pointer at
1532 * DDERR_INVALIDPARAMS if Direct3D7 == NULL
1534 *****************************************************************************/
1535 static HRESULT WINAPI
1536 IDirect3DDeviceImpl_7_GetDirect3D(IDirect3DDevice7
*iface
,
1537 IDirect3D7
**Direct3D7
)
1539 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1540 TRACE("(%p)->(%p)\n", This
, Direct3D7
);
1543 return DDERR_INVALIDPARAMS
;
1545 *Direct3D7
= ICOM_INTERFACE(This
->ddraw
, IDirect3D7
);
1546 IDirect3D7_AddRef(*Direct3D7
);
1548 TRACE(" returning interface %p\n", *Direct3D7
);
1552 static HRESULT WINAPI
1553 Thunk_IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3
*iface
,
1554 IDirect3D3
**Direct3D3
)
1556 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1558 IDirect3D7
*ret_ptr
;
1560 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D3
);
1561 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1565 *Direct3D3
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D3
, ret_ptr
);
1566 TRACE(" returning interface %p\n", *Direct3D3
);
1570 static HRESULT WINAPI
1571 Thunk_IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2
*iface
,
1572 IDirect3D2
**Direct3D2
)
1574 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1576 IDirect3D7
*ret_ptr
;
1578 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D2
);
1579 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1583 *Direct3D2
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D2
, ret_ptr
);
1584 TRACE(" returning interface %p\n", *Direct3D2
);
1588 static HRESULT WINAPI
1589 Thunk_IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice
*iface
,
1590 IDirect3D
**Direct3D
)
1592 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1594 IDirect3D7
*ret_ptr
;
1596 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D
);
1597 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1601 *Direct3D
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D
, ret_ptr
);
1602 TRACE(" returning interface %p\n", *Direct3D
);
1606 /*****************************************************************************
1607 * IDirect3DDevice3::SetCurrentViewport
1609 * Sets a Direct3DViewport as the current viewport.
1610 * For the thunks note that all viewport interface versions are equal
1613 * Direct3DViewport3: The viewport to set
1619 * (Is a NULL viewport valid?)
1621 *****************************************************************************/
1622 static HRESULT WINAPI
1623 IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3
*iface
,
1624 IDirect3DViewport3
*Direct3DViewport3
)
1626 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1627 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport3
);
1628 TRACE("(%p)->(%p)\n", This
, Direct3DViewport3
);
1630 /* Do nothing if the specified viewport is the same as the current one */
1631 if (This
->current_viewport
== vp
)
1634 /* Should check if the viewport was added or not */
1636 /* Release previous viewport and AddRef the new one */
1637 if (This
->current_viewport
)
1639 TRACE("ViewportImpl is at %p, interface is at %p\n", This
->current_viewport
, ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
));
1640 IDirect3DViewport3_Release( ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
) );
1642 IDirect3DViewport3_AddRef(Direct3DViewport3
);
1644 /* Set this viewport as the current viewport */
1645 This
->current_viewport
= vp
;
1647 /* Activate this viewport */
1648 This
->current_viewport
->active_device
= This
;
1649 This
->current_viewport
->activate(This
->current_viewport
);
1654 static HRESULT WINAPI
1655 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2
*iface
,
1656 IDirect3DViewport2
*Direct3DViewport2
)
1658 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1659 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
1660 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
1661 return IDirect3DDevice3_SetCurrentViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1662 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
1665 /*****************************************************************************
1666 * IDirect3DDevice3::GetCurrentViewport
1668 * Returns the currently active viewport.
1673 * Direct3DViewport3: Address to return the interface pointer at
1677 * DDERR_INVALIDPARAMS if Direct3DViewport == NULL
1679 *****************************************************************************/
1680 static HRESULT WINAPI
1681 IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3
*iface
,
1682 IDirect3DViewport3
**Direct3DViewport3
)
1684 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1685 TRACE("(%p)->(%p)\n", This
, Direct3DViewport3
);
1687 if(!Direct3DViewport3
)
1688 return DDERR_INVALIDPARAMS
;
1690 *Direct3DViewport3
= ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
);
1692 /* AddRef the returned viewport */
1693 if(*Direct3DViewport3
) IDirect3DViewport3_AddRef(*Direct3DViewport3
);
1695 TRACE(" returning interface %p\n", *Direct3DViewport3
);
1700 static HRESULT WINAPI
1701 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(IDirect3DDevice2
*iface
,
1702 IDirect3DViewport2
**Direct3DViewport2
)
1704 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1706 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Direct3DViewport2
);
1707 hr
= IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1708 (IDirect3DViewport3
**) Direct3DViewport2
);
1709 if(hr
!= D3D_OK
) return hr
;
1710 *Direct3DViewport2
= (IDirect3DViewport2
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, *Direct3DViewport2
);
1714 /*****************************************************************************
1715 * IDirect3DDevice7::SetRenderTarget
1717 * Sets the render target for the Direct3DDevice.
1718 * For the thunks note that IDirectDrawSurface7 == IDirectDrawSurface4 and
1719 * IDirectDrawSurface3 == IDirectDrawSurface
1721 * Version 2, 3 and 7
1724 * NewTarget: Pointer to an IDirectDrawSurface7 interface to set as the new
1729 * D3D_OK on success, for details see IWineD3DDevice::SetRenderTarget
1731 *****************************************************************************/
1732 static HRESULT WINAPI
1733 IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7
*iface
,
1734 IDirectDrawSurface7
*NewTarget
,
1737 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1738 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, NewTarget
);
1739 TRACE("(%p)->(%p,%08x): Relay\n", This
, NewTarget
, Flags
);
1741 /* Flags: Not used */
1743 return IWineD3DDevice_SetRenderTarget(This
->wineD3DDevice
,
1745 Target
? Target
->WineD3DSurface
: NULL
);
1748 static HRESULT WINAPI
1749 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3
*iface
,
1750 IDirectDrawSurface4
*NewRenderTarget
,
1753 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1754 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, NewRenderTarget
);
1755 TRACE_(ddraw_thunk
)("(%p)->(%p,%08x) thunking to IDirect3DDevice7 interface.\n", This
, Target
, Flags
);
1756 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1757 ICOM_INTERFACE(Target
, IDirectDrawSurface7
),
1761 static HRESULT WINAPI
1762 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2
*iface
,
1763 IDirectDrawSurface
*NewRenderTarget
,
1766 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1767 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface3
, NewRenderTarget
);
1768 TRACE_(ddraw_thunk
)("(%p)->(%p,%08x) thunking to IDirect3DDevice7 interface.\n", This
, Target
, Flags
);
1769 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1770 ICOM_INTERFACE(Target
, IDirectDrawSurface7
),
1774 /*****************************************************************************
1775 * IDirect3DDevice7::GetRenderTarget
1777 * Returns the current render target.
1778 * This is handled locally, because the WineD3D render target's parent
1781 * Version 2, 3 and 7
1784 * RenderTarget: Address to store the surface interface pointer
1788 * DDERR_INVALIDPARAMS if RenderTarget == NULL
1790 *****************************************************************************/
1791 static HRESULT WINAPI
1792 IDirect3DDeviceImpl_7_GetRenderTarget(IDirect3DDevice7
*iface
,
1793 IDirectDrawSurface7
**RenderTarget
)
1795 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1796 TRACE("(%p)->(%p): Relay\n", This
, RenderTarget
);
1799 return DDERR_INVALIDPARAMS
;
1801 *RenderTarget
= ICOM_INTERFACE(This
->target
, IDirectDrawSurface7
);
1802 IDirectDrawSurface7_AddRef(*RenderTarget
);
1807 static HRESULT WINAPI
1808 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3
*iface
,
1809 IDirectDrawSurface4
**RenderTarget
)
1811 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1813 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, RenderTarget
);
1814 hr
= IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1815 (IDirectDrawSurface7
**) RenderTarget
);
1816 if(hr
!= D3D_OK
) return hr
;
1817 *RenderTarget
= (IDirectDrawSurface4
*) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirectDrawSurface7
, *RenderTarget
);
1821 static HRESULT WINAPI
1822 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(IDirect3DDevice2
*iface
,
1823 IDirectDrawSurface
**RenderTarget
)
1825 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1827 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, RenderTarget
);
1828 hr
= IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1829 (IDirectDrawSurface7
**) RenderTarget
);
1830 if(hr
!= D3D_OK
) return hr
;
1831 *RenderTarget
= (IDirectDrawSurface
*) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirectDrawSurface3
, *RenderTarget
);
1835 /*****************************************************************************
1836 * IDirect3DDevice3::Begin
1838 * Begins a description block of vertices. This is similar to glBegin()
1839 * and glEnd(). After a call to IDirect3DDevice3::End, the vertices
1840 * described with IDirect3DDevice::Vertex are drawn.
1845 * PrimitiveType: The type of primitives to draw
1846 * VertexTypeDesc: A flexible vertex format description of the vertices
1847 * Flags: Some flags..
1852 *****************************************************************************/
1853 static HRESULT WINAPI
1854 IDirect3DDeviceImpl_3_Begin(IDirect3DDevice3
*iface
,
1855 D3DPRIMITIVETYPE PrimitiveType
,
1856 DWORD VertexTypeDesc
,
1859 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1860 TRACE("(%p)->(%d,%d,%08x)\n", This
, PrimitiveType
, VertexTypeDesc
, Flags
);
1862 This
->primitive_type
= PrimitiveType
;
1863 This
->vertex_type
= VertexTypeDesc
;
1864 This
->render_flags
= Flags
;
1865 This
->vertex_size
= get_flexible_vertex_size(This
->vertex_type
);
1866 This
->nb_vertices
= 0;
1871 static HRESULT WINAPI
1872 Thunk_IDirect3DDeviceImpl_2_Begin(IDirect3DDevice2
*iface
,
1873 D3DPRIMITIVETYPE d3dpt
,
1874 D3DVERTEXTYPE dwVertexTypeDesc
,
1878 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1879 TRACE_(ddraw_thunk
)("(%p/%p)->(%08x,%08x,%08x): Thunking to IDirect3DDevice3\n", This
, iface
, d3dpt
, dwVertexTypeDesc
, dwFlags
);
1881 switch(dwVertexTypeDesc
)
1883 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
1884 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
1885 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
1887 ERR("Unexpected vertex type %d\n", dwVertexTypeDesc
);
1888 return DDERR_INVALIDPARAMS
; /* Should never happen */
1891 return IDirect3DDevice3_Begin(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1897 /*****************************************************************************
1898 * IDirect3DDevice3::BeginIndexed
1900 * Draws primitives based on vertices in a vertex array which are specified
1906 * PrimitiveType: Primitive type to draw
1907 * VertexType: A FVF description of the vertex format
1908 * Vertices: pointer to an array containing the vertices
1909 * NumVertices: The number of vertices in the vertex array
1910 * Flags: Some flags ...
1913 * D3D_OK, because it's a stub
1915 *****************************************************************************/
1916 static HRESULT WINAPI
1917 IDirect3DDeviceImpl_3_BeginIndexed(IDirect3DDevice3
*iface
,
1918 D3DPRIMITIVETYPE PrimitiveType
,
1924 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1925 FIXME("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This
, PrimitiveType
, VertexType
, Vertices
, NumVertices
, Flags
);
1930 static HRESULT WINAPI
1931 Thunk_IDirect3DDeviceImpl_2_BeginIndexed(IDirect3DDevice2
*iface
,
1932 D3DPRIMITIVETYPE d3dptPrimitiveType
,
1933 D3DVERTEXTYPE d3dvtVertexType
,
1935 DWORD dwNumVertices
,
1939 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1940 TRACE_(ddraw_thunk
)("(%p/%p)->(%08x,%08x,%p,%08x,%08x): Thunking to IDirect3DDevice3\n", This
, iface
, d3dptPrimitiveType
, d3dvtVertexType
, lpvVertices
, dwNumVertices
, dwFlags
);
1942 switch(d3dvtVertexType
)
1944 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
1945 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
1946 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
1948 ERR("Unexpected vertex type %d\n", d3dvtVertexType
);
1949 return DDERR_INVALIDPARAMS
; /* Should never happen */
1952 return IDirect3DDevice3_BeginIndexed(ICOM_INTERFACE(This
,IDirect3DDevice3
),
1960 /*****************************************************************************
1961 * IDirect3DDevice3::Vertex
1963 * Draws a vertex as described by IDirect3DDevice3::Begin. It places all
1964 * drawn vertices in a vertex buffer. If the buffer is too small, its
1965 * size is increased.
1970 * Vertex: Pointer to the vertex
1973 * D3D_OK, on success
1974 * DDERR_INVALIDPARAMS if Vertex is NULL
1976 *****************************************************************************/
1977 static HRESULT WINAPI
1978 IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3
*iface
,
1981 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1982 TRACE("(%p)->(%p)\n", This
, Vertex
);
1985 return DDERR_INVALIDPARAMS
;
1987 if ((This
->nb_vertices
+1)*This
->vertex_size
> This
->buffer_size
)
1990 This
->buffer_size
= This
->buffer_size
? This
->buffer_size
* 2 : This
->vertex_size
* 3;
1991 old_buffer
= This
->vertex_buffer
;
1992 This
->vertex_buffer
= HeapAlloc(GetProcessHeap(), 0, This
->buffer_size
);
1995 CopyMemory(This
->vertex_buffer
, old_buffer
, This
->nb_vertices
* This
->vertex_size
);
1996 HeapFree(GetProcessHeap(), 0, old_buffer
);
2000 CopyMemory(This
->vertex_buffer
+ This
->nb_vertices
++ * This
->vertex_size
, Vertex
, This
->vertex_size
);
2005 static HRESULT WINAPI
2006 Thunk_IDirect3DDeviceImpl_2_Vertex(IDirect3DDevice2
*iface
,
2009 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2010 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, lpVertexType
);
2011 return IDirect3DDevice3_Vertex(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2015 /*****************************************************************************
2016 * IDirect3DDevice3::Index
2018 * Specifies an index to a vertex to be drawn. The vertex array has to
2019 * be specified with BeginIndexed first.
2022 * VertexIndex: The index of the vertex to draw
2025 * D3D_OK because it's a stub
2027 *****************************************************************************/
2028 static HRESULT WINAPI
2029 IDirect3DDeviceImpl_3_Index(IDirect3DDevice3
*iface
,
2032 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2033 FIXME("(%p)->(%04x): stub!\n", This
, VertexIndex
);
2037 static HRESULT WINAPI
2038 Thunk_IDirect3DDeviceImpl_2_Index(IDirect3DDevice2
*iface
,
2041 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2042 TRACE_(ddraw_thunk
)("(%p)->(%04x) thunking to IDirect3DDevice3 interface.\n", This
, wVertexIndex
);
2043 return IDirect3DDevice3_Index(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2047 /*****************************************************************************
2048 * IDirect3DDevice3::End
2050 * Ends a draw begun with IDirect3DDevice3::Begin or
2051 * IDirect3DDevice::BeginIndexed. The vertices specified with
2052 * IDirect3DDevice::Vertex or IDirect3DDevice::Index are drawn using
2053 * the IDirect3DDevice7::DrawPrimitive method. So far only
2054 * non-indexed mode is supported
2059 * Flags: Some flags, as usual. Don't know which are defined
2062 * The return value of IDirect3DDevice7::DrawPrimitive
2064 *****************************************************************************/
2065 static HRESULT WINAPI
2066 IDirect3DDeviceImpl_3_End(IDirect3DDevice3
*iface
,
2069 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2070 TRACE("(%p)->(%08x)\n", This
, Flags
);
2072 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2073 This
->primitive_type
, This
->vertex_type
,
2074 This
->vertex_buffer
, This
->nb_vertices
,
2075 This
->render_flags
);
2078 static HRESULT WINAPI
2079 Thunk_IDirect3DDeviceImpl_2_End(IDirect3DDevice2
*iface
,
2082 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2083 TRACE_(ddraw_thunk
)("(%p)->(%08x) thunking to IDirect3DDevice3 interface.\n", This
, dwFlags
);
2084 return IDirect3DDevice3_End(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2088 /*****************************************************************************
2089 * IDirect3DDevice7::GetRenderState
2091 * Returns the value of a render state. The possible render states are
2092 * defined in include/d3dtypes.h
2094 * Version 2, 3 and 7
2097 * RenderStateType: Render state to return the current setting of
2098 * Value: Address to store the value at
2101 * D3D_OK on success, for details see IWineD3DDevice::GetRenderState
2102 * DDERR_INVALIDPARAMS if Value == NULL
2104 *****************************************************************************/
2105 static HRESULT WINAPI
2106 IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7
*iface
,
2107 D3DRENDERSTATETYPE RenderStateType
,
2110 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2112 TRACE("(%p)->(%08x,%p): Relay\n", This
, RenderStateType
, Value
);
2115 return DDERR_INVALIDPARAMS
;
2117 switch(RenderStateType
)
2119 case D3DRENDERSTATE_TEXTUREHANDLE
:
2121 /* This state is wrapped to SetTexture in SetRenderState, so
2122 * it has to be wrapped to GetTexture here
2124 IWineD3DBaseTexture
*tex
= NULL
;
2127 hr
= IWineD3DDevice_GetTexture(This
->wineD3DDevice
,
2131 if(hr
== WINED3D_OK
&& tex
)
2133 IDirectDrawSurface7
*parent
= NULL
;
2134 hr
= IWineD3DBaseTexture_GetParent(tex
,
2135 (IUnknown
**) &parent
);
2138 /* The parent of the texture is the IDirectDrawSurface7 interface
2139 * of the ddraw surface
2141 IDirectDrawSurfaceImpl
*texImpl
= ICOM_OBJECT(IDirectDrawSurfaceImpl
,
2142 IDirectDrawSurface7
,
2144 *Value
= texImpl
->Handle
;
2145 IDirectDrawSurface7_Release(parent
);
2147 IWineD3DBaseTexture_Release(tex
);
2152 case D3DRENDERSTATE_TEXTUREMAG
:
2154 WINED3DTEXTUREFILTERTYPE tex_mag
;
2156 hr
= IWineD3DDevice_GetSamplerState(This
->wineD3DDevice
,
2157 0, WINED3DSAMP_MAGFILTER
,
2162 case WINED3DTEXF_POINT
:
2163 *Value
= D3DFILTER_NEAREST
;
2165 case WINED3DTEXF_LINEAR
:
2166 *Value
= D3DFILTER_LINEAR
;
2169 ERR("Unhandled texture mag %d !\n",tex_mag
);
2175 case D3DRENDERSTATE_TEXTUREMIN
:
2177 WINED3DTEXTUREFILTERTYPE tex_min
;
2179 hr
= IWineD3DDevice_GetSamplerState(This
->wineD3DDevice
,
2180 0, WINED3DSAMP_MINFILTER
,
2185 case WINED3DTEXF_POINT
:
2186 *Value
= D3DFILTER_NEAREST
;
2188 case WINED3DTEXF_LINEAR
:
2189 *Value
= D3DFILTER_LINEAR
;
2192 ERR("Unhandled texture mag %d !\n",tex_min
);
2198 case D3DRENDERSTATE_TEXTUREADDRESSU
:
2199 case D3DRENDERSTATE_TEXTUREADDRESSV
:
2200 case D3DRENDERSTATE_TEXTUREADDRESS
:
2202 WINED3DTEXTURESTAGESTATETYPE TexStageStateType
;
2204 if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESS
)
2206 TexStageStateType
= WINED3DTSS_ADDRESS
;
2208 else if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESSU
)
2210 TexStageStateType
= WINED3DTSS_ADDRESSU
;
2214 TexStageStateType
= WINED3DTSS_ADDRESSV
;
2216 return IWineD3DDevice_GetTextureStageState(This
->wineD3DDevice
,
2217 0, TexStageStateType
,
2222 /* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
2223 return IWineD3DDevice_GetRenderState(This
->wineD3DDevice
,
2229 static HRESULT WINAPI
2230 Thunk_IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3
*iface
,
2231 D3DRENDERSTATETYPE dwRenderStateType
,
2232 DWORD
*lpdwRenderState
)
2234 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2235 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, dwRenderStateType
, lpdwRenderState
);
2236 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2241 static HRESULT WINAPI
2242 Thunk_IDirect3DDeviceImpl_2_GetRenderState(IDirect3DDevice2
*iface
,
2243 D3DRENDERSTATETYPE dwRenderStateType
,
2244 DWORD
*lpdwRenderState
)
2246 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2247 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, dwRenderStateType
, lpdwRenderState
);
2248 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2253 /*****************************************************************************
2254 * IDirect3DDevice7::SetRenderState
2256 * Sets a render state. The possible render states are defined in
2257 * include/d3dtypes.h
2259 * Version 2, 3 and 7
2262 * RenderStateType: State to set
2263 * Value: Value to assign to that state
2266 * D3D_OK on success,
2267 * for details see IWineD3DDevice::SetRenderState
2269 *****************************************************************************/
2270 static HRESULT WINAPI
2271 IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7
*iface
,
2272 D3DRENDERSTATETYPE RenderStateType
,
2275 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2276 TRACE("(%p)->(%08x,%d): Relay\n", This
, RenderStateType
, Value
);
2278 /* Some render states need special care */
2279 switch(RenderStateType
)
2281 case D3DRENDERSTATE_TEXTUREHANDLE
:
2285 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
2290 if(Value
> This
->numHandles
)
2292 FIXME("Specified handle %d out of range\n", Value
);
2293 return DDERR_INVALIDPARAMS
;
2295 if(This
->Handles
[Value
- 1].type
!= DDrawHandle_Texture
)
2297 FIXME("Handle %d isn't a texture handle\n", Value
);
2298 return DDERR_INVALIDPARAMS
;
2302 IDirectDrawSurfaceImpl
*surf
= (IDirectDrawSurfaceImpl
*) This
->Handles
[Value
- 1].ptr
;
2303 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
2305 (IWineD3DBaseTexture
*) surf
->wineD3DTexture
);
2309 case D3DRENDERSTATE_TEXTUREMAG
:
2311 WINED3DTEXTUREFILTERTYPE tex_mag
= WINED3DTEXF_NONE
;
2313 switch ((D3DTEXTUREFILTER
) Value
)
2315 case D3DFILTER_NEAREST
:
2316 tex_mag
= WINED3DTEXF_POINT
;
2318 case D3DFILTER_LINEAR
:
2319 tex_mag
= WINED3DTEXF_LINEAR
;
2322 ERR("Unhandled texture mag %d !\n",Value
);
2325 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
2326 0, WINED3DSAMP_MAGFILTER
,
2330 case D3DRENDERSTATE_TEXTUREMIN
:
2332 WINED3DTEXTUREFILTERTYPE tex_min
= WINED3DTEXF_NONE
;
2334 switch ((D3DTEXTUREFILTER
) Value
)
2336 case D3DFILTER_NEAREST
:
2337 tex_min
= WINED3DTEXF_POINT
;
2339 case D3DFILTER_LINEAR
:
2340 tex_min
= WINED3DTEXF_LINEAR
;
2343 ERR("Unhandled texture mag %d !\n",Value
);
2346 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
2347 0, WINED3DSAMP_MINFILTER
,
2351 case D3DRENDERSTATE_TEXTUREADDRESSU
:
2352 case D3DRENDERSTATE_TEXTUREADDRESSV
:
2353 case D3DRENDERSTATE_TEXTUREADDRESS
:
2355 WINED3DTEXTURESTAGESTATETYPE TexStageStateType
;
2357 if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESS
)
2359 TexStageStateType
= WINED3DTSS_ADDRESS
;
2361 else if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESSU
)
2363 TexStageStateType
= WINED3DTSS_ADDRESSU
;
2367 TexStageStateType
= WINED3DTSS_ADDRESSV
;
2370 return IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
,
2371 0, TexStageStateType
,
2375 case D3DRENDERSTATE_TEXTUREMAPBLEND
:
2377 /* Old texture combine setup style, superseded by texture stage states
2378 * in D3D7. It is safe for us to wrap it to texture stage states.
2380 switch ( (D3DTEXTUREBLEND
) Value
)
2382 case D3DTBLEND_MODULATE
:
2383 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLORARG1
, WINED3DTA_TEXTURE
);
2384 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG1
, WINED3DTA_TEXTURE
);
2385 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLORARG2
, WINED3DTA_CURRENT
);
2386 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLOROP
, WINED3DTOP_MODULATE
);
2387 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAOP
, WINED3DTOP_SELECTARG1
);
2390 case D3DTBLEND_MODULATEALPHA
:
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_COLORARG2
, WINED3DTA_CURRENT
);
2394 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG2
, WINED3DTA_CURRENT
);
2395 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLOROP
, WINED3DTOP_MODULATE
);
2396 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAOP
, WINED3DTOP_MODULATE
);
2399 case D3DTBLEND_DECAL
:
2400 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLORARG1
, WINED3DTA_TEXTURE
);
2401 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG1
, WINED3DTA_TEXTURE
);
2402 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLOROP
, WINED3DTOP_SELECTARG1
);
2403 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAOP
, WINED3DTOP_SELECTARG1
);
2406 case D3DTBLEND_DECALALPHA
:
2407 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLORARG1
, WINED3DTA_TEXTURE
);
2408 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG1
, WINED3DTA_TEXTURE
);
2409 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAARG2
, WINED3DTA_CURRENT
);
2410 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_COLOROP
, WINED3DTOP_SELECTARG1
);
2411 IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
, 0, WINED3DTSS_ALPHAOP
, WINED3DTOP_MODULATE
);
2415 ERR("Unhandled texture environment %d !\n",Value
);
2423 /* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
2425 return IWineD3DDevice_SetRenderState(This
->wineD3DDevice
,
2431 static HRESULT WINAPI
2432 Thunk_IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3
*iface
,
2433 D3DRENDERSTATETYPE RenderStateType
,
2436 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2437 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, RenderStateType
, Value
);
2438 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2443 static HRESULT WINAPI
2444 Thunk_IDirect3DDeviceImpl_2_SetRenderState(IDirect3DDevice2
*iface
,
2445 D3DRENDERSTATETYPE RenderStateType
,
2448 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2449 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, RenderStateType
, Value
);
2450 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2455 /*****************************************************************************
2456 * Direct3DDevice3::SetLightState
2458 * Sets a light state for Direct3DDevice3 and Direct3DDevice2. The
2459 * light states are forwarded to Direct3DDevice7 render states
2464 * LightStateType: The light state to change
2465 * Value: The value to assign to that light state
2469 * DDERR_INVALIDPARAMS if the parameters were incorrect
2470 * Also check IDirect3DDevice7::SetRenderState
2472 *****************************************************************************/
2473 static HRESULT WINAPI
2474 IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3
*iface
,
2475 D3DLIGHTSTATETYPE LightStateType
,
2478 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2480 TRACE("(%p)->(%08x,%08x)\n", This
, LightStateType
, Value
);
2482 if (!LightStateType
&& (LightStateType
> D3DLIGHTSTATE_COLORVERTEX
))
2484 TRACE("Unexpected Light State Type\n");
2485 return DDERR_INVALIDPARAMS
;
2488 if (LightStateType
== D3DLIGHTSTATE_MATERIAL
/* 1 */)
2490 IDirect3DMaterialImpl
*mat
;
2492 if(Value
== 0) mat
= NULL
;
2493 else if(Value
> This
->numHandles
)
2495 ERR("Material handle out of range(%d)\n", Value
);
2496 return DDERR_INVALIDPARAMS
;
2498 else if(This
->Handles
[Value
- 1].type
!= DDrawHandle_Material
)
2500 ERR("Invalid handle %d\n", Value
);
2501 return DDERR_INVALIDPARAMS
;
2505 mat
= (IDirect3DMaterialImpl
*) This
->Handles
[Value
- 1].ptr
;
2510 TRACE(" activating material %p.\n", mat
);
2515 FIXME(" D3DLIGHTSTATE_MATERIAL called with NULL material !!!\n");
2517 This
->material
= Value
;
2519 else if (LightStateType
== D3DLIGHTSTATE_COLORMODEL
/* 3 */)
2524 ERR("DDCOLOR_MONO should not happen!\n");
2527 /* We are already in this mode */
2528 TRACE("Setting color model to RGB (no-op).\n");
2531 ERR("Unknown color model!\n");
2532 return DDERR_INVALIDPARAMS
;
2537 D3DRENDERSTATETYPE rs
;
2538 switch (LightStateType
)
2540 case D3DLIGHTSTATE_AMBIENT
: /* 2 */
2541 rs
= D3DRENDERSTATE_AMBIENT
;
2543 case D3DLIGHTSTATE_FOGMODE
: /* 4 */
2544 rs
= D3DRENDERSTATE_FOGVERTEXMODE
;
2546 case D3DLIGHTSTATE_FOGSTART
: /* 5 */
2547 rs
= D3DRENDERSTATE_FOGSTART
;
2549 case D3DLIGHTSTATE_FOGEND
: /* 6 */
2550 rs
= D3DRENDERSTATE_FOGEND
;
2552 case D3DLIGHTSTATE_FOGDENSITY
: /* 7 */
2553 rs
= D3DRENDERSTATE_FOGDENSITY
;
2555 case D3DLIGHTSTATE_COLORVERTEX
: /* 8 */
2556 rs
= D3DRENDERSTATE_COLORVERTEX
;
2559 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType
);
2560 return DDERR_INVALIDPARAMS
;
2563 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2571 static HRESULT WINAPI
2572 Thunk_IDirect3DDeviceImpl_2_SetLightState(IDirect3DDevice2
*iface
,
2573 D3DLIGHTSTATETYPE LightStateType
,
2576 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2577 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x) thunking to IDirect3DDevice3 interface.\n", This
, LightStateType
, Value
);
2578 return IDirect3DDevice3_SetLightState(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2583 /*****************************************************************************
2584 * IDirect3DDevice3::GetLightState
2586 * Returns the current setting of a light state. The state is read from
2587 * the Direct3DDevice7 render state.
2592 * LightStateType: The light state to return
2593 * Value: The address to store the light state setting at
2597 * DDDERR_INVALIDPARAMS if the parameters were incorrect
2598 * Also see IDirect3DDevice7::GetRenderState
2600 *****************************************************************************/
2601 static HRESULT WINAPI
2602 IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3
*iface
,
2603 D3DLIGHTSTATETYPE LightStateType
,
2606 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2608 TRACE("(%p)->(%08x,%p)\n", This
, LightStateType
, Value
);
2610 if (!LightStateType
&& (LightStateType
> D3DLIGHTSTATE_COLORVERTEX
))
2612 TRACE("Unexpected Light State Type\n");
2613 return DDERR_INVALIDPARAMS
;
2617 return DDERR_INVALIDPARAMS
;
2619 if (LightStateType
== D3DLIGHTSTATE_MATERIAL
/* 1 */)
2621 *Value
= This
->material
;
2623 else if (LightStateType
== D3DLIGHTSTATE_COLORMODEL
/* 3 */)
2625 *Value
= D3DCOLOR_RGB
;
2629 D3DRENDERSTATETYPE rs
;
2630 switch (LightStateType
)
2632 case D3DLIGHTSTATE_AMBIENT
: /* 2 */
2633 rs
= D3DRENDERSTATE_AMBIENT
;
2635 case D3DLIGHTSTATE_FOGMODE
: /* 4 */
2636 rs
= D3DRENDERSTATE_FOGVERTEXMODE
;
2638 case D3DLIGHTSTATE_FOGSTART
: /* 5 */
2639 rs
= D3DRENDERSTATE_FOGSTART
;
2641 case D3DLIGHTSTATE_FOGEND
: /* 6 */
2642 rs
= D3DRENDERSTATE_FOGEND
;
2644 case D3DLIGHTSTATE_FOGDENSITY
: /* 7 */
2645 rs
= D3DRENDERSTATE_FOGDENSITY
;
2647 case D3DLIGHTSTATE_COLORVERTEX
: /* 8 */
2648 rs
= D3DRENDERSTATE_COLORVERTEX
;
2651 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType
);
2652 return DDERR_INVALIDPARAMS
;
2655 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2663 static HRESULT WINAPI
2664 Thunk_IDirect3DDeviceImpl_2_GetLightState(IDirect3DDevice2
*iface
,
2665 D3DLIGHTSTATETYPE LightStateType
,
2668 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2669 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice3 interface.\n", This
, LightStateType
, Value
);
2670 return IDirect3DDevice3_GetLightState(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2675 /*****************************************************************************
2676 * IDirect3DDevice7::SetTransform
2678 * Assigns a D3DMATRIX to a transform type. The transform types are defined
2679 * in include/d3dtypes.h.
2680 * The D3DTRANSFORMSTATE_WORLD (=1) is translated to D3DTS_WORLDMATRIX(0)
2681 * (=255) for wined3d, because the 1 transform state was removed in d3d8
2682 * and WineD3D already understands the replacement D3DTS_WORLDMATRIX(0)
2684 * Version 2, 3 and 7
2687 * TransformStateType: transform state to set
2688 * Matrix: Matrix to assign to the state
2692 * DDERR_INVALIDPARAMS if Matrix == NULL
2693 * For details see IWineD3DDevice::SetTransform
2695 *****************************************************************************/
2696 static HRESULT WINAPI
2697 IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7
*iface
,
2698 D3DTRANSFORMSTATETYPE TransformStateType
,
2701 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2702 D3DTRANSFORMSTATETYPE type
= TransformStateType
;
2703 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, Matrix
);
2706 return DDERR_INVALIDPARAMS
;
2708 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2709 * use D3DTS_WORLDMATRIX(0) instead
2710 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2712 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2713 type
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2716 Unhandled: D3DTRANSFORMSTATE_WORLD1
2717 Unhandled: D3DTRANSFORMSTATE_WORLD2
2718 Unhandled: D3DTRANSFORMSTATE_WORLD3
2721 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
2722 return IWineD3DDevice_SetTransform(This
->wineD3DDevice
,
2724 (WINED3DMATRIX
*) Matrix
);
2727 static HRESULT WINAPI
2728 Thunk_IDirect3DDeviceImpl_3_SetTransform(IDirect3DDevice3
*iface
,
2729 D3DTRANSFORMSTATETYPE TransformStateType
,
2730 D3DMATRIX
*D3DMatrix
)
2732 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2733 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2734 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2739 static HRESULT WINAPI
2740 Thunk_IDirect3DDeviceImpl_2_SetTransform(IDirect3DDevice2
*iface
,
2741 D3DTRANSFORMSTATETYPE TransformStateType
,
2742 D3DMATRIX
*D3DMatrix
)
2744 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2745 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2746 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2751 /*****************************************************************************
2752 * IDirect3DDevice7::GetTransform
2754 * Returns the matrix assigned to a transform state
2755 * D3DTRANSFORMSTATE_WORLD is translated to D3DTS_WORLDMATRIX(0), see
2759 * TransformStateType: State to read the matrix from
2760 * Matrix: Address to store the matrix at
2764 * DDERR_INVALIDPARAMS if Matrix == NULL
2765 * For details, see IWineD3DDevice::GetTransform
2767 *****************************************************************************/
2768 static HRESULT WINAPI
2769 IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7
*iface
,
2770 D3DTRANSFORMSTATETYPE TransformStateType
,
2773 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2774 D3DTRANSFORMSTATETYPE type
= TransformStateType
;
2775 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, Matrix
);
2778 return DDERR_INVALIDPARAMS
;
2780 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2781 * use D3DTS_WORLDMATRIX(0) instead
2782 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2784 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2785 type
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2788 Unhandled: D3DTRANSFORMSTATE_WORLD1
2789 Unhandled: D3DTRANSFORMSTATE_WORLD2
2790 Unhandled: D3DTRANSFORMSTATE_WORLD3
2793 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
2794 return IWineD3DDevice_GetTransform(This
->wineD3DDevice
, type
, (WINED3DMATRIX
*) Matrix
);
2797 static HRESULT WINAPI
2798 Thunk_IDirect3DDeviceImpl_3_GetTransform(IDirect3DDevice3
*iface
,
2799 D3DTRANSFORMSTATETYPE TransformStateType
,
2800 D3DMATRIX
*D3DMatrix
)
2802 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2803 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2804 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2809 static HRESULT WINAPI
2810 Thunk_IDirect3DDeviceImpl_2_GetTransform(IDirect3DDevice2
*iface
,
2811 D3DTRANSFORMSTATETYPE TransformStateType
,
2812 D3DMATRIX
*D3DMatrix
)
2814 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2815 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2816 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2821 /*****************************************************************************
2822 * IDirect3DDevice7::MultiplyTransform
2824 * Multiplies the already-set transform matrix of a transform state
2825 * with another matrix. For the world matrix, see SetTransform
2827 * Version 2, 3 and 7
2830 * TransformStateType: Transform state to multiply
2831 * D3DMatrix Matrix to multiply with.
2835 * DDERR_INVALIDPARAMS if D3DMatrix is NULL
2836 * For details, see IWineD3DDevice::MultiplyTransform
2838 *****************************************************************************/
2839 static HRESULT WINAPI
2840 IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7
*iface
,
2841 D3DTRANSFORMSTATETYPE TransformStateType
,
2842 D3DMATRIX
*D3DMatrix
)
2844 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2845 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, D3DMatrix
);
2847 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2848 * use D3DTS_WORLDMATRIX(0) instead
2849 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2851 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2852 TransformStateType
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2855 Unhandled: D3DTRANSFORMSTATE_WORLD1
2856 Unhandled: D3DTRANSFORMSTATE_WORLD2
2857 Unhandled: D3DTRANSFORMSTATE_WORLD3
2860 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
2861 return IWineD3DDevice_MultiplyTransform(This
->wineD3DDevice
,
2863 (WINED3DMATRIX
*) D3DMatrix
);
2866 static HRESULT WINAPI
2867 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(IDirect3DDevice3
*iface
,
2868 D3DTRANSFORMSTATETYPE TransformStateType
,
2869 D3DMATRIX
*D3DMatrix
)
2871 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2872 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2873 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2878 static HRESULT WINAPI
2879 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform(IDirect3DDevice2
*iface
,
2880 D3DTRANSFORMSTATETYPE TransformStateType
,
2881 D3DMATRIX
*D3DMatrix
)
2883 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2884 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2885 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2890 /*****************************************************************************
2891 * IDirect3DDevice7::DrawPrimitive
2893 * Draws primitives based on vertices in an application-provided pointer
2895 * Version 2, 3 and 7. The IDirect3DDevice2 thunk converts the fixed vertex type into
2896 * an FVF format for D3D7
2899 * PrimitiveType: The type of the primitives to draw
2900 * Vertex type: Flexible vertex format vertex description
2901 * Vertices: Pointer to the vertex array
2902 * VertexCount: The number of vertices to draw
2903 * Flags: As usual a few flags
2907 * DDERR_INVALIDPARAMS if Vertices is NULL
2908 * For details, see IWineD3DDevice::DrawPrimitiveUP
2910 *****************************************************************************/
2911 static HRESULT WINAPI
2912 IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7
*iface
,
2913 D3DPRIMITIVETYPE PrimitiveType
,
2919 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2920 UINT PrimitiveCount
, stride
;
2922 TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): Relay!\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2925 return DDERR_INVALIDPARAMS
;
2927 /* Get the vertex count */
2928 switch(PrimitiveType
)
2930 case D3DPT_POINTLIST
:
2931 PrimitiveCount
= VertexCount
;
2934 case D3DPT_LINELIST
:
2935 PrimitiveCount
= VertexCount
/ 2;
2938 case D3DPT_LINESTRIP
:
2939 PrimitiveCount
= VertexCount
- 1;
2942 case D3DPT_TRIANGLELIST
:
2943 PrimitiveCount
= VertexCount
/ 3;
2946 case D3DPT_TRIANGLESTRIP
:
2947 PrimitiveCount
= VertexCount
- 2;
2950 case D3DPT_TRIANGLEFAN
:
2951 PrimitiveCount
= VertexCount
- 2;
2954 default: return DDERR_INVALIDPARAMS
;
2957 /* Get the stride */
2958 stride
= get_flexible_vertex_size(VertexType
);
2961 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, VertexType
);
2962 if(hr
!= D3D_OK
) return hr
;
2964 /* This method translates to the user pointer draw of WineD3D */
2965 return IWineD3DDevice_DrawPrimitiveUP(This
->wineD3DDevice
,
2972 static HRESULT WINAPI
2973 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(IDirect3DDevice3
*iface
,
2974 D3DPRIMITIVETYPE PrimitiveType
,
2980 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2981 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2982 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2990 static HRESULT WINAPI
2991 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive(IDirect3DDevice2
*iface
,
2992 D3DPRIMITIVETYPE PrimitiveType
,
2993 D3DVERTEXTYPE VertexType
,
2998 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3000 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
3004 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
3005 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
3006 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
3008 ERR("Unexpected vertex type %d\n", VertexType
);
3009 return DDERR_INVALIDPARAMS
; /* Should never happen */
3012 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3020 /*****************************************************************************
3021 * IDirect3DDevice7::DrawIndexedPrimitive
3023 * Draws vertices from an application-provided pointer, based on the index
3024 * numbers in a WORD array.
3026 * Version 2, 3 and 7. The version 7 thunk translates the vertex type into
3027 * an FVF format for D3D7
3030 * PrimitiveType: The primitive type to draw
3031 * VertexType: The FVF vertex description
3032 * Vertices: Pointer to the vertex array
3034 * Indices: Pointer to the index array
3035 * IndexCount: Number of indices = Number of vertices to draw
3036 * Flags: As usual, some flags
3040 * DDERR_INVALIDPARAMS if Vertices or Indices is NULL
3041 * For details, see IWineD3DDevice::DrawIndexedPrimitiveUP
3043 *****************************************************************************/
3044 static HRESULT WINAPI
3045 IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7
*iface
,
3046 D3DPRIMITIVETYPE PrimitiveType
,
3054 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3055 UINT PrimitiveCount
= 0;
3057 TRACE("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): Relay!\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
3058 /* Get the primitive number */
3059 switch(PrimitiveType
)
3061 case D3DPT_POINTLIST
:
3062 PrimitiveCount
= IndexCount
;
3065 case D3DPT_LINELIST
:
3066 PrimitiveCount
= IndexCount
/ 2;
3069 case D3DPT_LINESTRIP
:
3070 PrimitiveCount
= IndexCount
- 1;
3073 case D3DPT_TRIANGLELIST
:
3074 PrimitiveCount
= IndexCount
/ 3;
3077 case D3DPT_TRIANGLESTRIP
:
3078 PrimitiveCount
= IndexCount
- 2;
3081 case D3DPT_TRIANGLEFAN
:
3082 PrimitiveCount
= IndexCount
- 2;
3085 default: return DDERR_INVALIDPARAMS
;
3088 /* Set the D3DDevice's FVF */
3089 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, VertexType
);
3092 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This
, hr
);
3096 return IWineD3DDevice_DrawIndexedPrimitiveUP(This
->wineD3DDevice
,
3098 0 /* MinVertexIndex */,
3099 VertexCount
/* UINT NumVertexIndex */,
3104 get_flexible_vertex_size(VertexType
));
3107 static HRESULT WINAPI
3108 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(IDirect3DDevice3
*iface
,
3109 D3DPRIMITIVETYPE PrimitiveType
,
3117 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3118 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
3119 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3129 static HRESULT WINAPI
3130 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(IDirect3DDevice2
*iface
,
3131 D3DPRIMITIVETYPE PrimitiveType
,
3132 D3DVERTEXTYPE VertexType
,
3140 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3141 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
3145 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
3146 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
3147 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
3149 ERR("Unexpected vertex type %d\n", VertexType
);
3150 return DDERR_INVALIDPARAMS
; /* Should never happen */
3153 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3163 /*****************************************************************************
3164 * IDirect3DDevice7::SetClipStatus
3166 * Sets the clip status. This defines things as clipping conditions and
3167 * the extents of the clipping region.
3169 * Version 2, 3 and 7
3175 * D3D_OK because it's a stub
3176 * (DDERR_INVALIDPARAMS if ClipStatus == NULL)
3178 *****************************************************************************/
3179 static HRESULT WINAPI
3180 IDirect3DDeviceImpl_7_SetClipStatus(IDirect3DDevice7
*iface
,
3181 D3DCLIPSTATUS
*ClipStatus
)
3183 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3184 FIXME("(%p)->(%p): Stub!\n", This
, ClipStatus
);
3186 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them
3187 * Perhaps this needs a new data type and an additional IWineD3DDevice method
3189 /* return IWineD3DDevice_SetClipStatus(This->wineD3DDevice, ClipStatus);*/
3193 static HRESULT WINAPI
3194 Thunk_IDirect3DDeviceImpl_3_SetClipStatus(IDirect3DDevice3
*iface
,
3195 D3DCLIPSTATUS
*ClipStatus
)
3197 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3198 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3199 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3203 static HRESULT WINAPI
3204 Thunk_IDirect3DDeviceImpl_2_SetClipStatus(IDirect3DDevice2
*iface
,
3205 D3DCLIPSTATUS
*ClipStatus
)
3207 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3208 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3209 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3213 /*****************************************************************************
3214 * IDirect3DDevice7::GetClipStatus
3216 * Returns the clip status
3219 * ClipStatus: Address to write the clip status to
3222 * D3D_OK because it's a stub
3224 *****************************************************************************/
3225 static HRESULT WINAPI
3226 IDirect3DDeviceImpl_7_GetClipStatus(IDirect3DDevice7
*iface
,
3227 D3DCLIPSTATUS
*ClipStatus
)
3229 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3230 FIXME("(%p)->(%p): Stub!\n", This
, ClipStatus
);
3232 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them */
3233 /* return IWineD3DDevice_GetClipStatus(This->wineD3DDevice, ClipStatus);*/
3237 static HRESULT WINAPI
3238 Thunk_IDirect3DDeviceImpl_3_GetClipStatus(IDirect3DDevice3
*iface
,
3239 D3DCLIPSTATUS
*ClipStatus
)
3241 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3242 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3243 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3247 static HRESULT WINAPI
3248 Thunk_IDirect3DDeviceImpl_2_GetClipStatus(IDirect3DDevice2
*iface
,
3249 D3DCLIPSTATUS
*ClipStatus
)
3251 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
3252 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
3253 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3257 /*****************************************************************************
3258 * IDirect3DDevice::DrawPrimitiveStrided
3260 * Draws vertices described by a D3DDRAWPRIMITIVESTRIDEDDATA structure.
3265 * PrimitiveType: The primitive type to draw
3266 * VertexType: The FVF description of the vertices to draw (for the stride??)
3267 * D3DDrawPrimStrideData: A D3DDRAWPRIMITIVESTRIDEDDATA structure describing
3268 * the vertex data locations
3269 * VertexCount: The number of vertices to draw
3273 * D3D_OK, because it's a stub
3274 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3275 * (For details, see IWineD3DDevice::DrawPrimitiveStrided)
3277 *****************************************************************************/
3278 static HRESULT WINAPI
3279 IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7
*iface
,
3280 D3DPRIMITIVETYPE PrimitiveType
,
3282 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3286 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3287 WineDirect3DVertexStridedData WineD3DStrided
;
3289 UINT PrimitiveCount
;
3291 TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Flags
);
3293 memset(&WineD3DStrided
, 0, sizeof(WineD3DStrided
));
3294 /* Get the strided data right. the wined3d structure is a bit bigger
3295 * Watch out: The contents of the strided data are determined by the fvf,
3296 * not by the members set in D3DDrawPrimStrideData. So it's valid
3297 * to have diffuse.lpvData set to 0xdeadbeef if the diffuse flag is
3298 * not set in the fvf.
3300 if(VertexType
& D3DFVF_POSITION_MASK
)
3302 WineD3DStrided
.u
.s
.position
.lpData
= D3DDrawPrimStrideData
->position
.lpvData
;
3303 WineD3DStrided
.u
.s
.position
.dwStride
= D3DDrawPrimStrideData
->position
.dwStride
;
3304 WineD3DStrided
.u
.s
.position
.dwType
= WINED3DDECLTYPE_FLOAT3
;
3305 if (VertexType
& D3DFVF_XYZRHW
)
3307 WineD3DStrided
.u
.s
.position
.dwType
= WINED3DDECLTYPE_FLOAT4
;
3308 WineD3DStrided
.u
.s
.position_transformed
= TRUE
;
3310 WineD3DStrided
.u
.s
.position_transformed
= FALSE
;
3313 if(VertexType
& D3DFVF_NORMAL
)
3315 WineD3DStrided
.u
.s
.normal
.lpData
= D3DDrawPrimStrideData
->normal
.lpvData
;
3316 WineD3DStrided
.u
.s
.normal
.dwStride
= D3DDrawPrimStrideData
->normal
.dwStride
;
3317 WineD3DStrided
.u
.s
.normal
.dwType
= WINED3DDECLTYPE_FLOAT3
;
3320 if(VertexType
& D3DFVF_DIFFUSE
)
3322 WineD3DStrided
.u
.s
.diffuse
.lpData
= D3DDrawPrimStrideData
->diffuse
.lpvData
;
3323 WineD3DStrided
.u
.s
.diffuse
.dwStride
= D3DDrawPrimStrideData
->diffuse
.dwStride
;
3324 WineD3DStrided
.u
.s
.diffuse
.dwType
= WINED3DDECLTYPE_SHORT4
;
3327 if(VertexType
& D3DFVF_SPECULAR
)
3329 WineD3DStrided
.u
.s
.specular
.lpData
= D3DDrawPrimStrideData
->specular
.lpvData
;
3330 WineD3DStrided
.u
.s
.specular
.dwStride
= D3DDrawPrimStrideData
->specular
.dwStride
;
3331 WineD3DStrided
.u
.s
.specular
.dwType
= WINED3DDECLTYPE_SHORT4
;
3334 for( i
= 0; i
< GET_TEXCOUNT_FROM_FVF(VertexType
); i
++)
3336 WineD3DStrided
.u
.s
.texCoords
[i
].lpData
= D3DDrawPrimStrideData
->textureCoords
[i
].lpvData
;
3337 WineD3DStrided
.u
.s
.texCoords
[i
].dwStride
= D3DDrawPrimStrideData
->textureCoords
[i
].dwStride
;
3338 switch(GET_TEXCOORD_SIZE_FROM_FVF(VertexType
, i
))
3340 case 1: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT1
; break;
3341 case 2: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT2
; break;
3342 case 3: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT3
; break;
3343 case 4: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT4
; break;
3344 default: ERR("Unexpected texture coordinate size %d\n",
3345 GET_TEXCOORD_SIZE_FROM_FVF(VertexType
, i
));
3349 /* Get the primitive count */
3350 switch(PrimitiveType
)
3352 case D3DPT_POINTLIST
:
3353 PrimitiveCount
= VertexCount
;
3356 case D3DPT_LINELIST
:
3357 PrimitiveCount
= VertexCount
/ 2;
3360 case D3DPT_LINESTRIP
:
3361 PrimitiveCount
= VertexCount
- 1;
3364 case D3DPT_TRIANGLELIST
:
3365 PrimitiveCount
= VertexCount
/ 3;
3368 case D3DPT_TRIANGLESTRIP
:
3369 PrimitiveCount
= VertexCount
- 2;
3372 case D3DPT_TRIANGLEFAN
:
3373 PrimitiveCount
= VertexCount
- 2;
3376 default: return DDERR_INVALIDPARAMS
;
3379 IWineD3DDevice_SetFVF(This
->wineD3DDevice
,
3382 return IWineD3DDevice_DrawPrimitiveStrided(This
->wineD3DDevice
,
3388 static HRESULT WINAPI
3389 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided(IDirect3DDevice3
*iface
,
3390 D3DPRIMITIVETYPE PrimitiveType
,
3392 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3396 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3397 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Flags
);
3398 return IDirect3DDevice7_DrawPrimitiveStrided(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3401 D3DDrawPrimStrideData
,
3406 /*****************************************************************************
3407 * IDirect3DDevice7::DrawIndexedPrimitiveStrided
3409 * Draws primitives specified by strided data locations based on indices
3417 * D3D_OK, because it's a stub
3418 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3419 * (DDERR_INVALIDPARAMS if Indices is NULL)
3420 * (For more details, see IWineD3DDevice::DrawIndexedPrimitiveStrided)
3422 *****************************************************************************/
3423 static HRESULT WINAPI
3424 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7
*iface
,
3425 D3DPRIMITIVETYPE PrimitiveType
,
3427 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3433 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3434 FIXME("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): stub!\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Indices
, IndexCount
, Flags
);
3436 /* I'll implement it as soon as I find a app to test it.
3437 * This needs an additional method in IWineD3DDevice.
3442 static HRESULT WINAPI
3443 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(IDirect3DDevice3
*iface
,
3444 D3DPRIMITIVETYPE PrimitiveType
,
3446 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3452 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3453 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", iface
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Indices
, IndexCount
, Flags
);
3454 return IDirect3DDevice7_DrawIndexedPrimitiveStrided(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3457 D3DDrawPrimStrideData
,
3464 /*****************************************************************************
3465 * IDirect3DDevice7::DrawPrimitiveVB
3467 * Draws primitives from a vertex buffer to the screen.
3472 * PrimitiveType: Type of primitive to be rendered.
3473 * D3DVertexBuf: Source Vertex Buffer
3474 * StartVertex: Index of the first vertex from the buffer to be rendered
3475 * NumVertices: Number of vertices to be rendered
3476 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3480 * DDERR_INVALIDPARAMS if D3DVertexBuf is NULL
3482 *****************************************************************************/
3483 static HRESULT WINAPI
3484 IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7
*iface
,
3485 D3DPRIMITIVETYPE PrimitiveType
,
3486 IDirect3DVertexBuffer7
*D3DVertexBuf
,
3491 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3492 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer7
, D3DVertexBuf
);
3493 UINT PrimitiveCount
;
3496 WINED3DVERTEXBUFFER_DESC Desc
;
3498 TRACE("(%p)->(%08x,%p,%08x,%08x,%08x)\n", This
, PrimitiveType
, D3DVertexBuf
, StartVertex
, NumVertices
, Flags
);
3503 ERR("(%p) No Vertex buffer specified\n", This
);
3504 return DDERR_INVALIDPARAMS
;
3507 /* Get the primitive count */
3508 switch(PrimitiveType
)
3510 case D3DPT_POINTLIST
:
3511 PrimitiveCount
= NumVertices
;
3514 case D3DPT_LINELIST
:
3515 PrimitiveCount
= NumVertices
/ 2;
3518 case D3DPT_LINESTRIP
:
3519 PrimitiveCount
= NumVertices
- 1;
3522 case D3DPT_TRIANGLELIST
:
3523 PrimitiveCount
= NumVertices
/ 3;
3526 case D3DPT_TRIANGLESTRIP
:
3527 PrimitiveCount
= NumVertices
- 2;
3530 case D3DPT_TRIANGLEFAN
:
3531 PrimitiveCount
= NumVertices
- 2;
3534 default: return DDERR_INVALIDPARAMS
;
3537 /* Get the FVF of the vertex buffer, and its stride */
3538 hr
= IWineD3DVertexBuffer_GetDesc(vb
->wineD3DVertexBuffer
,
3542 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x\n", This
, hr
);
3545 stride
= get_flexible_vertex_size(Desc
.FVF
);
3547 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, Desc
.FVF
);
3550 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This
, hr
);
3554 /* Set the vertex stream source */
3555 hr
= IWineD3DDevice_SetStreamSource(This
->wineD3DDevice
,
3556 0 /* StreamNumber */,
3557 vb
->wineD3DVertexBuffer
,
3558 0 /* StartVertex - we pass this to DrawPrimitive */,
3562 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This
, hr
);
3566 /* Now draw the primitives */
3567 return IWineD3DDevice_DrawPrimitive(This
->wineD3DDevice
,
3573 static HRESULT WINAPI
3574 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3
*iface
,
3575 D3DPRIMITIVETYPE PrimitiveType
,
3576 IDirect3DVertexBuffer
*D3DVertexBuf
,
3581 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3582 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer
, D3DVertexBuf
);
3583 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p,%08x,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, vb
, StartVertex
, NumVertices
, Flags
);
3584 return IDirect3DDevice7_DrawPrimitiveVB(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3586 ICOM_INTERFACE(vb
, IDirect3DVertexBuffer7
),
3593 /*****************************************************************************
3594 * IDirect3DDevice7::DrawIndexedPrimitiveVB
3596 * Draws primitives from a vertex buffer to the screen
3599 * PrimitiveType: Type of primitive to be rendered.
3600 * D3DVertexBuf: Source Vertex Buffer
3601 * StartVertex: Index of the first vertex from the buffer to be rendered
3602 * NumVertices: Number of vertices to be rendered
3603 * Indices: Array of DWORDs used to index into the Vertices
3604 * IndexCount: Number of indices in Indices
3605 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3609 *****************************************************************************/
3610 static HRESULT WINAPI
3611 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7
*iface
,
3612 D3DPRIMITIVETYPE PrimitiveType
,
3613 IDirect3DVertexBuffer7
*D3DVertexBuf
,
3620 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3621 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer7
, D3DVertexBuf
);
3623 UINT PrimitiveCount
;
3624 WORD
*LockedIndices
;
3626 WINED3DVERTEXBUFFER_DESC Desc
;
3628 TRACE("(%p)->(%08x,%p,%d,%d,%p,%d,%08x)\n", This
, PrimitiveType
, vb
, StartVertex
, NumVertices
, Indices
, IndexCount
, Flags
);
3631 * 1) Calculate some things: Vertex count -> Primitive count, stride, ...
3632 * 2) Upload the Indices to the index buffer
3633 * 3) Set the index source
3634 * 4) Set the Vertex Buffer as the Stream source
3635 * 5) Call IWineD3DDevice::DrawIndexedPrimitive
3638 /* Get the primitive count */
3639 switch(PrimitiveType
)
3641 case D3DPT_POINTLIST
:
3642 PrimitiveCount
= IndexCount
;
3645 case D3DPT_LINELIST
:
3646 PrimitiveCount
= IndexCount
/ 2;
3649 case D3DPT_LINESTRIP
:
3650 PrimitiveCount
= IndexCount
- 1;
3653 case D3DPT_TRIANGLELIST
:
3654 PrimitiveCount
= IndexCount
/ 3;
3657 case D3DPT_TRIANGLESTRIP
:
3658 PrimitiveCount
= IndexCount
- 2;
3661 case D3DPT_TRIANGLEFAN
:
3662 PrimitiveCount
= IndexCount
- 2;
3665 default: return DDERR_INVALIDPARAMS
;
3668 /* Get the FVF of the vertex buffer, and its stride */
3669 hr
= IWineD3DVertexBuffer_GetDesc(vb
->wineD3DVertexBuffer
,
3673 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x\n", This
, hr
);
3676 stride
= get_flexible_vertex_size(Desc
.FVF
);
3677 TRACE("Vertex buffer FVF = %08x, stride=%d\n", Desc
.FVF
, stride
);
3679 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, Desc
.FVF
);
3682 ERR(" (%p) Setting the FVF failed, hr = %x!\n", This
, hr
);
3686 /* copy the index stream into the index buffer.
3687 * A new IWineD3DDevice method could be created
3688 * which takes an user pointer containing the indices
3689 * or a SetData-Method for the index buffer, which
3690 * overrides the index buffer data with our pointer.
3692 hr
= IWineD3DIndexBuffer_Lock(This
->indexbuffer
,
3693 0 /* OffSetToLock */,
3694 0 /* SizeToLock - doesn't matter */,
3695 (BYTE
**) &LockedIndices
,
3697 assert(IndexCount
< 0x100000);
3700 ERR("(%p) IWineD3DIndexBuffer::Lock failed with hr = %08x\n", This
, hr
);
3703 memcpy(LockedIndices
, Indices
, IndexCount
* sizeof(WORD
));
3704 hr
= IWineD3DIndexBuffer_Unlock(This
->indexbuffer
);
3707 ERR("(%p) IWineD3DIndexBuffer::Unlock failed with hr = %08x\n", This
, hr
);
3711 /* Set the index stream */
3712 hr
= IWineD3DDevice_SetIndices(This
->wineD3DDevice
,
3716 /* Set the vertex stream source */
3717 hr
= IWineD3DDevice_SetStreamSource(This
->wineD3DDevice
,
3718 0 /* StreamNumber */,
3719 vb
->wineD3DVertexBuffer
,
3720 0 /* offset, we pass this to DrawIndexedPrimitive */,
3724 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This
, hr
);
3729 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->wineD3DDevice
,
3739 static HRESULT WINAPI
3740 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevice3
*iface
,
3741 D3DPRIMITIVETYPE PrimitiveType
,
3742 IDirect3DVertexBuffer
*D3DVertexBuf
,
3747 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3748 IDirect3DVertexBufferImpl
*VB
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer
, D3DVertexBuf
);
3749 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p,%p,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VB
, Indices
, IndexCount
, Flags
);
3751 return IDirect3DDevice7_DrawIndexedPrimitiveVB(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3753 ICOM_INTERFACE(VB
, IDirect3DVertexBuffer7
),
3761 /*****************************************************************************
3762 * IDirect3DDevice7::ComputeSphereVisibility
3764 * Calculates the visibility of spheres in the current viewport. The spheres
3765 * are passed in the Centers and Radii arrays, the results are passed back
3766 * in the ReturnValues array. Return values are either completely visible,
3767 * partially visible or completely invisible.
3768 * The return value consist of a combination of D3DCLIP_* flags, or it's
3769 * 0 if the sphere is completely visible(according to the SDK, not checked)
3771 * Sounds like an overdose of math ;)
3776 * Centers: Array containing the sphere centers
3777 * Radii: Array containing the sphere radii
3778 * NumSpheres: The number of centers and radii in the arrays
3780 * ReturnValues: Array to write the results to
3783 * D3D_OK because it's a stub
3784 * (DDERR_INVALIDPARAMS if Centers, Radii or ReturnValues are NULL)
3785 * (D3DERR_INVALIDMATRIX if the combined world, view and proj matrix
3788 *****************************************************************************/
3789 static HRESULT WINAPI
3790 IDirect3DDeviceImpl_7_ComputeSphereVisibility(IDirect3DDevice7
*iface
,
3795 DWORD
*ReturnValues
)
3797 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3798 FIXME("(%p)->(%p,%p,%08x,%08x,%p): stub!\n", This
, Centers
, Radii
, NumSpheres
, Flags
, ReturnValues
);
3800 /* the DirectX 7 sdk says that the visibility is computed by
3801 * back-transforming the viewing frustum to model space
3802 * using the inverse of the combined world, view and projection
3803 * matrix. If the matrix can't be reversed, D3DERR_INVALIDMATRIX
3806 * Basic implementation idea:
3807 * 1) Check if the center is in the viewing frustum
3808 * 2) Cut the sphere with the planes of the viewing
3811 * ->Center inside the frustum, no intersections:
3813 * ->Center outside the frustum, no intersections:
3815 * ->Some intersections: Partially visible
3817 * Implement this call in WineD3D. Either implement the
3818 * matrix and vector stuff in WineD3D, or use some external
3825 static HRESULT WINAPI
3826 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility(IDirect3DDevice3
*iface
,
3831 DWORD
*ReturnValues
)
3833 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3834 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08x,%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, Centers
, Radii
, NumSpheres
, Flags
, ReturnValues
);
3835 return IDirect3DDevice7_ComputeSphereVisibility(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3843 /*****************************************************************************
3844 * IDirect3DDevice7::GetTexture
3846 * Returns the texture interface handle assigned to a texture stage.
3847 * The returned texture is AddRefed. This is taken from old ddraw,
3848 * not checked in Windows.
3853 * Stage: Texture stage to read the texture from
3854 * Texture: Address to store the interface pointer at
3858 * DDERR_INVALIDPARAMS if Texture is NULL
3859 * For details, see IWineD3DDevice::GetTexture
3861 *****************************************************************************/
3862 static HRESULT WINAPI
3863 IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7
*iface
,
3865 IDirectDrawSurface7
**Texture
)
3867 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3868 IWineD3DBaseTexture
*Surf
;
3870 TRACE("(%p)->(%d,%p): Relay\n", This
, Stage
, Texture
);
3874 TRACE("Texture == NULL, failing with DDERR_INVALIDPARAMS\n");
3875 return DDERR_INVALIDPARAMS
;
3878 hr
= IWineD3DDevice_GetTexture(This
->wineD3DDevice
, Stage
, (IWineD3DBaseTexture
**) &Surf
);
3879 if( (hr
!= D3D_OK
) || (!Surf
) )
3885 /* GetParent AddRef()s, which is perfectly OK.
3886 * We have passed the IDirectDrawSurface7 interface to WineD3D, so that's OK too.
3888 return IWineD3DBaseTexture_GetParent(Surf
,
3889 (IUnknown
**) Texture
);
3892 static HRESULT WINAPI
3893 Thunk_IDirect3DDeviceImpl_3_GetTexture(IDirect3DDevice3
*iface
,
3895 IDirect3DTexture2
**Texture2
)
3897 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3899 IDirectDrawSurface7
*ret_val
;
3901 TRACE_(ddraw_thunk
)("(%p)->(%d,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, Texture2
);
3902 ret
= IDirect3DDevice7_GetTexture(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3906 *Texture2
= COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirect3DTexture2
, ret_val
);
3908 TRACE_(ddraw_thunk
)(" returning interface %p.\n", *Texture2
);
3913 /*****************************************************************************
3914 * IDirect3DDevice7::SetTexture
3916 * Assigns a texture to a texture stage. Is the texture AddRef-ed?
3921 * Stage: The stage to assign the texture to
3922 * Texture: Interface pointer to the texture surface
3926 * For details, see IWineD3DDevice::SetTexture
3928 *****************************************************************************/
3929 static HRESULT WINAPI
3930 IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7
*iface
,
3932 IDirectDrawSurface7
*Texture
)
3934 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3935 IDirectDrawSurfaceImpl
*surf
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, Texture
);
3936 TRACE("(%p)->(%08x,%p): Relay!\n", This
, Stage
, surf
);
3938 /* Texture may be NULL here */
3939 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
3941 surf
? (IWineD3DBaseTexture
* ) surf
->wineD3DTexture
: NULL
);
3944 static HRESULT WINAPI
3945 Thunk_IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3
*iface
,
3947 IDirect3DTexture2
*Texture2
)
3949 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3950 IDirectDrawSurfaceImpl
*tex
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Texture2
);
3951 TRACE_(ddraw_thunk
)("(%p)->(%d,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, tex
);
3952 return IDirect3DDevice7_SetTexture(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3954 ICOM_INTERFACE(tex
, IDirectDrawSurface7
));
3957 /*****************************************************************************
3958 * IDirect3DDevice7::GetTextureStageState
3960 * Retrieves a state from a texture stage.
3965 * Stage: The stage to retrieve the state from
3966 * TexStageStateType: The state type to retrieve
3967 * State: Address to store the state's value at
3971 * DDERR_INVALIDPARAMS if State is NULL
3972 * For details, see IWineD3DDevice::GetTextureStageState
3974 *****************************************************************************/
3975 static HRESULT WINAPI
3976 IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7
*iface
,
3978 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3981 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3982 TRACE("(%p)->(%08x,%08x,%p): Relay!\n", This
, Stage
, TexStageStateType
, State
);
3985 return DDERR_INVALIDPARAMS
;
3987 switch(TexStageStateType
)
3989 /* Mipfilter is a sampler state with different values */
3990 case D3DTSS_MIPFILTER
:
3993 WINED3DTEXTUREFILTERTYPE value
;
3995 hr
= IWineD3DDevice_GetSamplerState(This
->wineD3DDevice
,
3997 WINED3DSAMP_MIPFILTER
,
4001 case WINED3DTEXF_NONE
: *State
= D3DTFP_NONE
; break;
4002 case WINED3DTEXF_POINT
: *State
= D3DTFP_POINT
; break;
4003 case WINED3DTEXF_LINEAR
: *State
= D3DTFP_LINEAR
; break;
4005 ERR("Unexpected mipfilter value %d\n", value
);
4006 *State
= D3DTFP_NONE
;
4011 /* Minfilter is a sampler state too, equal values */
4012 case D3DTSS_MINFILTER
:
4013 return IWineD3DDevice_GetSamplerState(This
->wineD3DDevice
,
4015 WINED3DSAMP_MINFILTER
,
4017 /* Same for MAGFILTER */
4018 case D3DTSS_MAGFILTER
:
4019 return IWineD3DDevice_GetSamplerState(This
->wineD3DDevice
,
4021 WINED3DSAMP_MAGFILTER
,
4024 return IWineD3DDevice_GetTextureStageState(This
->wineD3DDevice
,
4031 static HRESULT WINAPI
4032 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState(IDirect3DDevice3
*iface
,
4034 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
4037 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
4038 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, TexStageStateType
, State
);
4039 return IDirect3DDevice7_GetTextureStageState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
4045 /*****************************************************************************
4046 * IDirect3DDevice7::SetTextureStageState
4048 * Sets a texture stage state. Some stage types need to be handled specially,
4049 * because they do not exist in WineD3D and were moved to another place
4054 * Stage: The stage to modify
4055 * TexStageStateType: The state to change
4056 * State: The new value for the state
4060 * For details, see IWineD3DDevice::SetTextureStageState
4062 *****************************************************************************/
4063 static HRESULT WINAPI
4064 IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7
*iface
,
4066 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
4069 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4070 TRACE("(%p)->(%08x,%08x,%08x): Relay!\n", This
, Stage
, TexStageStateType
, State
);
4071 switch(TexStageStateType
)
4073 /* Mipfilter is a sampler state with different values */
4074 case D3DTSS_MIPFILTER
:
4076 WINED3DTEXTUREFILTERTYPE value
;
4079 case D3DTFP_NONE
: value
= WINED3DTEXF_NONE
; break;
4080 case D3DTFP_POINT
: value
= WINED3DTEXF_POINT
; break;
4081 case 0: /* Unchecked */
4082 case D3DTFP_LINEAR
: value
= WINED3DTEXF_LINEAR
; break;
4084 ERR("Unexpected mipfilter value %d\n", State
);
4085 value
= WINED3DTEXF_NONE
;
4087 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
4089 WINED3DSAMP_MIPFILTER
,
4093 /* Minfilter is a sampler state too, equal values */
4094 case D3DTSS_MINFILTER
:
4095 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
4097 WINED3DSAMP_MINFILTER
,
4099 /* Same for MAGFILTER */
4100 case D3DTSS_MAGFILTER
:
4101 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
4103 WINED3DSAMP_MAGFILTER
,
4108 return IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
,
4115 static HRESULT WINAPI
4116 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState(IDirect3DDevice3
*iface
,
4118 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
4121 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
4122 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%08x) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, TexStageStateType
, State
);
4123 return IDirect3DDevice7_SetTextureStageState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
4129 /*****************************************************************************
4130 * IDirect3DDevice7::ValidateDevice
4132 * SDK: "Reports the device's ability to render the currently set
4133 * texture-blending operations in a single pass". Whatever that means
4139 * NumPasses: Address to write the number of necessary passes for the
4140 * desired effect to.
4144 * See IWineD3DDevice::ValidateDevice for more details
4146 *****************************************************************************/
4147 static HRESULT WINAPI
4148 IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7
*iface
,
4151 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4152 TRACE("(%p)->(%p): Relay\n", This
, NumPasses
);
4154 return IWineD3DDevice_ValidateDevice(This
->wineD3DDevice
, NumPasses
);
4157 static HRESULT WINAPI
4158 Thunk_IDirect3DDeviceImpl_3_ValidateDevice(IDirect3DDevice3
*iface
,
4161 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
4162 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Passes
);
4163 return IDirect3DDevice7_ValidateDevice(ICOM_INTERFACE(This
, IDirect3DDevice7
),
4167 /*****************************************************************************
4168 * IDirect3DDevice7::Clear
4170 * Fills the render target, the z buffer and the stencil buffer with a
4171 * clear color / value
4176 * Count: Number of rectangles in Rects must be 0 if Rects is NULL
4177 * Rects: Rectangles to clear. If NULL, the whole surface is cleared
4178 * Flags: Some flags, as usual
4179 * Color: Clear color for the render target
4180 * Z: Clear value for the Z buffer
4181 * Stencil: Clear value to store in each stencil buffer entry
4185 * For details, see IWineD3DDevice::Clear
4187 *****************************************************************************/
4188 static HRESULT WINAPI
4189 IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7
*iface
,
4197 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4198 TRACE("(%p)->(%08x,%p,%08x,%08x,%f,%08x): Relay\n", This
, Count
, Rects
, Flags
, (DWORD
) Color
, Z
, Stencil
);
4200 /* Note; D3DRECT is compatible with WINED3DRECT */
4201 return IWineD3DDevice_Clear(This
->wineD3DDevice
, Count
, (WINED3DRECT
*) Rects
, Flags
, Color
, Z
, Stencil
);
4204 /*****************************************************************************
4205 * IDirect3DDevice7::SetViewport
4207 * Sets the current viewport.
4209 * Version 7 only, but IDirect3DViewport uses this call for older
4213 * Data: The new viewport to set
4217 * DDERR_INVALIDPARAMS if Data is NULL
4218 * For more details, see IWineDDDevice::SetViewport
4220 *****************************************************************************/
4221 static HRESULT WINAPI
4222 IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7
*iface
,
4225 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4226 TRACE("(%p)->(%p) Relay!\n", This
, Data
);
4229 return DDERR_INVALIDPARAMS
;
4231 /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
4232 return IWineD3DDevice_SetViewport(This
->wineD3DDevice
,
4233 (WINED3DVIEWPORT
*) Data
);
4236 /*****************************************************************************
4237 * IDirect3DDevice::GetViewport
4239 * Returns the current viewport
4244 * Data: D3D7Viewport structure to write the viewport information to
4248 * DDERR_INVALIDPARAMS if Data is NULL
4249 * For more details, see IWineD3DDevice::GetViewport
4251 *****************************************************************************/
4252 static HRESULT WINAPI
4253 IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7
*iface
,
4256 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4258 TRACE("(%p)->(%p) Relay!\n", This
, Data
);
4261 return DDERR_INVALIDPARAMS
;
4263 /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
4264 hr
= IWineD3DDevice_GetViewport(This
->wineD3DDevice
,
4265 (WINED3DVIEWPORT
*) Data
);
4267 return hr_ddraw_from_wined3d(hr
);
4270 /*****************************************************************************
4271 * IDirect3DDevice7::SetMaterial
4278 * Mat: The material to set
4282 * DDERR_INVALIDPARAMS if Mat is NULL.
4283 * For more details, see IWineD3DDevice::SetMaterial
4285 *****************************************************************************/
4286 static HRESULT WINAPI
4287 IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7
*iface
,
4290 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4292 TRACE("(%p)->(%p): Relay!\n", This
, Mat
);
4294 /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
4295 hr
= IWineD3DDevice_SetMaterial(This
->wineD3DDevice
,
4296 (WINED3DMATERIAL
*) Mat
);
4298 return hr_ddraw_from_wined3d(hr
);
4301 /*****************************************************************************
4302 * IDirect3DDevice7::GetMaterial
4304 * Returns the current material
4309 * Mat: D3DMATERIAL7 structure to write the material parameters to
4313 * DDERR_INVALIDPARAMS if Mat is NULL
4314 * For more details, see IWineD3DDevice::GetMaterial
4316 *****************************************************************************/
4317 static HRESULT WINAPI
4318 IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7
*iface
,
4321 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4323 TRACE("(%p)->(%p): Relay!\n", This
, Mat
);
4325 /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
4326 hr
= IWineD3DDevice_GetMaterial(This
->wineD3DDevice
,
4327 (WINED3DMATERIAL
*) Mat
);
4329 return hr_ddraw_from_wined3d(hr
);
4332 /*****************************************************************************
4333 * IDirect3DDevice7::SetLight
4335 * Assigns a light to a light index, but doesn't activate it yet.
4337 * Version 7, IDirect3DLight uses this method for older versions
4340 * LightIndex: The index of the new light
4341 * Light: A D3DLIGHT7 structure describing the light
4345 * For more details, see IWineD3DDevice::SetLight
4347 *****************************************************************************/
4348 static HRESULT WINAPI
4349 IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7
*iface
,
4353 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4355 TRACE("(%p)->(%08x,%p): Relay!\n", This
, LightIndex
, Light
);
4357 /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
4358 hr
= IWineD3DDevice_SetLight(This
->wineD3DDevice
,
4360 (WINED3DLIGHT
*) Light
);
4362 return hr_ddraw_from_wined3d(hr
);
4365 /*****************************************************************************
4366 * IDirect3DDevice7::GetLight
4368 * Returns the light assigned to a light index
4371 * Light: Structure to write the light information to
4375 * DDERR_INVALIDPARAMS if Light is NULL
4376 * For details, see IWineD3DDevice::GetLight
4378 *****************************************************************************/
4379 static HRESULT WINAPI
4380 IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7
*iface
,
4384 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4386 TRACE("(%p)->(%08x,%p): Relay!\n", This
, LightIndex
, Light
);
4388 /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
4389 rc
= IWineD3DDevice_GetLight(This
->wineD3DDevice
,
4391 (WINED3DLIGHT
*) Light
);
4393 /* Translate the result. WineD3D returns other values than D3D7 */
4394 return hr_ddraw_from_wined3d(rc
);
4397 /*****************************************************************************
4398 * IDirect3DDevice7::BeginStateBlock
4400 * Begins recording to a stateblock
4406 * For details see IWineD3DDevice::BeginStateBlock
4408 *****************************************************************************/
4409 static HRESULT WINAPI
4410 IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7
*iface
)
4412 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4414 TRACE("(%p)->(): Relay!\n", This
);
4416 hr
= IWineD3DDevice_BeginStateBlock(This
->wineD3DDevice
);
4417 return hr_ddraw_from_wined3d(hr
);
4420 /*****************************************************************************
4421 * IDirect3DDevice7::EndStateBlock
4423 * Stops recording to a state block and returns the created stateblock
4429 * BlockHandle: Address to store the stateblock's handle to
4433 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4434 * See IWineD3DDevice::EndStateBlock for more details
4436 *****************************************************************************/
4437 static HRESULT WINAPI
4438 IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7
*iface
,
4441 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4443 TRACE("(%p)->(%p): Relay!\n", This
, BlockHandle
);
4447 WARN("BlockHandle == NULL, returning DDERR_INVALIDPARAMS\n");
4448 return DDERR_INVALIDPARAMS
;
4451 *BlockHandle
= IDirect3DDeviceImpl_CreateHandle(This
);
4454 ERR("Cannot get a handle number for the stateblock\n");
4455 return DDERR_OUTOFMEMORY
;
4457 This
->Handles
[*BlockHandle
- 1].type
= DDrawHandle_StateBlock
;
4458 hr
= IWineD3DDevice_EndStateBlock(This
->wineD3DDevice
,
4459 (IWineD3DStateBlock
**) &This
->Handles
[*BlockHandle
- 1].ptr
);
4460 return hr_ddraw_from_wined3d(hr
);
4463 /*****************************************************************************
4464 * IDirect3DDevice7::PreLoad
4466 * Allows the app to signal that a texture will be used soon, to allow
4467 * the Direct3DDevice to load it to the video card in the meantime.
4472 * Texture: The texture to preload
4476 * DDERR_INVALIDPARAMS if Texture is NULL
4477 * See IWineD3DSurface::PreLoad for details
4479 *****************************************************************************/
4480 static HRESULT WINAPI
4481 IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7
*iface
,
4482 IDirectDrawSurface7
*Texture
)
4484 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4485 IDirectDrawSurfaceImpl
*surf
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, Texture
);
4487 TRACE("(%p)->(%p): Relay!\n", This
, surf
);
4490 return DDERR_INVALIDPARAMS
;
4492 IWineD3DSurface_PreLoad(surf
->WineD3DSurface
);
4496 /*****************************************************************************
4497 * IDirect3DDevice7::ApplyStateBlock
4499 * Activates the state stored in a state block handle.
4502 * BlockHandle: The stateblock handle to activate
4506 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4508 *****************************************************************************/
4509 static HRESULT WINAPI
4510 IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7
*iface
,
4513 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4515 TRACE("(%p)->(%08x): Relay!\n", This
, BlockHandle
);
4517 if(!BlockHandle
|| BlockHandle
> This
->numHandles
)
4519 WARN("Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4520 return D3DERR_INVALIDSTATEBLOCK
;
4522 if(This
->Handles
[BlockHandle
- 1].type
!= DDrawHandle_StateBlock
)
4524 WARN("Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4525 return D3DERR_INVALIDSTATEBLOCK
;
4528 hr
= IWineD3DStateBlock_Apply((IWineD3DStateBlock
*) This
->Handles
[BlockHandle
- 1].ptr
);
4529 return hr_ddraw_from_wined3d(hr
);
4532 /*****************************************************************************
4533 * IDirect3DDevice7::CaptureStateBlock
4535 * Updates a stateblock's values to the values currently set for the device
4540 * BlockHandle: Stateblock to update
4544 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4545 * See IWineD3DDevice::CaptureStateBlock for more details
4547 *****************************************************************************/
4548 static HRESULT WINAPI
4549 IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7
*iface
,
4552 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4554 TRACE("(%p)->(%08x): Relay!\n", This
, BlockHandle
);
4556 if(BlockHandle
== 0 || BlockHandle
> This
->numHandles
)
4558 WARN("Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4559 return D3DERR_INVALIDSTATEBLOCK
;
4561 if(This
->Handles
[BlockHandle
- 1].type
!= DDrawHandle_StateBlock
)
4563 WARN("Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4564 return D3DERR_INVALIDSTATEBLOCK
;
4567 hr
= IWineD3DStateBlock_Capture((IWineD3DStateBlock
*) This
->Handles
[BlockHandle
- 1].ptr
);
4568 return hr_ddraw_from_wined3d(hr
);
4571 /*****************************************************************************
4572 * IDirect3DDevice7::DeleteStateBlock
4574 * Deletes a stateblock handle. This means releasing the WineD3DStateBlock
4579 * BlockHandle: Stateblock handle to delete
4583 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is 0
4585 *****************************************************************************/
4586 static HRESULT WINAPI
4587 IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7
*iface
,
4590 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4592 TRACE("(%p)->(%08x): Relay!\n", This
, BlockHandle
);
4594 if(BlockHandle
== 0 || BlockHandle
> This
->numHandles
)
4596 WARN("Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4597 return D3DERR_INVALIDSTATEBLOCK
;
4599 if(This
->Handles
[BlockHandle
- 1].type
!= DDrawHandle_StateBlock
)
4601 WARN("Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK\n", BlockHandle
);
4602 return D3DERR_INVALIDSTATEBLOCK
;
4605 ref
= IWineD3DStateBlock_Release((IWineD3DStateBlock
*) This
->Handles
[BlockHandle
- 1].ptr
);
4608 ERR("Something is still holding the stateblock %p(Handle %d). Ref = %d\n", This
->Handles
[BlockHandle
- 1].ptr
, BlockHandle
, ref
);
4610 This
->Handles
[BlockHandle
- 1].ptr
= NULL
;
4611 This
->Handles
[BlockHandle
- 1].type
= DDrawHandle_Unknown
;
4616 /*****************************************************************************
4617 * IDirect3DDevice7::CreateStateBlock
4619 * Creates a new state block handle.
4624 * Type: The state block type
4625 * BlockHandle: Address to write the created handle to
4629 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4631 *****************************************************************************/
4632 static HRESULT WINAPI
4633 IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7
*iface
,
4634 D3DSTATEBLOCKTYPE Type
,
4637 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4639 TRACE("(%p)->(%08x,%p)!\n", This
, Type
, BlockHandle
);
4643 WARN("BlockHandle == NULL, returning DDERR_INVALIDPARAMS\n");
4644 return DDERR_INVALIDPARAMS
;
4647 *BlockHandle
= IDirect3DDeviceImpl_CreateHandle(This
);
4650 ERR("Cannot get a handle number for the stateblock\n");
4651 return DDERR_OUTOFMEMORY
;
4653 This
->Handles
[*BlockHandle
- 1].type
= DDrawHandle_StateBlock
;
4655 /* The D3DSTATEBLOCKTYPE enum is fine here */
4656 hr
= IWineD3DDevice_CreateStateBlock(This
->wineD3DDevice
,
4658 (IWineD3DStateBlock
**) &This
->Handles
[*BlockHandle
- 1].ptr
,
4659 NULL
/* Parent, hope that works */);
4660 return hr_ddraw_from_wined3d(hr
);
4663 /*****************************************************************************
4664 * IDirect3DDevice7::Load
4666 * Loads a rectangular area from the source into the destination texture.
4667 * It can also copy the source to the faces of a cubic environment map
4672 * DestTex: Destination texture
4673 * DestPoint: Point in the destination where the source image should be
4675 * SrcTex: Source texture
4676 * SrcRect: Source rectangle
4681 * DDERR_INVALIDPARAMS if DestTex or SrcTex are NULL
4682 * See IDirect3DTexture2::Load for details
4684 *****************************************************************************/
4685 static HRESULT WINAPI
4686 IDirect3DDeviceImpl_7_Load(IDirect3DDevice7
*iface
,
4687 IDirectDrawSurface7
*DestTex
,
4689 IDirectDrawSurface7
*SrcTex
,
4693 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4694 IDirectDrawSurfaceImpl
*dest
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, DestTex
);
4695 IDirectDrawSurfaceImpl
*src
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, SrcTex
);
4696 FIXME("(%p)->(%p,%p,%p,%p,%08x): Partially Implemented!\n", This
, dest
, DestPoint
, src
, SrcRect
, Flags
);
4698 if( (!src
) || (!dest
) )
4699 return DDERR_INVALIDPARAMS
;
4701 IDirect3DTexture2_Load(ICOM_INTERFACE(dest
, IDirect3DTexture2
),
4702 ICOM_INTERFACE(src
, IDirect3DTexture2
));
4706 /*****************************************************************************
4707 * IDirect3DDevice7::LightEnable
4709 * Enables or disables a light
4711 * Version 7, IDirect3DLight uses this method too.
4714 * LightIndex: The index of the light to enable / disable
4715 * Enable: Enable or disable the light
4719 * For more details, see IWineD3DDevice::SetLightEnable
4721 *****************************************************************************/
4722 static HRESULT WINAPI
4723 IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7
*iface
,
4727 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4729 TRACE("(%p)->(%08x,%d): Relay!\n", This
, LightIndex
, Enable
);
4731 hr
= IWineD3DDevice_SetLightEnable(This
->wineD3DDevice
, LightIndex
, Enable
);
4732 return hr_ddraw_from_wined3d(hr
);
4735 /*****************************************************************************
4736 * IDirect3DDevice7::GetLightEnable
4738 * Retrieves if the light with the given index is enabled or not
4743 * LightIndex: Index of desired light
4744 * Enable: Pointer to a BOOL which contains the result
4748 * DDERR_INVALIDPARAMS if Enable is NULL
4749 * See IWineD3DDevice::GetLightEnable for more details
4751 *****************************************************************************/
4752 static HRESULT WINAPI
4753 IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7
*iface
,
4757 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4759 TRACE("(%p)->(%08x,%p): Relay\n", This
, LightIndex
, Enable
);
4762 return DDERR_INVALIDPARAMS
;
4764 hr
= IWineD3DDevice_GetLightEnable(This
->wineD3DDevice
, LightIndex
, Enable
);
4765 return hr_ddraw_from_wined3d(hr
);
4768 /*****************************************************************************
4769 * IDirect3DDevice7::SetClipPlane
4771 * Sets custom clipping plane
4776 * Index: The index of the clipping plane
4777 * PlaneEquation: An equation defining the clipping plane
4781 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4782 * See IWineD3DDevice::SetClipPlane for more details
4784 *****************************************************************************/
4785 static HRESULT WINAPI
4786 IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7
*iface
,
4788 D3DVALUE
* PlaneEquation
)
4790 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4791 TRACE("(%p)->(%08x,%p): Relay!\n", This
, Index
, PlaneEquation
);
4794 return DDERR_INVALIDPARAMS
;
4796 return IWineD3DDevice_SetClipPlane(This
->wineD3DDevice
, Index
, PlaneEquation
);
4799 /*****************************************************************************
4800 * IDirect3DDevice7::GetClipPlane
4802 * Returns the clipping plane with a specific index
4805 * Index: The index of the desired plane
4806 * PlaneEquation: Address to store the plane equation to
4810 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4811 * See IWineD3DDevice::GetClipPlane for more details
4813 *****************************************************************************/
4814 static HRESULT WINAPI
4815 IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7
*iface
,
4817 D3DVALUE
* PlaneEquation
)
4819 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4820 TRACE("(%p)->(%d,%p): Relay!\n", This
, Index
, PlaneEquation
);
4823 return DDERR_INVALIDPARAMS
;
4825 return IWineD3DDevice_GetClipPlane(This
->wineD3DDevice
, Index
, PlaneEquation
);
4828 /*****************************************************************************
4829 * IDirect3DDevice7::GetInfo
4831 * Retrieves some information about the device. The DirectX sdk says that
4832 * this version returns S_FALSE for all retail builds of DirectX, that's what
4833 * this implementation does.
4836 * DevInfoID: Information type requested
4837 * DevInfoStruct: Pointer to a structure to store the info to
4838 * Size: Size of the structure
4841 * S_FALSE, because it's a non-debug driver
4843 *****************************************************************************/
4844 static HRESULT WINAPI
4845 IDirect3DDeviceImpl_7_GetInfo(IDirect3DDevice7
*iface
,
4847 void *DevInfoStruct
,
4850 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4851 TRACE("(%p)->(%08x,%p,%08x)\n", This
, DevInfoID
, DevInfoStruct
, Size
);
4855 TRACE(" info requested : ");
4858 case D3DDEVINFOID_TEXTUREMANAGER
: TRACE("D3DDEVINFOID_TEXTUREMANAGER\n"); break;
4859 case D3DDEVINFOID_D3DTEXTUREMANAGER
: TRACE("D3DDEVINFOID_D3DTEXTUREMANAGER\n"); break;
4860 case D3DDEVINFOID_TEXTURING
: TRACE("D3DDEVINFOID_TEXTURING\n"); break;
4861 default: ERR(" invalid flag !!!\n"); return DDERR_INVALIDPARAMS
;
4865 return S_FALSE
; /* According to MSDN, this is valid for a non-debug driver */
4868 const IDirect3DDevice7Vtbl IDirect3DDevice7_Vtbl
=
4870 /*** IUnknown Methods ***/
4871 IDirect3DDeviceImpl_7_QueryInterface
,
4872 IDirect3DDeviceImpl_7_AddRef
,
4873 IDirect3DDeviceImpl_7_Release
,
4874 /*** IDirect3DDevice7 ***/
4875 IDirect3DDeviceImpl_7_GetCaps
,
4876 IDirect3DDeviceImpl_7_EnumTextureFormats
,
4877 IDirect3DDeviceImpl_7_BeginScene
,
4878 IDirect3DDeviceImpl_7_EndScene
,
4879 IDirect3DDeviceImpl_7_GetDirect3D
,
4880 IDirect3DDeviceImpl_7_SetRenderTarget
,
4881 IDirect3DDeviceImpl_7_GetRenderTarget
,
4882 IDirect3DDeviceImpl_7_Clear
,
4883 IDirect3DDeviceImpl_7_SetTransform
,
4884 IDirect3DDeviceImpl_7_GetTransform
,
4885 IDirect3DDeviceImpl_7_SetViewport
,
4886 IDirect3DDeviceImpl_7_MultiplyTransform
,
4887 IDirect3DDeviceImpl_7_GetViewport
,
4888 IDirect3DDeviceImpl_7_SetMaterial
,
4889 IDirect3DDeviceImpl_7_GetMaterial
,
4890 IDirect3DDeviceImpl_7_SetLight
,
4891 IDirect3DDeviceImpl_7_GetLight
,
4892 IDirect3DDeviceImpl_7_SetRenderState
,
4893 IDirect3DDeviceImpl_7_GetRenderState
,
4894 IDirect3DDeviceImpl_7_BeginStateBlock
,
4895 IDirect3DDeviceImpl_7_EndStateBlock
,
4896 IDirect3DDeviceImpl_7_PreLoad
,
4897 IDirect3DDeviceImpl_7_DrawPrimitive
,
4898 IDirect3DDeviceImpl_7_DrawIndexedPrimitive
,
4899 IDirect3DDeviceImpl_7_SetClipStatus
,
4900 IDirect3DDeviceImpl_7_GetClipStatus
,
4901 IDirect3DDeviceImpl_7_DrawPrimitiveStrided
,
4902 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided
,
4903 IDirect3DDeviceImpl_7_DrawPrimitiveVB
,
4904 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB
,
4905 IDirect3DDeviceImpl_7_ComputeSphereVisibility
,
4906 IDirect3DDeviceImpl_7_GetTexture
,
4907 IDirect3DDeviceImpl_7_SetTexture
,
4908 IDirect3DDeviceImpl_7_GetTextureStageState
,
4909 IDirect3DDeviceImpl_7_SetTextureStageState
,
4910 IDirect3DDeviceImpl_7_ValidateDevice
,
4911 IDirect3DDeviceImpl_7_ApplyStateBlock
,
4912 IDirect3DDeviceImpl_7_CaptureStateBlock
,
4913 IDirect3DDeviceImpl_7_DeleteStateBlock
,
4914 IDirect3DDeviceImpl_7_CreateStateBlock
,
4915 IDirect3DDeviceImpl_7_Load
,
4916 IDirect3DDeviceImpl_7_LightEnable
,
4917 IDirect3DDeviceImpl_7_GetLightEnable
,
4918 IDirect3DDeviceImpl_7_SetClipPlane
,
4919 IDirect3DDeviceImpl_7_GetClipPlane
,
4920 IDirect3DDeviceImpl_7_GetInfo
4923 const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl
=
4925 /*** IUnknown Methods ***/
4926 Thunk_IDirect3DDeviceImpl_3_QueryInterface
,
4927 Thunk_IDirect3DDeviceImpl_3_AddRef
,
4928 Thunk_IDirect3DDeviceImpl_3_Release
,
4929 /*** IDirect3DDevice3 ***/
4930 IDirect3DDeviceImpl_3_GetCaps
,
4931 IDirect3DDeviceImpl_3_GetStats
,
4932 IDirect3DDeviceImpl_3_AddViewport
,
4933 IDirect3DDeviceImpl_3_DeleteViewport
,
4934 IDirect3DDeviceImpl_3_NextViewport
,
4935 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats
,
4936 Thunk_IDirect3DDeviceImpl_3_BeginScene
,
4937 Thunk_IDirect3DDeviceImpl_3_EndScene
,
4938 Thunk_IDirect3DDeviceImpl_3_GetDirect3D
,
4939 IDirect3DDeviceImpl_3_SetCurrentViewport
,
4940 IDirect3DDeviceImpl_3_GetCurrentViewport
,
4941 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget
,
4942 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget
,
4943 IDirect3DDeviceImpl_3_Begin
,
4944 IDirect3DDeviceImpl_3_BeginIndexed
,
4945 IDirect3DDeviceImpl_3_Vertex
,
4946 IDirect3DDeviceImpl_3_Index
,
4947 IDirect3DDeviceImpl_3_End
,
4948 Thunk_IDirect3DDeviceImpl_3_GetRenderState
,
4949 Thunk_IDirect3DDeviceImpl_3_SetRenderState
,
4950 IDirect3DDeviceImpl_3_GetLightState
,
4951 IDirect3DDeviceImpl_3_SetLightState
,
4952 Thunk_IDirect3DDeviceImpl_3_SetTransform
,
4953 Thunk_IDirect3DDeviceImpl_3_GetTransform
,
4954 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform
,
4955 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive
,
4956 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive
,
4957 Thunk_IDirect3DDeviceImpl_3_SetClipStatus
,
4958 Thunk_IDirect3DDeviceImpl_3_GetClipStatus
,
4959 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided
,
4960 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided
,
4961 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB
,
4962 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB
,
4963 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility
,
4964 Thunk_IDirect3DDeviceImpl_3_GetTexture
,
4965 Thunk_IDirect3DDeviceImpl_3_SetTexture
,
4966 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState
,
4967 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState
,
4968 Thunk_IDirect3DDeviceImpl_3_ValidateDevice
4971 const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl
=
4973 /*** IUnknown Methods ***/
4974 Thunk_IDirect3DDeviceImpl_2_QueryInterface
,
4975 Thunk_IDirect3DDeviceImpl_2_AddRef
,
4976 Thunk_IDirect3DDeviceImpl_2_Release
,
4977 /*** IDirect3DDevice2 ***/
4978 Thunk_IDirect3DDeviceImpl_2_GetCaps
,
4979 IDirect3DDeviceImpl_2_SwapTextureHandles
,
4980 Thunk_IDirect3DDeviceImpl_2_GetStats
,
4981 Thunk_IDirect3DDeviceImpl_2_AddViewport
,
4982 Thunk_IDirect3DDeviceImpl_2_DeleteViewport
,
4983 Thunk_IDirect3DDeviceImpl_2_NextViewport
,
4984 IDirect3DDeviceImpl_2_EnumTextureFormats
,
4985 Thunk_IDirect3DDeviceImpl_2_BeginScene
,
4986 Thunk_IDirect3DDeviceImpl_2_EndScene
,
4987 Thunk_IDirect3DDeviceImpl_2_GetDirect3D
,
4988 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport
,
4989 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport
,
4990 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget
,
4991 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget
,
4992 Thunk_IDirect3DDeviceImpl_2_Begin
,
4993 Thunk_IDirect3DDeviceImpl_2_BeginIndexed
,
4994 Thunk_IDirect3DDeviceImpl_2_Vertex
,
4995 Thunk_IDirect3DDeviceImpl_2_Index
,
4996 Thunk_IDirect3DDeviceImpl_2_End
,
4997 Thunk_IDirect3DDeviceImpl_2_GetRenderState
,
4998 Thunk_IDirect3DDeviceImpl_2_SetRenderState
,
4999 Thunk_IDirect3DDeviceImpl_2_GetLightState
,
5000 Thunk_IDirect3DDeviceImpl_2_SetLightState
,
5001 Thunk_IDirect3DDeviceImpl_2_SetTransform
,
5002 Thunk_IDirect3DDeviceImpl_2_GetTransform
,
5003 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform
,
5004 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive
,
5005 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive
,
5006 Thunk_IDirect3DDeviceImpl_2_SetClipStatus
,
5007 Thunk_IDirect3DDeviceImpl_2_GetClipStatus
5010 const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl
=
5012 /*** IUnknown Methods ***/
5013 Thunk_IDirect3DDeviceImpl_1_QueryInterface
,
5014 Thunk_IDirect3DDeviceImpl_1_AddRef
,
5015 Thunk_IDirect3DDeviceImpl_1_Release
,
5016 /*** IDirect3DDevice1 ***/
5017 IDirect3DDeviceImpl_1_Initialize
,
5018 Thunk_IDirect3DDeviceImpl_1_GetCaps
,
5019 Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles
,
5020 IDirect3DDeviceImpl_1_CreateExecuteBuffer
,
5021 Thunk_IDirect3DDeviceImpl_1_GetStats
,
5022 IDirect3DDeviceImpl_1_Execute
,
5023 Thunk_IDirect3DDeviceImpl_1_AddViewport
,
5024 Thunk_IDirect3DDeviceImpl_1_DeleteViewport
,
5025 Thunk_IDirect3DDeviceImpl_1_NextViewport
,
5026 IDirect3DDeviceImpl_1_Pick
,
5027 IDirect3DDeviceImpl_1_GetPickRecords
,
5028 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats
,
5029 IDirect3DDeviceImpl_1_CreateMatrix
,
5030 IDirect3DDeviceImpl_1_SetMatrix
,
5031 IDirect3DDeviceImpl_1_GetMatrix
,
5032 IDirect3DDeviceImpl_1_DeleteMatrix
,
5033 Thunk_IDirect3DDeviceImpl_1_EndScene
,
5034 Thunk_IDirect3DDeviceImpl_1_BeginScene
,
5035 Thunk_IDirect3DDeviceImpl_1_GetDirect3D
5038 /*****************************************************************************
5039 * IDirect3DDeviceImpl_CreateHandle
5041 * Not called from the VTable
5043 * Some older interface versions operate with handles, which are basically
5044 * DWORDs which identify an interface, for example
5045 * IDirect3DDevice::SetRenderState with DIRECT3DRENDERSTATE_TEXTUREHANDLE
5047 * Those handle could be just casts to the interface pointers or vice versa,
5048 * but that is not 64 bit safe and would mean blindly derefering a DWORD
5049 * passed by the app. Instead there is a dynamic array in the device which
5050 * keeps a DWORD to pointer information and a type for the handle.
5052 * Basically this array only grows, when a handle is freed its pointer is
5053 * just set to NULL. There will be much more reads from the array than
5054 * insertion operations, so a dynamic array is fine.
5057 * This: D3DDevice implementation for which this handle should be created
5060 * A free handle on success
5063 *****************************************************************************/
5065 IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl
*This
)
5068 struct HandleEntry
*oldHandles
= This
->Handles
;
5070 TRACE("(%p)\n", This
);
5072 for(i
= 0; i
< This
->numHandles
; i
++)
5074 if(This
->Handles
[i
].ptr
== NULL
&&
5075 This
->Handles
[i
].type
== DDrawHandle_Unknown
)
5077 TRACE("Reusing freed handle %d\n", i
+ 1);
5082 TRACE("Growing the handle array\n");
5085 This
->Handles
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct HandleEntry
) * This
->numHandles
);
5088 ERR("Out of memory\n");
5089 This
->Handles
= oldHandles
;
5095 memcpy(This
->Handles
, oldHandles
, (This
->numHandles
- 1) * sizeof(struct HandleEntry
));
5096 HeapFree(GetProcessHeap(), 0, oldHandles
);
5099 TRACE("Returning %d\n", This
->numHandles
);
5100 return This
->numHandles
;