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 for QueryInterface
74 * rules see ddraw.c, IDirectDraw7::QueryInterface
76 * Exists in Version 1, 2, 3 and 7
79 * refiid: Interface ID queried for
80 * obj: Used to return the interface pointer
83 * D3D_OK or E_NOINTERFACE
85 *****************************************************************************/
87 IDirect3DDeviceImpl_7_QueryInterface(IDirect3DDevice7
*iface
,
91 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
92 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(refiid
), obj
);
94 /* According to COM docs, if the QueryInterface fails, obj should be set to NULL */
98 return DDERR_INVALIDPARAMS
;
100 if ( IsEqualGUID( &IID_IUnknown
, refiid
) )
102 *obj
= ICOM_INTERFACE(This
, IDirect3DDevice7
);
105 /* Check DirectDraw Interfac\x01s */
106 else if( IsEqualGUID( &IID_IDirectDraw7
, refiid
) )
108 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirectDraw7
);
109 TRACE("(%p) Returning IDirectDraw7 interface at %p\n", This
, *obj
);
111 else if ( IsEqualGUID( &IID_IDirectDraw4
, refiid
) )
113 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirectDraw4
);
114 TRACE("(%p) Returning IDirectDraw4 interface at %p\n", This
, *obj
);
116 else if ( IsEqualGUID( &IID_IDirectDraw2
, refiid
) )
118 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirectDraw2
);
119 TRACE("(%p) Returning IDirectDraw2 interface at %p\n", This
, *obj
);
121 else if( IsEqualGUID( &IID_IDirectDraw
, refiid
) )
123 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirectDraw
);
124 TRACE("(%p) Returning IDirectDraw interface at %p\n", This
, *obj
);
128 else if ( IsEqualGUID( &IID_IDirect3D
, refiid
) )
130 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirect3D
);
131 TRACE("(%p) Returning IDirect3D interface at %p\n", This
, *obj
);
133 else if ( IsEqualGUID( &IID_IDirect3D2
, refiid
) )
135 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirect3D2
);
136 TRACE("(%p) Returning IDirect3D2 interface at %p\n", This
, *obj
);
138 else if ( IsEqualGUID( &IID_IDirect3D3
, refiid
) )
140 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirect3D3
);
141 TRACE("(%p) Returning IDirect3D3 interface at %p\n", This
, *obj
);
143 else if ( IsEqualGUID( &IID_IDirect3D7
, refiid
) )
145 *obj
= ICOM_INTERFACE(This
->ddraw
, IDirect3D7
);
146 TRACE("(%p) Returning IDirect3D7 interface at %p\n", This
, *obj
);
150 else if ( IsEqualGUID( &IID_IDirect3DDevice
, refiid
) )
152 *obj
= ICOM_INTERFACE(This
, IDirect3DDevice
);
153 TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This
, *obj
);
155 else if ( IsEqualGUID( &IID_IDirect3DDevice2
, refiid
) ) {
156 *obj
= ICOM_INTERFACE(This
, IDirect3DDevice2
);
157 TRACE("(%p) Returning IDirect3DDevice2 interface at %p\n", This
, *obj
);
159 else if ( IsEqualGUID( &IID_IDirect3DDevice3
, refiid
) ) {
160 *obj
= ICOM_INTERFACE(This
, IDirect3DDevice3
);
161 TRACE("(%p) Returning IDirect3DDevice3 interface at %p\n", This
, *obj
);
163 else if ( IsEqualGUID( &IID_IDirect3DDevice7
, refiid
) ) {
164 *obj
= ICOM_INTERFACE(This
, IDirect3DDevice7
);
165 TRACE("(%p) Returning IDirect3DDevice7 interface at %p\n", This
, *obj
);
168 /* Unknown interface */
171 ERR("(%p)->(%s, %p): No interface found", This
, debugstr_guid(refiid
), obj
);
172 return E_NOINTERFACE
;
175 /* AddRef the returned interface */
176 IUnknown_AddRef( (IUnknown
*) *obj
);
180 static HRESULT WINAPI
181 Thunk_IDirect3DDeviceImpl_3_QueryInterface(IDirect3DDevice3
*iface
,
185 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
186 TRACE_(ddraw_thunk
)("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", This
, debugstr_guid(riid
), obj
);
187 return IDirect3DDevice7_QueryInterface(ICOM_INTERFACE(This
, IDirect3DDevice7
),
192 static HRESULT WINAPI
193 Thunk_IDirect3DDeviceImpl_2_QueryInterface(IDirect3DDevice2
*iface
,
197 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
198 TRACE_(ddraw_thunk
)("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", This
, debugstr_guid(riid
), obj
);
199 return IDirect3DDevice7_QueryInterface(ICOM_INTERFACE(This
, IDirect3DDevice7
),
204 static HRESULT WINAPI
205 Thunk_IDirect3DDeviceImpl_1_QueryInterface(IDirect3DDevice
*iface
,
209 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
210 TRACE_(ddraw_thunk
)("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", This
, debugstr_guid(riid
), obp
);
211 return IDirect3DDevice7_QueryInterface(ICOM_INTERFACE(This
, IDirect3DDevice7
),
216 /*****************************************************************************
217 * IDirect3DDevice7::AddRef
219 * Increases the refcount....
220 * The most exciting Method, definitly
222 * Exists in Version 1, 2, 3 and 7
227 *****************************************************************************/
229 IDirect3DDeviceImpl_7_AddRef(IDirect3DDevice7
*iface
)
231 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
232 ULONG ref
= InterlockedIncrement(&This
->ref
);
234 TRACE("(%p) : incrementing from %lu.\n", This
, ref
-1);
240 Thunk_IDirect3DDeviceImpl_3_AddRef(IDirect3DDevice3
*iface
)
242 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
243 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
244 return IDirect3DDevice7_AddRef(ICOM_INTERFACE(This
, IDirect3DDevice7
));
248 Thunk_IDirect3DDeviceImpl_2_AddRef(IDirect3DDevice2
*iface
)
250 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
251 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
252 return IDirect3DDevice7_AddRef(ICOM_INTERFACE(This
, IDirect3DDevice7
));
256 Thunk_IDirect3DDeviceImpl_1_AddRef(IDirect3DDevice
*iface
)
258 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface
);
259 return IDirect3DDevice7_AddRef(COM_INTERFACE_CAST(IDirect3DDeviceImpl
, IDirect3DDevice
, IDirect3DDevice7
, iface
));
262 /*****************************************************************************
263 * IDirect3DDevice7::Release
265 * Decreases the refcount of the interface
266 * When the refcount is reduced to 0, the object is destroyed.
268 * Exists in Version 1, 2, 3 and 7
273 *****************************************************************************/
275 IDirect3DDeviceImpl_7_Release(IDirect3DDevice7
*iface
)
277 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
278 ULONG ref
= InterlockedDecrement(&This
->ref
);
280 TRACE("(%p)->() decrementing from %lu.\n", This
, ref
+1);
282 /* This method doesn't destroy the WineD3DDevice, because it's still in use for
283 * 2D rendering. IDirectDrawSurface7::Release will destroy the WineD3DDevice
284 * when the render target is released
288 IParent
*IndexBufferParent
;
291 /* Free the index buffer */
292 IWineD3DDevice_SetIndices(This
->wineD3DDevice
,
295 IWineD3DIndexBuffer_GetParent(This
->indexbuffer
,
296 (IUnknown
**) &IndexBufferParent
);
297 IParent_Release(IndexBufferParent
); /* Once for the getParent */
298 if( IParent_Release(IndexBufferParent
) != 0) /* And now to destroy it */
300 ERR(" (%p) Something is still holding the index buffer parent %p\n", This
, IndexBufferParent
);
303 /* Restore the render targets */
304 if(This
->OffScreenTarget
)
306 /* This->target is the offscreen target.
307 * This->ddraw->d3d_target is the target used by DDraw
309 TRACE("(%p) Release: Using %p as front buffer, %p as back buffer\n", This
, This
->ddraw
->d3d_target
, NULL
);
310 IWineD3DDevice_SetFrontBackBuffers(This
->wineD3DDevice
,
311 This
->ddraw
->d3d_target
->WineD3DSurface
,
315 /* Release the WineD3DDevice. This won't destroy it */
316 if(IWineD3DDevice_Release(This
->wineD3DDevice
) <= 0)
318 ERR(" (%p) The wineD3D device %p was destroyed unexpectadely. Prepare for trouble\n", This
, This
->wineD3DDevice
);
321 /* The texture handles should be unset by now, but there might be some bits
322 * missing in our reference counting(needs test). Do a sanity check
324 for(i
= 0; i
< This
->numHandles
; i
++)
326 if(This
->Handles
[i
].ptr
)
328 switch(This
->Handles
[i
].type
)
330 case DDrawHandle_Texture
:
332 IDirectDrawSurfaceImpl
*surf
= (IDirectDrawSurfaceImpl
*) This
->Handles
[i
].ptr
;
333 FIXME("Texture Handle %ld not unset properly\n", i
+ 1);
338 case DDrawHandle_Material
:
340 IDirect3DMaterialImpl
*mat
= (IDirect3DMaterialImpl
*) This
->Handles
[i
].ptr
;
341 FIXME("Material handle %ld not unset properly\n", i
+ 1);
346 FIXME("Unknown handle %ld not unset properly\n", i
+ 1);
351 HeapFree(GetProcessHeap(), 0, This
->Handles
);
353 /* Release the render target and the WineD3D render target
354 * (See IDirect3D7::CreateDevice for more comments on this)
356 IDirectDrawSurface7_Release(ICOM_INTERFACE(This
->target
, IDirectDrawSurface7
));
357 IDirectDrawSurface7_Release(ICOM_INTERFACE(This
->ddraw
->d3d_target
,IDirectDrawSurface7
));
359 This
->ddraw
->d3ddevice
= NULL
;
361 /* Now free the structure */
362 HeapFree(GetProcessHeap(), 0, This
);
369 Thunk_IDirect3DDeviceImpl_3_Release(IDirect3DDevice3
*iface
)
371 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
372 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
373 return IDirect3DDevice7_Release(ICOM_INTERFACE(This
, IDirect3DDevice7
));
377 Thunk_IDirect3DDeviceImpl_2_Release(IDirect3DDevice2
*iface
)
379 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
380 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
381 return IDirect3DDevice7_Release(ICOM_INTERFACE(This
, IDirect3DDevice7
));
385 Thunk_IDirect3DDeviceImpl_1_Release(IDirect3DDevice
*iface
)
387 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
388 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
389 return IDirect3DDevice7_Release(ICOM_INTERFACE(This
, IDirect3DDevice7
));
392 /*****************************************************************************
393 * IDirect3DDevice Methods
394 *****************************************************************************/
396 /*****************************************************************************
397 * IDirect3DDevice::Initialize
399 * Initializes a Direct3DDevice. This implementation is a no-op, as all
400 * initialization is done at create time.
402 * Exists in Version 1
405 * No idea what they mean, as the MSDN page is gone
409 *****************************************************************************/
410 static HRESULT WINAPI
411 IDirect3DDeviceImpl_1_Initialize(IDirect3DDevice
*iface
,
412 IDirect3D
*Direct3D
, GUID
*guid
,
415 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
417 /* It shouldn't be crucial, but print a FIXME, I'm interested if
418 * any game calls it and when
420 FIXME("(%p)->(%p,%p,%p): No-op!\n", This
, Direct3D
, guid
, Desc
);
425 /*****************************************************************************
426 * IDirect3DDevice7::GetCaps
428 * Retrieves the device's capatiblities
430 * This implementation is used for Version 7 only, the older versions have
431 * their own implementation.
434 * Desc: Pointer to a D3DDEVICEDESC7 structure to fill
438 * D3DERR_* if a problem occurs. See WineD3D
440 *****************************************************************************/
441 static HRESULT WINAPI
442 IDirect3DDeviceImpl_7_GetCaps(IDirect3DDevice7
*iface
,
443 D3DDEVICEDESC7
*Desc
)
445 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
446 D3DDEVICEDESC OldDesc
;
447 TRACE("(%p)->(%p)\n", This
, Desc
);
449 /* Call the same function used by IDirect3D, this saves code */
450 return IDirect3DImpl_GetCaps(This
->ddraw
->wineD3D
, &OldDesc
, Desc
);
453 /*****************************************************************************
454 * IDirect3DDevice3::GetCaps
456 * Retrieves the capatiblities of the hardware device and the emulation
457 * device. For Wine, hardware and emulation are the same(it's all HW).
459 * This implementation is used for Version 1, 2, and 3. Version 7 has its own
462 * HWDesc: Structure to fill with the HW caps
463 * HelDesc: Structure to fill with the hardare emulation caps
467 * D3DERR_* if a problem occurs. See WineD3D
469 *****************************************************************************/
470 static HRESULT WINAPI
471 IDirect3DDeviceImpl_3_GetCaps(IDirect3DDevice3
*iface
,
472 D3DDEVICEDESC
*HWDesc
,
473 D3DDEVICEDESC
*HelDesc
)
475 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
476 D3DDEVICEDESC7 newDesc
;
478 TRACE("(%p)->(%p,%p)\n", iface
, HWDesc
, HelDesc
);
480 hr
= IDirect3DImpl_GetCaps(This
->ddraw
->wineD3D
, HWDesc
, &newDesc
);
481 if(hr
!= D3D_OK
) return hr
;
487 static HRESULT WINAPI
488 Thunk_IDirect3DDeviceImpl_2_GetCaps(IDirect3DDevice2
*iface
,
489 D3DDEVICEDESC
*D3DHWDevDesc
,
490 D3DDEVICEDESC
*D3DHELDevDesc
)
492 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
493 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice3 interface.\n", This
, D3DHWDevDesc
, D3DHELDevDesc
);
494 return IDirect3DDevice3_GetCaps(ICOM_INTERFACE(This
, IDirect3DDevice3
),
499 static HRESULT WINAPI
500 Thunk_IDirect3DDeviceImpl_1_GetCaps(IDirect3DDevice
*iface
,
501 D3DDEVICEDESC
*D3DHWDevDesc
,
502 D3DDEVICEDESC
*D3DHELDevDesc
)
504 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
505 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice3 interface.\n", This
, D3DHWDevDesc
, D3DHELDevDesc
);
506 return IDirect3DDevice3_GetCaps(ICOM_INTERFACE(This
, IDirect3DDevice3
),
511 /*****************************************************************************
512 * IDirect3DDevice2::SwapTextureHandles
514 * Swaps the texture handles of 2 Texture interfaces. Version 1 and 2
517 * Tex1, Tex2: The 2 Textures to swap
522 *****************************************************************************/
523 static HRESULT WINAPI
524 IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2
*iface
,
525 IDirect3DTexture2
*Tex1
,
526 IDirect3DTexture2
*Tex2
)
528 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
530 IDirectDrawSurfaceImpl
*surf1
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Tex1
);
531 IDirectDrawSurfaceImpl
*surf2
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Tex2
);
532 TRACE("(%p)->(%p,%p)\n", This
, surf1
, surf2
);
534 This
->Handles
[surf1
->Handle
- 1].ptr
= surf2
;
535 This
->Handles
[surf2
->Handle
- 1].ptr
= surf1
;
537 swap
= surf2
->Handle
;
538 surf2
->Handle
= surf1
->Handle
;
539 surf1
->Handle
= swap
;
544 static HRESULT WINAPI
545 Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles(IDirect3DDevice
*iface
,
546 IDirect3DTexture
*D3DTex1
,
547 IDirect3DTexture
*D3DTex2
)
549 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
550 IDirectDrawSurfaceImpl
*surf1
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture
, D3DTex1
);
551 IDirectDrawSurfaceImpl
*surf2
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture
, D3DTex2
);
552 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", This
, surf1
, surf2
);
553 return IDirect3DDevice2_SwapTextureHandles(ICOM_INTERFACE(This
, IDirect3DDevice2
),
554 ICOM_INTERFACE(surf1
, IDirect3DTexture2
),
555 ICOM_INTERFACE(surf2
, IDirect3DTexture2
));
558 /*****************************************************************************
559 * IDirect3DDevice3::GetStats
561 * This method seems to retrieve some stats from the device.
562 * The MSDN documentation doesn't exist any more, but the D3DSTATS
563 * structure suggests that the amout of drawn primitives and processed
564 * vertices is returned.
566 * Exists in Version 1, 2 and 3
569 * Stats: Pointer to a D3DSTATS structure to be filled
573 * DDERR_INVALIDPARAMS if Stats == NULL
575 *****************************************************************************/
576 static HRESULT WINAPI
577 IDirect3DDeviceImpl_3_GetStats(IDirect3DDevice3
*iface
,
580 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
581 FIXME("(%p)->(%p): Stub!\n", This
, Stats
);
584 return DDERR_INVALIDPARAMS
;
586 /* Fill the Stats with 0 */
587 Stats
->dwTrianglesDrawn
= 0;
588 Stats
->dwLinesDrawn
= 0;
589 Stats
->dwPointsDrawn
= 0;
590 Stats
->dwSpansDrawn
= 0;
591 Stats
->dwVerticesProcessed
= 0;
596 static HRESULT WINAPI
597 Thunk_IDirect3DDeviceImpl_2_GetStats(IDirect3DDevice2
*iface
,
600 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
601 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Stats
);
602 return IDirect3DDevice3_GetStats(ICOM_INTERFACE(This
, IDirect3DDevice3
),
606 static HRESULT WINAPI
607 Thunk_IDirect3DDeviceImpl_1_GetStats(IDirect3DDevice
*iface
,
610 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
611 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Stats
);
612 return IDirect3DDevice3_GetStats(ICOM_INTERFACE(This
, IDirect3DDevice3
),
616 /*****************************************************************************
617 * IDirect3DDevice::CreateExecuteBuffer
619 * Creates an IDirect3DExecuteBuffer, used for rendering with a
625 * Desc: Buffer description
626 * ExecuteBuffer: Address to return the Interface pointer at
627 * UnkOuter: Must be NULL. Basically for aggreation, which ddraw doesn't
631 * CLASS_E_NOAGGREGATION if UnkOuter != NULL
632 * DDERR_OUTOFMEMORY if we ran out of memory
635 *****************************************************************************/
636 static HRESULT WINAPI
637 IDirect3DDeviceImpl_1_CreateExecuteBuffer(IDirect3DDevice
*iface
,
638 D3DEXECUTEBUFFERDESC
*Desc
,
639 IDirect3DExecuteBuffer
**ExecuteBuffer
,
642 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
643 IDirect3DExecuteBufferImpl
* object
;
644 TRACE("(%p)->(%p,%p,%p)!\n", This
, Desc
, ExecuteBuffer
, UnkOuter
);
647 return CLASS_E_NOAGGREGATION
;
649 /* Allocate the new Execute Buffer */
650 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DExecuteBufferImpl
));
653 ERR("Out of memory when allocating a IDirect3DExecuteBufferImpl structure\n");
654 return DDERR_OUTOFMEMORY
;
657 ICOM_INIT_INTERFACE(object
, IDirect3DExecuteBuffer
, IDirect3DExecuteBuffer_Vtbl
);
660 object
->d3ddev
= This
;
662 /* Initializes memory */
663 memcpy(&object
->desc
, Desc
, Desc
->dwSize
);
665 /* No buffer given */
666 if ((object
->desc
.dwFlags
& D3DDEB_LPDATA
) == 0)
667 object
->desc
.lpData
= NULL
;
669 /* No buffer size given */
670 if ((object
->desc
.dwFlags
& D3DDEB_BUFSIZE
) == 0)
671 object
->desc
.dwBufferSize
= 0;
673 /* Create buffer if asked */
674 if ((object
->desc
.lpData
== NULL
) && (object
->desc
.dwBufferSize
> 0))
676 object
->need_free
= TRUE
;
677 object
->desc
.lpData
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,object
->desc
.dwBufferSize
);
678 if(!object
->desc
.lpData
)
680 ERR("Out of memory when allocating the execute buffer data\n");
681 HeapFree(GetProcessHeap(), 0, object
);
682 return DDERR_OUTOFMEMORY
;
687 object
->need_free
= FALSE
;
690 /* No vertices for the moment */
691 object
->vertex_data
= NULL
;
693 object
->desc
.dwFlags
|= D3DDEB_LPDATA
;
695 object
->indices
= NULL
;
696 object
->nb_indices
= 0;
698 *ExecuteBuffer
= ICOM_INTERFACE(object
, IDirect3DExecuteBuffer
);
700 TRACE(" Returning IDirect3DExecuteBuffer at %p, implementation is at %p\n", *ExecuteBuffer
, object
);
705 /*****************************************************************************
706 * IDirect3DDevice::Execute
708 * Executes all the stuff in an execute buffer.
711 * ExecuteBuffer: The buffer to execute
712 * Viewport: The viewport used for rendering
716 * DDERR_INVALIDPARAMS if ExecuteBuffer == NULL
719 *****************************************************************************/
720 static HRESULT WINAPI
721 IDirect3DDeviceImpl_1_Execute(IDirect3DDevice
*iface
,
722 IDirect3DExecuteBuffer
*ExecuteBuffer
,
723 IDirect3DViewport
*Viewport
,
726 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
727 IDirect3DExecuteBufferImpl
*Direct3DExecuteBufferImpl
= ICOM_OBJECT(IDirect3DExecuteBufferImpl
, IDirect3DExecuteBuffer
, ExecuteBuffer
);
728 IDirect3DViewportImpl
*Direct3DViewportImpl
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
730 TRACE("(%p)->(%p,%p,%08lx)\n", This
, Direct3DExecuteBufferImpl
, Direct3DViewportImpl
, Flags
);
732 if(!Direct3DExecuteBufferImpl
)
733 return DDERR_INVALIDPARAMS
;
736 IDirect3DExecuteBufferImpl_Execute(Direct3DExecuteBufferImpl
, This
, Direct3DViewportImpl
);
741 /*****************************************************************************
742 * IDirect3DDevice3::AddViewport
744 * Add a Direct3DViewport to the device's viewport list. These viewports
745 * are wrapped to IDirect3DDevice7 viewports in viewport.c
747 * Exists in Version 1, 2 and 3. Note that IDirect3DViewport 1, 2 and 3
748 * are the same interfaces.
751 * Viewport: The viewport to add
754 * DDERR_INVALIDPARAMS if Viewport == NULL
757 *****************************************************************************/
758 static HRESULT WINAPI
759 IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3
*iface
,
760 IDirect3DViewport3
*Viewport
)
762 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
763 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
765 TRACE("(%p)->(%p)\n", This
, vp
);
769 return DDERR_INVALIDPARAMS
;
771 vp
->next
= This
->viewport_list
;
772 This
->viewport_list
= vp
;
777 static HRESULT WINAPI
778 Thunk_IDirect3DDeviceImpl_2_AddViewport(IDirect3DDevice2
*iface
,
779 IDirect3DViewport2
*Direct3DViewport2
)
781 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
782 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
783 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
784 return IDirect3DDevice3_AddViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
785 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
788 static HRESULT WINAPI
789 Thunk_IDirect3DDeviceImpl_1_AddViewport(IDirect3DDevice
*iface
,
790 IDirect3DViewport
*Direct3DViewport
)
792 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
793 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport
);
794 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
795 return IDirect3DDevice3_AddViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
796 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
799 /*****************************************************************************
800 * IDirect3DDevice3::DeleteViewport
802 * Deletes a Direct3DViewport from the device's viewport list.
804 * Exists in Version 1, 2 and 3. Note that all Viewport interface versions
808 * Viewport: The viewport to delete
812 * DDERR_INVALIDPARAMS if the viewport wasn't found in the list
814 *****************************************************************************/
815 static HRESULT WINAPI
816 IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3
*iface
,
817 IDirect3DViewport3
*Viewport
)
819 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
820 IDirect3DViewportImpl
*vp
= (IDirect3DViewportImpl
*) Viewport
;
821 IDirect3DViewportImpl
*cur_viewport
, *prev_viewport
= NULL
;
823 TRACE("(%p)->(%p)\n", This
, vp
);
825 cur_viewport
= This
->viewport_list
;
826 while (cur_viewport
!= NULL
)
828 if (cur_viewport
== vp
)
830 if (prev_viewport
== NULL
) This
->viewport_list
= cur_viewport
->next
;
831 else prev_viewport
->next
= cur_viewport
->next
;
832 /* TODO : add desactivate of the viewport and all associated lights... */
835 prev_viewport
= cur_viewport
;
836 cur_viewport
= cur_viewport
->next
;
839 return DDERR_INVALIDPARAMS
;
842 static HRESULT WINAPI
843 Thunk_IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2
*iface
,
844 IDirect3DViewport2
*Direct3DViewport2
)
846 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
847 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
848 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
849 return IDirect3DDevice3_DeleteViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
850 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
853 static HRESULT WINAPI
854 Thunk_IDirect3DDeviceImpl_1_DeleteViewport(IDirect3DDevice
*iface
,
855 IDirect3DViewport
*Direct3DViewport2
)
857 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
858 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
859 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
860 return IDirect3DDevice3_DeleteViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
861 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
864 /*****************************************************************************
865 * IDirect3DDevice3::NextViewport
867 * Returns an viewport from the viewport list, depending on the
868 * passed viewport and the flags.
870 * Exists in Version 1, 2 and 3. Note that all Viewport interface versions
874 * Viewport: Viewport to use for beginning the search
875 * Flags: D3DNEXT_NEXT, D3DNEXT_HEAD or D3DNEXT_TAIL
879 * DDERR_INVALIDPARAMS if the flags were wrong, ir Viewport was NULL
881 *****************************************************************************/
882 static HRESULT WINAPI
883 IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3
*iface
,
884 IDirect3DViewport3
*Viewport3
,
885 IDirect3DViewport3
**lplpDirect3DViewport3
,
888 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
889 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport3
);
890 IDirect3DViewportImpl
*res
= NULL
;
892 TRACE("(%p)->(%p,%p,%08lx)\n", This
, vp
, lplpDirect3DViewport3
, Flags
);
896 return DDERR_INVALIDPARAMS
;
897 *lplpDirect3DViewport3
= NULL
;
910 res
= This
->viewport_list
;
915 IDirect3DViewportImpl
*cur_viewport
= This
->viewport_list
;
916 if (cur_viewport
!= NULL
)
918 while (cur_viewport
->next
!= NULL
) cur_viewport
= cur_viewport
->next
;
924 *lplpDirect3DViewport3
= NULL
;
925 return DDERR_INVALIDPARAMS
;
928 *lplpDirect3DViewport3
= ICOM_INTERFACE(res
, IDirect3DViewport3
);
932 static HRESULT WINAPI
933 Thunk_IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2
*iface
,
934 IDirect3DViewport2
*Viewport2
,
935 IDirect3DViewport2
**lplpDirect3DViewport2
,
938 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
939 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport2
);
940 IDirect3DViewport3
*res
;
942 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08lx) thunking to IDirect3DDevice3 interface.\n", This
, vp
, lplpDirect3DViewport2
, Flags
);
943 hr
= IDirect3DDevice3_NextViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
944 ICOM_INTERFACE(vp
, IDirect3DViewport3
),
947 *lplpDirect3DViewport2
= (IDirect3DViewport2
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, res
);
951 static HRESULT WINAPI
952 Thunk_IDirect3DDeviceImpl_1_NextViewport(IDirect3DDevice
*iface
,
953 IDirect3DViewport
*Viewport
,
954 IDirect3DViewport
**lplpDirect3DViewport
,
957 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
958 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
959 IDirect3DViewport3
*res
;
961 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08lx) thunking to IDirect3DDevice3 interface.\n", This
, vp
, lplpDirect3DViewport
, Flags
);
962 hr
= IDirect3DDevice3_NextViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
963 ICOM_INTERFACE(vp
, IDirect3DViewport3
),
966 *lplpDirect3DViewport
= (IDirect3DViewport
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, res
);
970 /*****************************************************************************
971 * IDirect3DDevice::Pick
973 * Executes an execute buffer without performing rendering. Instead, a
974 * list of primitives that intersect with (x1,y1) of the passed rectangle
975 * is created. IDirect3DDevice::GetPickRecords can be used to retrieve
981 * ExecuteBuffer: Buffer to execute
982 * Viewport: Viewport to use for execution
983 * Flags: None are defined, according to the SDK
984 * Rect: Specifies the coordinates to be picked. Only x1 and y2 are used,
985 * x2 and y2 are ignored.
988 * D3D_OK because it's a stub
990 *****************************************************************************/
991 static HRESULT WINAPI
992 IDirect3DDeviceImpl_1_Pick(IDirect3DDevice
*iface
,
993 IDirect3DExecuteBuffer
*ExecuteBuffer
,
994 IDirect3DViewport
*Viewport
,
998 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
999 IDirect3DExecuteBufferImpl
*execbuf
= ICOM_OBJECT(IDirect3DExecuteBufferImpl
, IDirect3DExecuteBuffer
, ExecuteBuffer
);
1000 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Viewport
);
1001 FIXME("(%p)->(%p,%p,%08lx,%p): stub!\n", This
, execbuf
, vp
, Flags
, Rect
);
1006 /*****************************************************************************
1007 * IDirect3DDevice::GetPickRecords
1009 * Retrieves the pick records generated by IDirect3DDevice::GetPickRecords
1014 * Count: Pointer to a DWORD containing the numbers of pick records to
1016 * D3DPickRec: Address to store the resulting D3DPICKRECORD arry.
1019 * D3D_OK, because it's a stub
1021 *****************************************************************************/
1022 static HRESULT WINAPI
1023 IDirect3DDeviceImpl_1_GetPickRecords(IDirect3DDevice
*iface
,
1025 D3DPICKRECORD
*D3DPickRec
)
1027 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1028 FIXME("(%p)->(%p,%p): stub!\n", This
, Count
, D3DPickRec
);
1033 /*****************************************************************************
1034 * EnumTextureFormatsCB
1036 * Callback called by WineD3D for each enumerated Texture format. It
1037 * translates the WineD3DFormat into a ddraw pixel format and calls
1038 * the application callback
1041 * Device: The WineD3DDevice's parents = The IDirect3DDevice7 interface
1043 * fmt: An enumerated pixel format
1044 * Context: Data pointer passed to WineD3D by
1045 * IDirect3DDevice7::EnumTexureformats
1048 * The return value of the application-provided callback
1050 *****************************************************************************/
1051 static HRESULT WINAPI
1052 EnumTextureFormatsCB(IUnknown
*Device
,
1056 struct EnumTextureFormatsCBS
*cbs
= (struct EnumTextureFormatsCBS
*) Context
;
1058 DDSURFACEDESC sdesc
;
1059 DDPIXELFORMAT
*pformat
;
1061 memset(&sdesc
, 0, sizeof(DDSURFACEDESC
));
1062 sdesc
.dwSize
= sizeof(DDSURFACEDESC
);
1063 sdesc
.dwFlags
= DDSD_PIXELFORMAT
| DDSD_CAPS
;
1064 sdesc
.ddsCaps
.dwCaps
= DDSCAPS_TEXTURE
;
1065 pformat
= &(sdesc
.ddpfPixelFormat
);
1066 pformat
->dwSize
= sizeof(DDPIXELFORMAT
);
1068 PixelFormat_WineD3DtoDD(pformat
, fmt
);
1070 if( ( fmt
== WINED3DFMT_UYVY
) ||
1071 ( fmt
== WINED3DFMT_YUY2
) ||
1072 ( fmt
== WINED3DFMT_DXT1
) ||
1073 ( fmt
== WINED3DFMT_DXT2
) ||
1074 ( fmt
== WINED3DFMT_DXT3
) ||
1075 ( fmt
== WINED3DFMT_DXT4
) ||
1076 ( fmt
== WINED3DFMT_DXT5
) ||
1077 ( fmt
== WINED3DFMT_MULTI2_ARGB
) ||
1078 ( fmt
== WINED3DFMT_G8R8_G8B8
) ||
1079 ( fmt
== WINED3DFMT_R8G8_B8G8
) ||
1080 ( fmt
== WINED3DFMT_L8
) ||
1081 ( fmt
== WINED3DFMT_A8L8
) ||
1082 ( fmt
== WINED3DFMT_A4L4
) ||
1083 ( fmt
== WINED3DFMT_V8U8
) ||
1084 ( fmt
== WINED3DFMT_L6V5U5
) )
1086 /* These formats exist exist in D3D3 and D3D7 only,
1087 * so do not call the older callback
1089 if(cbs
->cbv7
) return cbs
->cbv7(pformat
, cbs
->Context
);
1093 /* Only one of these should be passed */
1094 if(cbs
->cbv2
) return cbs
->cbv2(&sdesc
, cbs
->Context
);
1095 if(cbs
->cbv7
) return cbs
->cbv7(pformat
, cbs
->Context
);
1098 return DDENUMRET_OK
;
1101 /*****************************************************************************
1102 * IDirect3DDevice7::EnumTextureformats
1104 * Enumerates the supported texture formats. This is relayed to WineD3D,
1105 * and a EnumTextureFormatsCB translated the WineD3DFormats to DDraw
1106 * formats and calls the application callback.
1108 * This is for Version 7 and 3, the older versions have a different
1109 * callback function and their own implementation
1112 * Callback: Callback to call for each enumerated format
1113 * Arg: Argument to pass to the callback
1117 * DDERR_INVALIDPARAMS if Callback == NULL
1119 *****************************************************************************/
1120 static HRESULT WINAPI
1121 IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7
*iface
,
1122 LPD3DENUMPIXELFORMATSCALLBACK Callback
,
1125 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1127 struct EnumTextureFormatsCBS cbs
= { NULL
, Callback
, Arg
};
1128 TRACE("(%p)->(%p,%p): Relay\n", This
, Callback
, Arg
);
1131 return DDERR_INVALIDPARAMS
;
1133 hr
= IWineD3DDevice_EnumTextureFormats(This
->wineD3DDevice
,
1134 EnumTextureFormatsCB
,
1136 return hr_ddraw_from_wined3d(hr
);
1139 static HRESULT WINAPI
1140 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats(IDirect3DDevice3
*iface
,
1141 LPD3DENUMPIXELFORMATSCALLBACK Callback
,
1144 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1145 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice7 interface.\n", This
, Callback
, Arg
);
1146 return IDirect3DDevice7_EnumTextureFormats(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1151 /*****************************************************************************
1152 * IDirect3DDevice2::EnumTextureformats
1154 * EnumTextureFormats for Version 1 and 2, see
1155 * IDirect3DDevice7::EnumTexureFormats for a more detailed description
1157 *****************************************************************************/
1158 static HRESULT WINAPI
1159 IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2
*iface
,
1160 LPD3DENUMTEXTUREFORMATSCALLBACK Callback
,
1163 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1165 struct EnumTextureFormatsCBS cbs
= { Callback
, NULL
, Arg
};
1166 TRACE("(%p)->(%p,%p): Relay\n", This
, Callback
, Arg
);
1168 hr
= IWineD3DDevice_EnumTextureFormats(This
->wineD3DDevice
,
1169 EnumTextureFormatsCB
,
1171 return hr_ddraw_from_wined3d(hr
);
1174 static HRESULT WINAPI
1175 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats(IDirect3DDevice
*iface
,
1176 LPD3DENUMTEXTUREFORMATSCALLBACK Callback
,
1179 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1180 TRACE_(ddraw_thunk
)("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", This
, Callback
, Arg
);
1181 return IDirect3DDevice2_EnumTextureFormats(ICOM_INTERFACE(This
, IDirect3DDevice2
),
1186 /*****************************************************************************
1187 * IDirect3DDevice::CreateMatrix
1189 * Creates a matrix handle. In Wine, Matrix handles are simply pointers
1190 * to a D3DMATRIX structure
1195 * D3DMatHandle: Address to return the handle at
1199 * DDERR_INVALIDPARAMS if D3DMatHandle = NULL
1201 *****************************************************************************/
1202 static HRESULT WINAPI
1203 IDirect3DDeviceImpl_1_CreateMatrix(IDirect3DDevice
*iface
, D3DMATRIXHANDLE
*D3DMatHandle
)
1205 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1206 TRACE("(%p)->(%p)\n", This
, D3DMatHandle
);
1209 return DDERR_INVALIDPARAMS
;
1211 *D3DMatHandle
= (D3DMATRIXHANDLE
) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(D3DMATRIX
));
1212 TRACE(" returning matrix handle %p\n", (void *) *D3DMatHandle
);
1217 /*****************************************************************************
1218 * IDirect3DDevice::SetMatrix
1220 * Sets a matrix for a matrix handle. As matrix handles are pointers to
1221 * a D3DMATRIX structure, the matrix is simply copied into the allocated
1227 * D3DMatHandle: Handle to set the matrix to
1228 * D3DMatrix: Matrix to set
1232 * DDERR_INVALIDPARAMS if the handle of the matrix is NULL
1234 *****************************************************************************/
1235 static HRESULT WINAPI
1236 IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice
*iface
,
1237 D3DMATRIXHANDLE D3DMatHandle
,
1238 D3DMATRIX
*D3DMatrix
)
1240 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1241 TRACE("(%p)->(%08lx,%p)\n", This
, (DWORD
) D3DMatHandle
, D3DMatrix
);
1243 if( (!D3DMatHandle
) || (!D3DMatrix
) )
1244 return DDERR_INVALIDPARAMS
;
1247 dump_D3DMATRIX(D3DMatrix
);
1249 *((D3DMATRIX
*) D3DMatHandle
) = *D3DMatrix
;
1254 /*****************************************************************************
1255 * IDirect3DDevice::SetMatrix
1257 * Returns the content of a D3DMATRIX handle
1262 * D3DMatHandle: Matrix handle to read the content from
1263 * D3DMatrix: Address to store the content at
1267 * DDERR_INVALIDPARAMS if D3DMatHandle or D3DMatrix are NULL
1269 *****************************************************************************/
1270 static HRESULT WINAPI
1271 IDirect3DDeviceImpl_1_GetMatrix(IDirect3DDevice
*iface
,
1272 D3DMATRIXHANDLE D3DMatHandle
,
1273 D3DMATRIX
*D3DMatrix
)
1275 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1276 TRACE("(%p)->(%08lx,%p)\n", This
, (DWORD
) D3DMatHandle
, D3DMatrix
);
1279 return DDERR_INVALIDPARAMS
;
1280 if(!(D3DMATRIX
*) D3DMatHandle
)
1281 return DDERR_INVALIDPARAMS
;
1283 /* The handle is simply a pointer to a D3DMATRIX structure */
1284 *D3DMatrix
= *((D3DMATRIX
*) D3DMatHandle
);
1289 /*****************************************************************************
1290 * IDirect3DDevice::DeleteMatrix
1292 * Destroys a Matrix handle.
1297 * D3DMatHandle: Handle to destroy
1301 * DDERR_INVALIDPARAMS if D3DMatHandle is NULL
1303 *****************************************************************************/
1304 static HRESULT WINAPI
1305 IDirect3DDeviceImpl_1_DeleteMatrix(IDirect3DDevice
*iface
,
1306 D3DMATRIXHANDLE D3DMatHandle
)
1308 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1309 TRACE("(%p)->(%08lx)\n", This
, (DWORD
) D3DMatHandle
);
1311 if(!(D3DMATRIX
*) D3DMatHandle
)
1312 return DDERR_INVALIDPARAMS
;
1314 HeapFree(GetProcessHeap(), 0, (void *) D3DMatHandle
);
1319 /*****************************************************************************
1320 * IDirect3DDevice7::BeginScene
1322 * This method must be called before any rendering is performed.
1323 * IDirect3DDevice::EndScene has to be called after the scene is complete
1325 * Version 1, 2, 3 and 7
1328 * D3D_OK on sucess, for details see IWineD3DDevice::BeginScene
1330 *****************************************************************************/
1331 static HRESULT WINAPI
1332 IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7
*iface
)
1334 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1335 TRACE("(%p): Relay\n", This
);
1337 return IWineD3DDevice_BeginScene(This
->wineD3DDevice
);
1340 static HRESULT WINAPI
1341 Thunk_IDirect3DDeviceImpl_3_BeginScene(IDirect3DDevice3
*iface
)
1343 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1344 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1345 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1348 static HRESULT WINAPI
1349 Thunk_IDirect3DDeviceImpl_2_BeginScene(IDirect3DDevice2
*iface
)
1351 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1352 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1353 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1356 static HRESULT WINAPI
1357 Thunk_IDirect3DDeviceImpl_1_BeginScene(IDirect3DDevice
*iface
)
1359 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1360 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1361 return IDirect3DDevice7_BeginScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1364 /*****************************************************************************
1365 * IDirect3DDevice7::EndScene
1367 * Ends a scene that has been begun with IDirect3DDevice7::BeginScene.
1368 * This method must be called after rendering is finished.
1370 * Version 1, 2, 3 and 7
1373 * D3D_OK on success, for details see IWineD3DDevice::EndScene
1375 *****************************************************************************/
1376 static HRESULT WINAPI
1377 IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7
*iface
)
1379 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1380 TRACE("(%p): Relay\n", This
);
1382 IWineD3DDevice_EndScene(This
->wineD3DDevice
);
1386 static HRESULT WINAPI
1387 Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3
*iface
)
1389 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1390 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1391 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1394 static HRESULT WINAPI
1395 Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2
*iface
)
1397 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1398 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1399 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1402 static HRESULT WINAPI
1403 Thunk_IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice
*iface
)
1405 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1406 TRACE_(ddraw_thunk
)("(%p)->() thunking to IDirect3DDevice7 interface.\n", This
);
1407 return IDirect3DDevice7_EndScene(ICOM_INTERFACE(This
, IDirect3DDevice7
));
1410 /*****************************************************************************
1411 * IDirect3DDevice7::GetDirect3D
1413 * Returns the IDirect3D(= interface to the DirectDraw object) used to create
1417 * Direct3D7: Address to store the interface pointer at
1421 * DDERR_INVALIDPARAMS if Direct3D7 == NULL
1423 *****************************************************************************/
1424 static HRESULT WINAPI
1425 IDirect3DDeviceImpl_7_GetDirect3D(IDirect3DDevice7
*iface
,
1426 IDirect3D7
**Direct3D7
)
1428 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1429 TRACE("(%p)->(%p)\n", This
, Direct3D7
);
1432 return DDERR_INVALIDPARAMS
;
1434 *Direct3D7
= ICOM_INTERFACE(This
->ddraw
, IDirect3D7
);
1435 IDirect3D7_AddRef(*Direct3D7
);
1437 TRACE(" returning interface %p\n", *Direct3D7
);
1441 static HRESULT WINAPI
1442 Thunk_IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3
*iface
,
1443 IDirect3D3
**Direct3D3
)
1445 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1447 IDirect3D7
*ret_ptr
;
1449 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D3
);
1450 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1454 *Direct3D3
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D3
, ret_ptr
);
1455 TRACE(" returning interface %p\n", *Direct3D3
);
1459 static HRESULT WINAPI
1460 Thunk_IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2
*iface
,
1461 IDirect3D2
**Direct3D2
)
1463 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1465 IDirect3D7
*ret_ptr
;
1467 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D2
);
1468 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1472 *Direct3D2
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D2
, ret_ptr
);
1473 TRACE(" returning interface %p\n", *Direct3D2
);
1477 static HRESULT WINAPI
1478 Thunk_IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice
*iface
,
1479 IDirect3D
**Direct3D
)
1481 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice
, iface
);
1483 IDirect3D7
*ret_ptr
;
1485 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Direct3D
);
1486 ret
= IDirect3DDevice7_GetDirect3D(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1490 *Direct3D
= COM_INTERFACE_CAST(IDirectDrawImpl
, IDirect3D7
, IDirect3D
, ret_ptr
);
1491 TRACE(" returning interface %p\n", *Direct3D
);
1495 /*****************************************************************************
1496 * IDirect3DDevice3::SetCurrentViewport
1498 * Sets a Direct3DViewport as the current viewport.
1499 * For the thunks note that all viewport interface versions are equal
1502 * Direct3DViewport3: The viewport to set
1508 * (Is a NULL viewport valid?)
1510 *****************************************************************************/
1511 static HRESULT WINAPI
1512 IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3
*iface
,
1513 IDirect3DViewport3
*Direct3DViewport3
)
1515 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1516 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport3
);
1517 TRACE("(%p)->(%p)\n", This
, Direct3DViewport3
);
1519 /* Do nothing if the specified viewport is the same as the current one */
1520 if (This
->current_viewport
== vp
)
1523 /* Should check if the viewport was added or not */
1525 /* Release previous viewport and AddRef the new one */
1526 if (This
->current_viewport
)
1528 TRACE("ViewportImpl is at %p, interface is at %p\n", This
->current_viewport
, ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
));
1529 IDirect3DViewport3_Release( ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
) );
1531 IDirect3DViewport3_AddRef(Direct3DViewport3
);
1533 /* Set this viewport as the current viewport */
1534 This
->current_viewport
= vp
;
1536 /* Activate this viewport */
1537 This
->current_viewport
->active_device
= This
;
1538 This
->current_viewport
->activate(This
->current_viewport
);
1543 static HRESULT WINAPI
1544 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2
*iface
,
1545 IDirect3DViewport2
*Direct3DViewport2
)
1547 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1548 IDirect3DViewportImpl
*vp
= ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, Direct3DViewport2
);
1549 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, vp
);
1550 return IDirect3DDevice3_SetCurrentViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1551 ICOM_INTERFACE(vp
, IDirect3DViewport3
));
1554 /*****************************************************************************
1555 * IDirect3DDevice3::GetCurrentViewport
1557 * Returns the currently active viewport.
1562 * Direct3DViewport3: Address to return the interface pointer at
1566 * DDERR_INVALIDPARAMS if Direct3DViewport == NULL
1568 *****************************************************************************/
1569 static HRESULT WINAPI
1570 IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3
*iface
,
1571 IDirect3DViewport3
**Direct3DViewport3
)
1573 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1574 TRACE("(%p)->(%p)\n", This
, Direct3DViewport3
);
1576 if(!Direct3DViewport3
)
1577 return DDERR_INVALIDPARAMS
;
1579 *Direct3DViewport3
= ICOM_INTERFACE(This
->current_viewport
, IDirect3DViewport3
);
1581 /* AddRef the returned viewport */
1582 IDirect3DViewport3_AddRef(*Direct3DViewport3
);
1584 TRACE(" returning interface %p\n", *Direct3DViewport3
);
1589 static HRESULT WINAPI
1590 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(IDirect3DDevice2
*iface
,
1591 IDirect3DViewport2
**Direct3DViewport2
)
1593 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1595 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, Direct3DViewport2
);
1596 hr
= IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1597 (IDirect3DViewport3
**) Direct3DViewport2
);
1598 if(hr
!= D3D_OK
) return hr
;
1599 *Direct3DViewport2
= (IDirect3DViewport2
*) COM_INTERFACE_CAST(IDirect3DViewportImpl
, IDirect3DViewport3
, IDirect3DViewport3
, Direct3DViewport2
);
1603 /*****************************************************************************
1604 * IDirect3DDevice7::SetRenderTarget
1606 * Sets the render target for the Direct3DDevice.
1607 * For the thunks note that IDirectDrawSurface7 == IDirectDrawSurface4 and
1608 * IDirectDrawSurface3 == IDirectDrawSurface
1610 * Version 2, 3 and 7
1613 * NewTarget: Pointer to an IDirectDrawSurface7 interface to set as the new
1618 * D3D_OK on success, for details see IWineD3DDevice::SetRenderTarget
1620 *****************************************************************************/
1621 static HRESULT WINAPI
1622 IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7
*iface
,
1623 IDirectDrawSurface7
*NewTarget
,
1626 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1627 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, NewTarget
);
1628 TRACE("(%p)->(%p,%08lx): Relay\n", This
, NewTarget
, Flags
);
1630 /* Flags: Not used */
1632 return IWineD3DDevice_SetRenderTarget(This
->wineD3DDevice
,
1634 Target
? Target
->WineD3DSurface
: NULL
);
1637 static HRESULT WINAPI
1638 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3
*iface
,
1639 IDirectDrawSurface4
*NewRenderTarget
,
1642 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1643 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, NewRenderTarget
);
1644 TRACE_(ddraw_thunk
)("(%p)->(%p,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, Target
, Flags
);
1645 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1646 ICOM_INTERFACE(Target
, IDirectDrawSurface7
),
1650 static HRESULT WINAPI
1651 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2
*iface
,
1652 IDirectDrawSurface
*NewRenderTarget
,
1655 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1656 IDirectDrawSurfaceImpl
*Target
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface3
, NewRenderTarget
);
1657 TRACE_(ddraw_thunk
)("(%p)->(%p,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, Target
, Flags
);
1658 return IDirect3DDevice7_SetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1659 ICOM_INTERFACE(Target
, IDirectDrawSurface7
),
1663 /*****************************************************************************
1664 * IDirect3DDevice7::GetRenderTarget
1666 * Returns the current render target.
1667 * This is handled locally, because the WineD3D render target's parent
1670 * Version 2, 3 and 7
1673 * RenderTarget: Address to store the surface interface pointer
1677 * DDERR_INVALIDPARAMS if RenderTarget == NULL
1679 *****************************************************************************/
1680 static HRESULT WINAPI
1681 IDirect3DDeviceImpl_7_GetRenderTarget(IDirect3DDevice7
*iface
,
1682 IDirectDrawSurface7
**RenderTarget
)
1684 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1685 TRACE("(%p)->(%p): Relay\n", This
, RenderTarget
);
1688 return DDERR_INVALIDPARAMS
;
1690 *RenderTarget
= ICOM_INTERFACE(This
->target
, IDirectDrawSurface7
);
1691 IDirectDrawSurface7_AddRef(*RenderTarget
);
1696 static HRESULT WINAPI
1697 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3
*iface
,
1698 IDirectDrawSurface4
**RenderTarget
)
1700 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1702 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, RenderTarget
);
1703 hr
= IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1704 (IDirectDrawSurface7
**) RenderTarget
);
1705 if(hr
!= D3D_OK
) return hr
;
1706 *RenderTarget
= (IDirectDrawSurface4
*) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirectDrawSurface7
, RenderTarget
);
1710 static HRESULT WINAPI
1711 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(IDirect3DDevice2
*iface
,
1712 IDirectDrawSurface
**RenderTarget
)
1714 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1716 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, RenderTarget
);
1717 hr
= IDirect3DDevice7_GetRenderTarget(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1718 (IDirectDrawSurface7
**) RenderTarget
);
1719 if(hr
!= D3D_OK
) return hr
;
1720 *RenderTarget
= (IDirectDrawSurface
*) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirectDrawSurface3
, RenderTarget
);
1724 /*****************************************************************************
1725 * IDirect3DDevice3::Begin
1727 * Begins a description block of vertices. This is simmilar to glBegin()
1728 * and glEnd(). After a call to IDirect3DDevice3::End, the vertices
1729 * described with IDirect3DDevice::Vertex are drawn.
1734 * PrimitiveType: The type of primitives to draw
1735 * VertexTypeDesc: A flexible vertex format description of the vertices
1736 * Flags: Some flags..
1741 *****************************************************************************/
1742 static HRESULT WINAPI
1743 IDirect3DDeviceImpl_3_Begin(IDirect3DDevice3
*iface
,
1744 D3DPRIMITIVETYPE PrimitiveType
,
1745 DWORD VertexTypeDesc
,
1748 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1749 TRACE("(%p)->(%d,%ld,%08lx)\n", This
, PrimitiveType
, VertexTypeDesc
, Flags
);
1751 This
->primitive_type
= PrimitiveType
;
1752 This
->vertex_type
= VertexTypeDesc
;
1753 This
->render_flags
= Flags
;
1754 This
->vertex_size
= get_flexible_vertex_size(This
->vertex_type
);
1755 This
->nb_vertices
= 0;
1760 static HRESULT WINAPI
1761 Thunk_IDirect3DDeviceImpl_2_Begin(IDirect3DDevice2
*iface
,
1762 D3DPRIMITIVETYPE d3dpt
,
1763 D3DVERTEXTYPE dwVertexTypeDesc
,
1767 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1768 TRACE_(ddraw_thunk
)("(%p/%p)->(%08x,%08x,%08lx): Thunking to IDirect3DDevice3\n", This
, iface
, d3dpt
, dwVertexTypeDesc
, dwFlags
);
1770 switch(dwVertexTypeDesc
)
1772 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
1773 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
1774 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
1776 assert(0); /* Should never happen */
1779 return IDirect3DDevice3_Begin(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1785 /*****************************************************************************
1786 * IDirect3DDevice3::BeginIndexed
1788 * Draws primitives based on vertices in a vertex array which are specified
1794 * PrimitiveType: Primitive type to draw
1795 * VertexType: A FVF description of the vertex format
1796 * Vertices: pointer to an array containg the vertices
1797 * NumVertices: The number of vertices in the vertex array
1798 * Flags: Some flags ...
1801 * D3D_OK, because it's a stub
1803 *****************************************************************************/
1804 static HRESULT WINAPI
1805 IDirect3DDeviceImpl_3_BeginIndexed(IDirect3DDevice3
*iface
,
1806 D3DPRIMITIVETYPE PrimitiveType
,
1812 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1813 FIXME("(%p)->(%08x,%08lx,%p,%08lx,%08lx): stub!\n", This
, PrimitiveType
, VertexType
, Vertices
, NumVertices
, Flags
);
1818 static HRESULT WINAPI
1819 Thunk_IDirect3DDeviceImpl_2_BeginIndexed(IDirect3DDevice2
*iface
,
1820 D3DPRIMITIVETYPE d3dptPrimitiveType
,
1821 D3DVERTEXTYPE d3dvtVertexType
,
1823 DWORD dwNumVertices
,
1827 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1828 TRACE_(ddraw_thunk
)("(%p/%p)->(%08x,%08x,%p,%08lx,%08lx): Thunking to IDirect3DDevice3\n", This
, iface
, d3dptPrimitiveType
, d3dvtVertexType
, lpvVertices
, dwNumVertices
, dwFlags
);
1830 switch(d3dvtVertexType
)
1832 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
1833 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
1834 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
1836 assert(0); /* Should never happen */
1839 return IDirect3DDevice3_BeginIndexed(ICOM_INTERFACE(This
,IDirect3DDevice3
),
1847 /*****************************************************************************
1848 * IDirect3DDevice3::Vertex
1850 * Draws a vertex as described by IDirect3DDevice3::Begin. It places all
1851 * drawn vertices in an vertex buffer. If the buffer is to small, its
1852 * size is increased.
1857 * Vertex: Pointer to the vertex
1860 * D3D_OK, on success
1861 * DDERR_INVALIDPARAMS if Vertex is NULL
1863 *****************************************************************************/
1864 static HRESULT WINAPI
1865 IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3
*iface
,
1868 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1869 TRACE("(%p)->(%p)\n", This
, Vertex
);
1872 return DDERR_INVALIDPARAMS
;
1874 if ((This
->nb_vertices
+1)*This
->vertex_size
> This
->buffer_size
)
1877 This
->buffer_size
= This
->buffer_size
? This
->buffer_size
* 2 : This
->vertex_size
* 3;
1878 old_buffer
= This
->vertex_buffer
;
1879 This
->vertex_buffer
= HeapAlloc(GetProcessHeap(), 0, This
->buffer_size
);
1882 CopyMemory(This
->vertex_buffer
, old_buffer
, This
->nb_vertices
* This
->vertex_size
);
1883 HeapFree(GetProcessHeap(), 0, old_buffer
);
1887 CopyMemory(This
->vertex_buffer
+ This
->nb_vertices
++ * This
->vertex_size
, Vertex
, This
->vertex_size
);
1892 static HRESULT WINAPI
1893 Thunk_IDirect3DDeviceImpl_2_Vertex(IDirect3DDevice2
*iface
,
1896 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1897 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", This
, lpVertexType
);
1898 return IDirect3DDevice3_Vertex(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1902 /*****************************************************************************
1903 * IDirect3DDevice3::Index
1905 * Specifies an index to an vertex to be drawn. The vertex array has to
1906 * be specified with BeginIndexed first.
1909 * VertexIndex: The index of the vertex to draw
1912 * D3D_OK because it's a stub
1914 *****************************************************************************/
1915 static HRESULT WINAPI
1916 IDirect3DDeviceImpl_3_Index(IDirect3DDevice3
*iface
,
1919 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1920 FIXME("(%p)->(%04x): stub!\n", This
, VertexIndex
);
1924 static HRESULT WINAPI
1925 Thunk_IDirect3DDeviceImpl_2_Index(IDirect3DDevice2
*iface
,
1928 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1929 TRACE_(ddraw_thunk
)("(%p)->(%04x) thunking to IDirect3DDevice3 interface.\n", This
, wVertexIndex
);
1930 return IDirect3DDevice3_Index(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1934 /*****************************************************************************
1935 * IDirect3DDevice3::End
1937 * Ends a draw begun with IDirect3DDevice3::Begin or
1938 * IDirect3DDevice::BeginIndexed. The vertices specified with
1939 * IDirect3DDevice::Vertex or IDirect3DDevice::Index are drawn using
1940 * the IDirect3DDevice7::DrawPrimitive method. So far only
1941 * non-indexed mode is supported
1946 * Flags: Some flags, as usual. Don't know which are defined
1949 * The return value of IDirect3DDevice7::DrawPrimitive
1951 *****************************************************************************/
1952 static HRESULT WINAPI
1953 IDirect3DDeviceImpl_3_End(IDirect3DDevice3
*iface
,
1956 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
1957 TRACE("(%p)->(%08lx)\n", This
, Flags
);
1959 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
1960 This
->primitive_type
, This
->vertex_type
,
1961 This
->vertex_buffer
, This
->nb_vertices
,
1962 This
->render_flags
);
1965 static HRESULT WINAPI
1966 Thunk_IDirect3DDeviceImpl_2_End(IDirect3DDevice2
*iface
,
1969 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
1970 TRACE_(ddraw_thunk
)("(%p)->(%08lx) thunking to IDirect3DDevice3 interface.\n", This
, dwFlags
);
1971 return IDirect3DDevice3_End(ICOM_INTERFACE(This
, IDirect3DDevice3
),
1975 /*****************************************************************************
1976 * IDirect3DDevice7::GetRenderState
1978 * Returns the value of a render state. The possible render states are
1979 * defined in include/d3dtypes.h
1981 * Version 2, 3 and 7
1984 * RenderStateType: Render state to return the current setting of
1985 * Value: Address to store the value at
1988 * D3D_OK on success, for details see IWineD3DDevice::GetRenderState
1989 * DDERR_INVALIDPARAMS if Value == NULL
1991 *****************************************************************************/
1992 static HRESULT WINAPI
1993 IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7
*iface
,
1994 D3DRENDERSTATETYPE RenderStateType
,
1997 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
1998 TRACE("(%p)->(%08x,%p): Relay\n", This
, RenderStateType
, Value
);
2001 return DDERR_INVALIDPARAMS
;
2003 return IWineD3DDevice_GetRenderState(This
->wineD3DDevice
,
2008 static HRESULT WINAPI
2009 Thunk_IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3
*iface
,
2010 D3DRENDERSTATETYPE dwRenderStateType
,
2011 DWORD
*lpdwRenderState
)
2013 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2014 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, dwRenderStateType
, lpdwRenderState
);
2015 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2020 static HRESULT WINAPI
2021 Thunk_IDirect3DDeviceImpl_2_GetRenderState(IDirect3DDevice2
*iface
,
2022 D3DRENDERSTATETYPE dwRenderStateType
,
2023 DWORD
*lpdwRenderState
)
2025 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2026 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, dwRenderStateType
, lpdwRenderState
);
2027 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2032 /*****************************************************************************
2033 * IDirect3DDevice7::SetRenderState
2035 * Sets a render state. The possible render states are defined in
2036 * include/d3dtypes.h
2038 * Version 2, 3 and 7
2041 * RenderStateType: State to set
2042 * Value: Value to assign to that state
2045 * D3D_OK on success,
2046 * for details see IWineD3DDevice::SetRenderState
2048 *****************************************************************************/
2049 static HRESULT WINAPI
2050 IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7
*iface
,
2051 D3DRENDERSTATETYPE RenderStateType
,
2054 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2055 TRACE("(%p)->(%08x,%ld): Relay\n", This
, RenderStateType
, Value
);
2057 /* Some render states need special care */
2058 switch(RenderStateType
)
2060 case D3DRENDERSTATE_TEXTUREHANDLE
:
2064 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
2069 if(Value
> This
->numHandles
)
2071 FIXME("Specified handle %ld out of range\n", Value
);
2072 return DDERR_INVALIDPARAMS
;
2074 if(This
->Handles
[Value
- 1].type
!= DDrawHandle_Texture
)
2076 FIXME("Handle %ld isn't a texture handle\n", Value
);
2077 return DDERR_INVALIDPARAMS
;
2081 IDirectDrawSurfaceImpl
*surf
= (IDirectDrawSurfaceImpl
*) This
->Handles
[Value
- 1].ptr
;
2082 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
2084 (IWineD3DBaseTexture
*) surf
->wineD3DTexture
);
2088 case D3DRENDERSTATE_TEXTUREMAG
:
2090 WINED3DTEXTUREFILTERTYPE tex_mag
= WINED3DTEXF_NONE
;
2092 switch ((D3DTEXTUREFILTER
) Value
)
2094 case D3DFILTER_NEAREST
:
2095 tex_mag
= WINED3DTEXF_POINT
;
2097 case D3DFILTER_LINEAR
:
2098 tex_mag
= WINED3DTEXF_LINEAR
;
2101 ERR("Unhandled texture mag %ld !\n",Value
);
2104 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
2105 0, WINED3DSAMP_MAGFILTER
,
2109 case D3DRENDERSTATE_TEXTUREMIN
:
2111 WINED3DTEXTUREFILTERTYPE tex_min
= WINED3DTEXF_NONE
;
2113 switch ((D3DTEXTUREFILTER
) Value
)
2115 case D3DFILTER_NEAREST
:
2116 tex_min
= WINED3DTEXF_POINT
;
2118 case D3DFILTER_LINEAR
:
2119 tex_min
= WINED3DTEXF_LINEAR
;
2122 ERR("Unhandled texture mag %ld !\n",Value
);
2125 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
2126 0, WINED3DSAMP_MINFILTER
,
2130 case D3DRENDERSTATE_TEXTUREADDRESSU
:
2131 case D3DRENDERSTATE_TEXTUREADDRESSV
:
2132 case D3DRENDERSTATE_TEXTUREADDRESS
:
2134 WINED3DTEXTURESTAGESTATETYPE TexStageStateType
;
2136 if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESS
)
2138 TexStageStateType
= WINED3DTSS_ADDRESS
;
2140 else if (RenderStateType
== D3DRENDERSTATE_TEXTUREADDRESSU
)
2142 TexStageStateType
= WINED3DTSS_ADDRESSU
;
2146 TexStageStateType
= WINED3DTSS_ADDRESSV
;
2149 return IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
,
2150 0, TexStageStateType
,
2155 return IWineD3DDevice_SetRenderState(This
->wineD3DDevice
,
2161 static HRESULT WINAPI
2162 Thunk_IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3
*iface
,
2163 D3DRENDERSTATETYPE RenderStateType
,
2166 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2167 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, RenderStateType
, Value
);
2168 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2173 static HRESULT WINAPI
2174 Thunk_IDirect3DDeviceImpl_2_SetRenderState(IDirect3DDevice2
*iface
,
2175 D3DRENDERSTATETYPE RenderStateType
,
2178 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2179 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, RenderStateType
, Value
);
2180 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2185 /*****************************************************************************
2186 * Direct3DDevice3::SetLightState
2188 * Sets a light state for Direct3DDevice3 and Direct3DDevice2. The
2189 * light states are forwarded to Direct3DDevice7 render states
2194 * LightStateType: The light state to change
2195 * Value: The value to assign to that light state
2199 * DDERR_INVALIDPARAMS if the paramters were incorrect
2200 * Also check IDirect3DDevice7::SetRenderState
2202 *****************************************************************************/
2203 static HRESULT WINAPI
2204 IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3
*iface
,
2205 D3DLIGHTSTATETYPE LightStateType
,
2208 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2210 TRACE("(%p)->(%08x,%08lx)\n", This
, LightStateType
, Value
);
2212 if (!LightStateType
&& (LightStateType
> D3DLIGHTSTATE_COLORVERTEX
))
2214 TRACE("Unexpected Light State Type\n");
2215 return DDERR_INVALIDPARAMS
;
2218 if (LightStateType
== D3DLIGHTSTATE_MATERIAL
/* 1 */)
2220 IDirect3DMaterialImpl
*mat
= (IDirect3DMaterialImpl
*) Value
;
2224 TRACE(" activating material %p.\n", mat
);
2229 FIXME(" D3DLIGHTSTATE_MATERIAL called with NULL material !!!\n");
2231 This
->material
= Value
;
2233 else if (LightStateType
== D3DLIGHTSTATE_COLORMODEL
/* 3 */)
2238 ERR("DDCOLOR_MONO should not happen!\n");
2241 /* We are already in this mode */
2242 TRACE("Setting color model to RGB (no-op).\n");
2245 ERR("Unknown color model!\n");
2246 return DDERR_INVALIDPARAMS
;
2251 D3DRENDERSTATETYPE rs
;
2252 switch (LightStateType
)
2254 case D3DLIGHTSTATE_AMBIENT
: /* 2 */
2255 rs
= D3DRENDERSTATE_AMBIENT
;
2257 case D3DLIGHTSTATE_FOGMODE
: /* 4 */
2258 rs
= D3DRENDERSTATE_FOGVERTEXMODE
;
2260 case D3DLIGHTSTATE_FOGSTART
: /* 5 */
2261 rs
= D3DRENDERSTATE_FOGSTART
;
2263 case D3DLIGHTSTATE_FOGEND
: /* 6 */
2264 rs
= D3DRENDERSTATE_FOGEND
;
2266 case D3DLIGHTSTATE_FOGDENSITY
: /* 7 */
2267 rs
= D3DRENDERSTATE_FOGDENSITY
;
2269 case D3DLIGHTSTATE_COLORVERTEX
: /* 8 */
2270 rs
= D3DRENDERSTATE_COLORVERTEX
;
2273 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType
);
2274 return DDERR_INVALIDPARAMS
;
2277 return IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2285 static HRESULT WINAPI
2286 Thunk_IDirect3DDeviceImpl_2_SetLightState(IDirect3DDevice2
*iface
,
2287 D3DLIGHTSTATETYPE LightStateType
,
2290 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2291 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx) thunking to IDirect3DDevice3 interface.\n", This
, LightStateType
, Value
);
2292 return IDirect3DDevice3_SetLightState(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2297 /*****************************************************************************
2298 * IDirect3DDevice3::GetLightState
2300 * Returns the current setting of a light state. The state is read from
2301 * the Direct3DDevice7 render state.
2306 * LightStateType: The light state to return
2307 * Value: The address to store the light state setting at
2311 * DDDERR_INVALIDPARAMS if the parameters were incorrect
2312 * Also see IDirect3DDevice7::GetRenderState
2314 *****************************************************************************/
2315 static HRESULT WINAPI
2316 IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3
*iface
,
2317 D3DLIGHTSTATETYPE LightStateType
,
2320 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2322 TRACE("(%p)->(%08x,%p)\n", This
, LightStateType
, Value
);
2324 if (!LightStateType
&& (LightStateType
> D3DLIGHTSTATE_COLORVERTEX
))
2326 TRACE("Unexpected Light State Type\n");
2327 return DDERR_INVALIDPARAMS
;
2331 return DDERR_INVALIDPARAMS
;
2333 if (LightStateType
== D3DLIGHTSTATE_MATERIAL
/* 1 */)
2335 *Value
= This
->material
;
2337 else if (LightStateType
== D3DLIGHTSTATE_COLORMODEL
/* 3 */)
2339 *Value
= D3DCOLOR_RGB
;
2343 D3DRENDERSTATETYPE rs
;
2344 switch (LightStateType
)
2346 case D3DLIGHTSTATE_AMBIENT
: /* 2 */
2347 rs
= D3DRENDERSTATE_AMBIENT
;
2349 case D3DLIGHTSTATE_FOGMODE
: /* 4 */
2350 rs
= D3DRENDERSTATE_FOGVERTEXMODE
;
2352 case D3DLIGHTSTATE_FOGSTART
: /* 5 */
2353 rs
= D3DRENDERSTATE_FOGSTART
;
2355 case D3DLIGHTSTATE_FOGEND
: /* 6 */
2356 rs
= D3DRENDERSTATE_FOGEND
;
2358 case D3DLIGHTSTATE_FOGDENSITY
: /* 7 */
2359 rs
= D3DRENDERSTATE_FOGDENSITY
;
2361 case D3DLIGHTSTATE_COLORVERTEX
: /* 8 */
2362 rs
= D3DRENDERSTATE_COLORVERTEX
;
2365 ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType
);
2366 return DDERR_INVALIDPARAMS
;
2369 return IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2377 static HRESULT WINAPI
2378 Thunk_IDirect3DDeviceImpl_2_GetLightState(IDirect3DDevice2
*iface
,
2379 D3DLIGHTSTATETYPE LightStateType
,
2382 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2383 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice3 interface.\n", This
, LightStateType
, Value
);
2384 return IDirect3DDevice3_GetLightState(ICOM_INTERFACE(This
, IDirect3DDevice3
),
2389 /*****************************************************************************
2390 * IDirect3DDevice7::SetTransform
2392 * Assignes a D3DMATRIX to a transform type. The transform types are defined
2393 * in include/d3dtypes.h.
2394 * The D3DTRANSFORMSTATE_WORLD (=1) is translated to D3DTS_WORLDMATRIX(0)
2395 * (=255) for wined3d, because the 1 transform state was removed in d3d8
2396 * and WineD3D allready understands the replacement D3DTS_WORLDMATRIX(0)
2398 * Version 2, 3 and 7
2401 * TransformStateType: transform state to set
2402 * Matrix: Matrix to assign to the state
2406 * DDERR_INVALIDPARAMS if Matrix == NULL
2407 * For details see IWineD3DDevice::SetTransform
2409 *****************************************************************************/
2410 static HRESULT WINAPI
2411 IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7
*iface
,
2412 D3DTRANSFORMSTATETYPE TransformStateType
,
2415 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2416 D3DTRANSFORMSTATETYPE type
= TransformStateType
;
2417 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, Matrix
);
2420 return DDERR_INVALIDPARAMS
;
2422 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2423 * use D3DTS_WORLDMATRIX(0) instead
2424 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2426 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2427 type
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2429 return IWineD3DDevice_SetTransform(This
->wineD3DDevice
,
2434 static HRESULT WINAPI
2435 Thunk_IDirect3DDeviceImpl_3_SetTransform(IDirect3DDevice3
*iface
,
2436 D3DTRANSFORMSTATETYPE TransformStateType
,
2437 D3DMATRIX
*D3DMatrix
)
2439 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2440 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2441 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2446 static HRESULT WINAPI
2447 Thunk_IDirect3DDeviceImpl_2_SetTransform(IDirect3DDevice2
*iface
,
2448 D3DTRANSFORMSTATETYPE TransformStateType
,
2449 D3DMATRIX
*D3DMatrix
)
2451 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2452 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2453 return IDirect3DDevice7_SetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2458 /*****************************************************************************
2459 * IDirect3DDevice7::GetTransform
2461 * Returns the matrix assigned to a transform state
2462 * D3DTRANSFORMSTATE_WORLD is translated to D3DTS_WORLDMATRIX(0), see
2466 * TransformStateType: State to read the matrix from
2467 * Matrix: Address to store the matrix at
2471 * DDERR_INVALIDPARAMS if Matrix == NULL
2472 * For details, see IWineD3DDevice::GetTransform
2474 *****************************************************************************/
2475 static HRESULT WINAPI
2476 IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7
*iface
,
2477 D3DTRANSFORMSTATETYPE TransformStateType
,
2480 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2481 D3DTRANSFORMSTATETYPE type
= TransformStateType
;
2482 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, Matrix
);
2485 return DDERR_INVALIDPARAMS
;
2487 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2488 * use D3DTS_WORLDMATRIX(0) instead
2489 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2491 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2492 type
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2494 return IWineD3DDevice_GetTransform(This
->wineD3DDevice
, type
, Matrix
);
2497 static HRESULT WINAPI
2498 Thunk_IDirect3DDeviceImpl_3_GetTransform(IDirect3DDevice3
*iface
,
2499 D3DTRANSFORMSTATETYPE TransformStateType
,
2500 D3DMATRIX
*D3DMatrix
)
2502 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2503 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2504 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2509 static HRESULT WINAPI
2510 Thunk_IDirect3DDeviceImpl_2_GetTransform(IDirect3DDevice2
*iface
,
2511 D3DTRANSFORMSTATETYPE TransformStateType
,
2512 D3DMATRIX
*D3DMatrix
)
2514 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2515 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2516 return IDirect3DDevice7_GetTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2521 /*****************************************************************************
2522 * IDirect3DDevice7::MultiplyTransform
2524 * Multiplies the already-set transform matrix of a transform state
2525 * with another matrix. For the world matrix, see SetTransform
2527 * Version 2, 3 and 7
2530 * TransformStateType: Transform state to multiply
2531 * D3DMatrix Matrix to multiply with.
2535 * DDERR_INVALIDPARAMS if D3DMatrix is NULL
2536 * For details, see IWineD3DDevice::MultiplyTransform
2538 *****************************************************************************/
2539 static HRESULT WINAPI
2540 IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7
*iface
,
2541 D3DTRANSFORMSTATETYPE TransformStateType
,
2542 D3DMATRIX
*D3DMatrix
)
2544 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2545 TRACE("(%p)->(%08x,%p): Relay\n", This
, TransformStateType
, D3DMatrix
);
2547 /* D3DTRANSFORMSTATE_WORLD doesn't exist in WineD3D,
2548 * use D3DTS_WORLDMATRIX(0) instead
2549 * D3DTS_WORLDMATRIX(index) is (D3DTRANSFORMSTATETYPE)(index + 256)
2551 if(TransformStateType
== D3DTRANSFORMSTATE_WORLD
)
2552 TransformStateType
= (D3DTRANSFORMSTATETYPE
)(0 + 256);
2554 return IWineD3DDevice_MultiplyTransform(This
->wineD3DDevice
,
2559 static HRESULT WINAPI
2560 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(IDirect3DDevice3
*iface
,
2561 D3DTRANSFORMSTATETYPE TransformStateType
,
2562 D3DMATRIX
*D3DMatrix
)
2564 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2565 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2566 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2571 static HRESULT WINAPI
2572 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform(IDirect3DDevice2
*iface
,
2573 D3DTRANSFORMSTATETYPE TransformStateType
,
2574 D3DMATRIX
*D3DMatrix
)
2576 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2577 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, TransformStateType
, D3DMatrix
);
2578 return IDirect3DDevice7_MultiplyTransform(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2583 /*****************************************************************************
2584 * IDirect3DDevice7::DrawPrimitive
2586 * Draws primitves based on vertices in an application-provided pointer
2588 * Version 2, 3 and 7. The IDirect3DDevice2 thunk converts the fixed vertex type into
2589 * an FVF format for D3D7
2592 * PrimitiveType: The type of the primitives to draw
2593 * Vertex type: Flexible vertex format vertex description
2594 * Vertices: Pointer to the vertex array
2595 * VertexCount: The number of vertices to draw
2596 * Flags: As usual a few flags
2600 * DDERR_INVALIDPARAMS if Vertices is NULL
2601 * For details, see IWineD3DDevice::DrawPrimitiveUP
2603 *****************************************************************************/
2604 static HRESULT WINAPI
2605 IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7
*iface
,
2606 D3DPRIMITIVETYPE PrimitiveType
,
2612 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2613 UINT PrimitiveCount
, stride
;
2615 TRACE("(%p)->(%08x,%08lx,%p,%08lx,%08lx): Relay!\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2618 return DDERR_INVALIDPARAMS
;
2620 /* Get the vertex count */
2621 switch(PrimitiveType
)
2623 case D3DPT_POINTLIST
:
2624 PrimitiveCount
= VertexCount
;
2627 case D3DPT_LINELIST
:
2628 PrimitiveCount
= VertexCount
/ 2;
2631 case D3DPT_LINESTRIP
:
2632 PrimitiveCount
= VertexCount
- 1;
2635 case D3DPT_TRIANGLELIST
:
2636 PrimitiveCount
= VertexCount
/ 3;
2639 case D3DPT_TRIANGLESTRIP
:
2640 PrimitiveCount
= VertexCount
- 2;
2643 case D3DPT_TRIANGLEFAN
:
2644 PrimitiveCount
= VertexCount
- 2;
2647 default: return DDERR_INVALIDPARAMS
;
2650 /* Get the stride */
2651 stride
= get_flexible_vertex_size(VertexType
);
2654 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, VertexType
);
2655 if(hr
!= D3D_OK
) return hr
;
2657 /* This method translates to the user pointer draw of WineD3D */
2658 return IWineD3DDevice_DrawPrimitiveUP(This
->wineD3DDevice
,
2665 static HRESULT WINAPI
2666 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(IDirect3DDevice3
*iface
,
2667 D3DPRIMITIVETYPE PrimitiveType
,
2673 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2674 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2675 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2683 static HRESULT WINAPI
2684 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive(IDirect3DDevice2
*iface
,
2685 D3DPRIMITIVETYPE PrimitiveType
,
2686 D3DVERTEXTYPE VertexType
,
2691 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2693 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Flags
);
2697 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
2698 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
2699 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
2701 assert(0); /* Should never happen */
2704 return IDirect3DDevice7_DrawPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2712 /*****************************************************************************
2713 * IDirect3DDevice7::DrawIndexedPrimitive
2715 * Draws vertices from an application-provided pointer, based on the index
2716 * numbers in a WORD array.
2718 * Version 2, 3 and 7. The version 7 thunk translates the vertex type into
2719 * an FVF format for D3D7
2722 * PrimitiveType: The primitive type to draw
2723 * VertexType: The FVF vertex description
2724 * Vertices: Pointer to the vertex array
2726 * Indices: Pointer to the index array
2727 * IndexCount: Number of indices = Number of vertices to draw
2728 * Flags: As usual, some flags
2732 * DDERR_INVALIDPARAMS if Vertices or Indices is NULL
2733 * For details, see IWineD3DDevice::DrawIndexedPrimitiveUP
2735 *****************************************************************************/
2736 static HRESULT WINAPI
2737 IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7
*iface
,
2738 D3DPRIMITIVETYPE PrimitiveType
,
2746 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2747 UINT PrimitiveCount
= 0;
2749 TRACE("(%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx): Relay!\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
2750 /* Get the primitive number */
2751 switch(PrimitiveType
)
2753 case D3DPT_POINTLIST
:
2754 PrimitiveCount
= IndexCount
;
2757 case D3DPT_LINELIST
:
2758 PrimitiveCount
= IndexCount
/ 2;
2761 case D3DPT_LINESTRIP
:
2762 PrimitiveCount
= IndexCount
- 1;
2765 case D3DPT_TRIANGLELIST
:
2766 PrimitiveCount
= IndexCount
/ 3;
2769 case D3DPT_TRIANGLESTRIP
:
2770 PrimitiveCount
= IndexCount
- 2;
2773 case D3DPT_TRIANGLEFAN
:
2774 PrimitiveCount
= IndexCount
- 2;
2777 default: return DDERR_INVALIDPARAMS
;
2780 /* Set the D3DDevice's FVF */
2781 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, VertexType
);
2784 ERR(" (%p) Setting the FVF failed, hr = %lx!\n", This
, hr
);
2788 return IWineD3DDevice_DrawIndexedPrimitiveUP(This
->wineD3DDevice
,
2790 0 /* MinVertexIndex */,
2791 VertexCount
/* UINT NumVertexIndex */,
2796 get_flexible_vertex_size(VertexType
));
2799 static HRESULT WINAPI
2800 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(IDirect3DDevice3
*iface
,
2801 D3DPRIMITIVETYPE PrimitiveType
,
2809 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2810 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
2811 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2821 static HRESULT WINAPI
2822 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(IDirect3DDevice2
*iface
,
2823 D3DPRIMITIVETYPE PrimitiveType
,
2824 D3DVERTEXTYPE VertexType
,
2832 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2833 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08x,%p,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, Vertices
, VertexCount
, Indices
, IndexCount
, Flags
);
2837 case D3DVT_VERTEX
: FVF
= D3DFVF_VERTEX
; break;
2838 case D3DVT_LVERTEX
: FVF
= D3DFVF_LVERTEX
; break;
2839 case D3DVT_TLVERTEX
: FVF
= D3DFVF_TLVERTEX
; break;
2841 assert(0); /* Should never happen */
2844 return IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2854 /*****************************************************************************
2855 * IDirect3DDevice7::SetClipStatus
2857 * Sets the clip status. This defines things as clipping conditions and
2858 * the extents of the clipping region.
2860 * Version 2, 3 and 7
2866 * D3D_OK because it's a stub
2867 * (DDERR_INVALIDPARAMS if ClipStatus == NULL)
2869 *****************************************************************************/
2870 static HRESULT WINAPI
2871 IDirect3DDeviceImpl_7_SetClipStatus(IDirect3DDevice7
*iface
,
2872 D3DCLIPSTATUS
*ClipStatus
)
2874 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2875 FIXME("(%p)->(%p): Stub!\n", This
, ClipStatus
);
2877 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them
2878 * Perhaps this needs a new data type and an additional IWineD3DDevice method
2880 /* return IWineD3DDevice_SetClipStatus(This->wineD3DDevice, ClipStatus);*/
2884 static HRESULT WINAPI
2885 Thunk_IDirect3DDeviceImpl_3_SetClipStatus(IDirect3DDevice3
*iface
,
2886 D3DCLIPSTATUS
*ClipStatus
)
2888 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2889 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
2890 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2894 static HRESULT WINAPI
2895 Thunk_IDirect3DDeviceImpl_2_SetClipStatus(IDirect3DDevice2
*iface
,
2896 D3DCLIPSTATUS
*ClipStatus
)
2898 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2899 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
2900 return IDirect3DDevice7_SetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2904 /*****************************************************************************
2905 * IDirect3DDevice7::GetClipStatus
2907 * Returns the clip status
2910 * ClipStatus: Address to write the clip status to
2913 * D3D_OK because it's a stub
2915 *****************************************************************************/
2916 static HRESULT WINAPI
2917 IDirect3DDeviceImpl_7_GetClipStatus(IDirect3DDevice7
*iface
,
2918 D3DCLIPSTATUS
*ClipStatus
)
2920 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2921 FIXME("(%p)->(%p): Stub!\n", This
, ClipStatus
);
2923 /* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them */
2924 /* return IWineD3DDevice_GetClipStatus(This->wineD3DDevice, ClipStatus);*/
2928 static HRESULT WINAPI
2929 Thunk_IDirect3DDeviceImpl_3_GetClipStatus(IDirect3DDevice3
*iface
,
2930 D3DCLIPSTATUS
*ClipStatus
)
2932 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
2933 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
2934 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2938 static HRESULT WINAPI
2939 Thunk_IDirect3DDeviceImpl_2_GetClipStatus(IDirect3DDevice2
*iface
,
2940 D3DCLIPSTATUS
*ClipStatus
)
2942 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice2
, iface
);
2943 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, ClipStatus
);
2944 return IDirect3DDevice7_GetClipStatus(ICOM_INTERFACE(This
, IDirect3DDevice7
),
2948 /*****************************************************************************
2949 * IDirect3DDevice::DrawPrimitiveStrided
2951 * Draws vertices described by a D3DDRAWPRIMITIVESTRIDEDDATA structure.
2956 * PrimitiveType: The primitive type to draw
2957 * VertexType: The FVF description of the vertices to draw(for the stride??)
2958 * D3DDrawPrimStrideData: A D3DDRAWPRIMITIVESTRIDEDDATA structure describing
2959 * the vertex data locations
2960 * VertexCount: The number of vertices to draw
2964 * D3D_OK, because it's a stub
2965 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
2966 * (For details, see IWineD3DDevice::DrawPrimitiveStrided)
2968 *****************************************************************************/
2969 static HRESULT WINAPI
2970 IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7
*iface
,
2971 D3DPRIMITIVETYPE PrimitiveType
,
2973 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
2977 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
2978 WineDirect3DVertexStridedData WineD3DStrided
;
2980 UINT PrimitiveCount
;
2982 TRACE("(%p)->(%08x,%08lx,%p,%08lx,%08lx): stub!\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Flags
);
2984 /* Get the strided data right. the wined3d structure is a bit bigger
2985 * Watch out: The contents of the strided data are determined by the fvf,
2986 * not by the members set in D3DDrawPrimStrideData. So it's valid
2987 * to have diffuse.lpvData set to 0xdeadbeef and not setting the diffuse
2990 if(VertexType
& D3DFVF_POSITION_MASK
)
2992 memset(&WineD3DStrided
, 0, sizeof(WineD3DStrided
));
2993 WineD3DStrided
.u
.s
.position
.lpData
= D3DDrawPrimStrideData
->position
.lpvData
;
2994 WineD3DStrided
.u
.s
.position
.dwStride
= D3DDrawPrimStrideData
->position
.dwStride
;
2995 WineD3DStrided
.u
.s
.position
.dwType
= WINED3DDECLTYPE_FLOAT3
;
2996 if (VertexType
& D3DFVF_XYZRHW
)
2998 WineD3DStrided
.u
.s
.position
.dwType
= WINED3DDECLTYPE_FLOAT4
;
3002 if(VertexType
& D3DFVF_NORMAL
)
3004 WineD3DStrided
.u
.s
.normal
.lpData
= D3DDrawPrimStrideData
->normal
.lpvData
;
3005 WineD3DStrided
.u
.s
.normal
.dwStride
= D3DDrawPrimStrideData
->normal
.dwStride
;
3006 WineD3DStrided
.u
.s
.normal
.dwType
= WINED3DDECLTYPE_FLOAT3
;
3009 if(VertexType
& D3DFVF_DIFFUSE
)
3011 WineD3DStrided
.u
.s
.diffuse
.lpData
= D3DDrawPrimStrideData
->diffuse
.lpvData
;
3012 WineD3DStrided
.u
.s
.diffuse
.dwStride
= D3DDrawPrimStrideData
->diffuse
.dwStride
;
3013 WineD3DStrided
.u
.s
.diffuse
.dwType
= WINED3DDECLTYPE_SHORT4
;
3016 if(VertexType
& D3DFVF_SPECULAR
)
3018 WineD3DStrided
.u
.s
.specular
.lpData
= D3DDrawPrimStrideData
->specular
.lpvData
;
3019 WineD3DStrided
.u
.s
.specular
.dwStride
= D3DDrawPrimStrideData
->specular
.dwStride
;
3020 WineD3DStrided
.u
.s
.specular
.dwType
= WINED3DDECLTYPE_SHORT4
;
3023 for( i
= 0; i
< GET_TEXCOUNT_FROM_FVF(VertexType
); i
++)
3025 WineD3DStrided
.u
.s
.texCoords
[i
].lpData
= D3DDrawPrimStrideData
->textureCoords
[i
].lpvData
;
3026 WineD3DStrided
.u
.s
.texCoords
[i
].dwStride
= D3DDrawPrimStrideData
->textureCoords
[i
].dwStride
;
3027 switch(GET_TEXCOORD_SIZE_FROM_FVF(VertexType
, i
))
3029 case 1: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT1
; break;
3030 case 2: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT2
; break;
3031 case 3: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT3
; break;
3032 case 4: WineD3DStrided
.u
.s
.texCoords
[i
].dwType
= WINED3DDECLTYPE_FLOAT4
; break;
3033 default: ERR("Unexpected texture coordinate size %ld\n",
3034 GET_TEXCOORD_SIZE_FROM_FVF(VertexType
, i
));
3038 /* Get the primitive count */
3039 switch(PrimitiveType
)
3041 case D3DPT_POINTLIST
:
3042 PrimitiveCount
= VertexCount
;
3045 case D3DPT_LINELIST
:
3046 PrimitiveCount
= VertexCount
/ 2;
3049 case D3DPT_LINESTRIP
:
3050 PrimitiveCount
= VertexCount
- 1;
3053 case D3DPT_TRIANGLELIST
:
3054 PrimitiveCount
= VertexCount
/ 3;
3057 case D3DPT_TRIANGLESTRIP
:
3058 PrimitiveCount
= VertexCount
- 2;
3061 case D3DPT_TRIANGLEFAN
:
3062 PrimitiveCount
= VertexCount
- 2;
3065 default: return DDERR_INVALIDPARAMS
;
3068 IWineD3DDevice_SetFVF(This
->wineD3DDevice
,
3071 return IWineD3DDevice_DrawPrimitiveStrided(This
->wineD3DDevice
,
3077 static HRESULT WINAPI
3078 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided(IDirect3DDevice3
*iface
,
3079 D3DPRIMITIVETYPE PrimitiveType
,
3081 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3085 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3086 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Flags
);
3087 return IDirect3DDevice7_DrawPrimitiveStrided(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3090 D3DDrawPrimStrideData
,
3095 /*****************************************************************************
3096 * IDirect3DDevice7::DrawIndexedPrimitiveStrided
3098 * Draws primitives specified by strided data locations based on indices
3106 * D3D_OK, because it's a stub
3107 * (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
3108 * (DDERR_INVALIDPARAMS if Indices is NULL)
3109 * (For more details, see IWineD3DDevice::DrawIndexedPrimitiveStrided)
3111 *****************************************************************************/
3112 static HRESULT WINAPI
3113 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7
*iface
,
3114 D3DPRIMITIVETYPE PrimitiveType
,
3116 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3122 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3123 FIXME("(%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx): stub!\n", This
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Indices
, IndexCount
, Flags
);
3125 /* I'll implement it as soon as I find a app to test it.
3126 * This needs an additional method in IWineD3DDevice.
3131 static HRESULT WINAPI
3132 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(IDirect3DDevice3
*iface
,
3133 D3DPRIMITIVETYPE PrimitiveType
,
3135 D3DDRAWPRIMITIVESTRIDEDDATA
*D3DDrawPrimStrideData
,
3141 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3142 TRACE_(ddraw_thunk
)("(%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", iface
, PrimitiveType
, VertexType
, D3DDrawPrimStrideData
, VertexCount
, Indices
, IndexCount
, Flags
);
3143 return IDirect3DDevice7_DrawIndexedPrimitiveStrided(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3146 D3DDrawPrimStrideData
,
3153 /*****************************************************************************
3154 * IDirect3DDevice7::DrawPrimitiveVB
3156 * Draws primitives from a vertex buffer to the screen.
3161 * PrimitiveType: Type of primitive to be rendered.
3162 * D3DVertexBuf: Source Vertex Buffer
3163 * StartVertex: Index of the first vertex from the buffer to be rendered
3164 * NumVertices: Number of vertices to be rendered
3165 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3169 * DDERR_INVALIDPARAMS if D3DVertexBuf is NULL
3171 *****************************************************************************/
3172 static HRESULT WINAPI
3173 IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7
*iface
,
3174 D3DPRIMITIVETYPE PrimitiveType
,
3175 IDirect3DVertexBuffer7
*D3DVertexBuf
,
3180 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3181 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer7
, D3DVertexBuf
);
3182 UINT PrimitiveCount
;
3185 WINED3DVERTEXBUFFER_DESC Desc
;
3187 TRACE("(%p)->(%08x,%p,%08lx,%08lx,%08lx)\n", This
, PrimitiveType
, D3DVertexBuf
, StartVertex
, NumVertices
, Flags
);
3192 ERR("(%p) No Vertex buffer specified\n", This
);
3193 return DDERR_INVALIDPARAMS
;
3196 /* Get the primitive count */
3197 switch(PrimitiveType
)
3199 case D3DPT_POINTLIST
:
3200 PrimitiveCount
= NumVertices
;
3203 case D3DPT_LINELIST
:
3204 PrimitiveCount
= NumVertices
/ 2;
3207 case D3DPT_LINESTRIP
:
3208 PrimitiveCount
= NumVertices
- 1;
3211 case D3DPT_TRIANGLELIST
:
3212 PrimitiveCount
= NumVertices
/ 3;
3215 case D3DPT_TRIANGLESTRIP
:
3216 PrimitiveCount
= NumVertices
- 2;
3219 case D3DPT_TRIANGLEFAN
:
3220 PrimitiveCount
= NumVertices
- 2;
3223 default: return DDERR_INVALIDPARAMS
;
3226 /* Get the FVF of the vertex buffer, and its stride */
3227 hr
= IWineD3DVertexBuffer_GetDesc(vb
->wineD3DVertexBuffer
,
3231 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08lx\n", This
, hr
);
3234 stride
= get_flexible_vertex_size(Desc
.FVF
);
3236 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, Desc
.FVF
);
3239 ERR(" (%p) Setting the FVF failed, hr = %lx!\n", This
, hr
);
3243 /* Set the vertex stream souce */
3244 hr
= IWineD3DDevice_SetStreamSource(This
->wineD3DDevice
,
3245 0 /* StreamNumber */,
3246 vb
->wineD3DVertexBuffer
,
3247 0 /* StartVertex - we pass this to DrawPrimitive */,
3251 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08lx\n", This
, hr
);
3255 /* Now draw the primitives */
3256 return IWineD3DDevice_DrawPrimitive(This
->wineD3DDevice
,
3262 static HRESULT WINAPI
3263 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3
*iface
,
3264 D3DPRIMITIVETYPE PrimitiveType
,
3265 IDirect3DVertexBuffer
*D3DVertexBuf
,
3270 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3271 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer
, D3DVertexBuf
);
3272 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p,%08lx,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, vb
, StartVertex
, NumVertices
, Flags
);
3273 return IDirect3DDevice7_DrawPrimitiveVB(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3275 ICOM_INTERFACE(vb
, IDirect3DVertexBuffer7
),
3282 /*****************************************************************************
3283 * IDirect3DDevice7::DrawIndexedPrimitiveVB
3285 * Draws primitives from a vertex buffer to the screen
3288 * PrimitiveType: Type of primitive to be rendered.
3289 * D3DVertexBuf: Source Vertex Buffer
3290 * StartVertex: Index of the first vertex from the buffer to be rendered
3291 * NumVertices: Number of vertices to be rendered
3292 * Indices: Array of DWORDs used to index into the Vertices
3293 * IndexCount: Number of indices in Indices
3294 * Flags: Can be D3DDP_WAIT to wait until rendering has finished
3298 *****************************************************************************/
3299 static HRESULT WINAPI
3300 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7
*iface
,
3301 D3DPRIMITIVETYPE PrimitiveType
,
3302 IDirect3DVertexBuffer7
*D3DVertexBuf
,
3309 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3310 IDirect3DVertexBufferImpl
*vb
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer7
, D3DVertexBuf
);
3312 UINT PrimitiveCount
;
3313 WORD
*LockedIndices
;
3315 WINED3DVERTEXBUFFER_DESC Desc
;
3317 TRACE("(%p)->(%08x,%p,%ld,%ld,%p,%ld,%08lx)\n", This
, PrimitiveType
, vb
, StartVertex
, NumVertices
, Indices
, IndexCount
, Flags
);
3320 * 1) Calculate some things: Vertex count -> Primitive count, stride, ...
3321 * 2) Upload the Indices to the index buffer
3322 * 3) Set the index source
3323 * 4) Set the Vertex Buffer as the Stream source
3324 * 5) Call IWineD3DDevice::DrawIndexedPrimitive
3327 /* Get the primitive count */
3328 switch(PrimitiveType
)
3330 case D3DPT_POINTLIST
:
3331 PrimitiveCount
= IndexCount
;
3334 case D3DPT_LINELIST
:
3335 PrimitiveCount
= IndexCount
/ 2;
3338 case D3DPT_LINESTRIP
:
3339 PrimitiveCount
= IndexCount
- 1;
3342 case D3DPT_TRIANGLELIST
:
3343 PrimitiveCount
= IndexCount
/ 3;
3346 case D3DPT_TRIANGLESTRIP
:
3347 PrimitiveCount
= IndexCount
- 2;
3350 case D3DPT_TRIANGLEFAN
:
3351 PrimitiveCount
= IndexCount
- 2;
3354 default: return DDERR_INVALIDPARAMS
;
3357 /* Get the FVF of the vertex buffer, and its stride */
3358 hr
= IWineD3DVertexBuffer_GetDesc(vb
->wineD3DVertexBuffer
,
3362 ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08lx\n", This
, hr
);
3365 stride
= get_flexible_vertex_size(Desc
.FVF
);
3366 TRACE("Vertex buffer FVF = %08lx, stride=%ld\n", Desc
.FVF
, stride
);
3368 hr
= IWineD3DDevice_SetFVF(This
->wineD3DDevice
, Desc
.FVF
);
3371 ERR(" (%p) Setting the FVF failed, hr = %lx!\n", This
, hr
);
3375 /* copy the index stream into the index buffer.
3376 * A new IWineD3DDevice method could be created
3377 * which takes an user pointer containing the indices
3378 * or a SetData-Method for the index buffer, which
3379 * overrides the index buffer data with our pointer.
3381 hr
= IWineD3DIndexBuffer_Lock(This
->indexbuffer
,
3382 0 /* OffSetToLock */,
3383 0 /* SizeToLock - doesn't matter */,
3384 (BYTE
**) &LockedIndices
,
3386 assert(IndexCount
< 0x100000);
3389 ERR("(%p) IWineD3DIndexBuffer::Lock failed with hr = %08lx\n", This
, hr
);
3392 memcpy(LockedIndices
, Indices
, IndexCount
* sizeof(WORD
));
3393 hr
= IWineD3DIndexBuffer_Unlock(This
->indexbuffer
);
3396 ERR("(%p) IWineD3DIndexBuffer::Unlock failed with hr = %08lx\n", This
, hr
);
3400 /* Set the index stream */
3401 hr
= IWineD3DDevice_SetIndices(This
->wineD3DDevice
,
3405 /* Set the vertex stream souce */
3406 hr
= IWineD3DDevice_SetStreamSource(This
->wineD3DDevice
,
3407 0 /* StreamNumber */,
3408 vb
->wineD3DVertexBuffer
,
3409 0 /* offset, we pass this to DrawIndexedPrimitive */,
3413 ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08lx\n", This
, hr
);
3418 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->wineD3DDevice
,
3429 static HRESULT WINAPI
3430 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevice3
*iface
,
3431 D3DPRIMITIVETYPE PrimitiveType
,
3432 IDirect3DVertexBuffer
*D3DVertexBuf
,
3437 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3438 IDirect3DVertexBufferImpl
*VB
= ICOM_OBJECT(IDirect3DVertexBufferImpl
, IDirect3DVertexBuffer
, D3DVertexBuf
);
3439 TRACE_(ddraw_thunk
)("(%p)->(%08x,%p,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, PrimitiveType
, VB
, Indices
, IndexCount
, Flags
);
3441 return IDirect3DDevice7_DrawIndexedPrimitiveVB(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3443 ICOM_INTERFACE(VB
, IDirect3DVertexBuffer7
),
3451 /*****************************************************************************
3452 * IDirect3DDevice7::ComputeSphereVisibility
3454 * Calculates the visibility of spheres in the current viewport. The spheres
3455 * are passed in the Centers and Radii arrays, the results are passed back
3456 * in the ReturnValues array. Return values are eighter completely visible,
3457 * partially visible or completely invisible.
3458 * The return value consist of a combination of D3DCLIP_* flags, or it's
3459 * 0 if the sphere is completely visible(according to the SDK, not checked)
3461 * Sounds like an overdose math ;)
3466 * Centers: Array containing the sphere centers
3467 * Radii: Array containing the sphere radis
3468 * NumSpheres: The number of centers and radiis in the arrays
3470 * ReturnValues: Array to write the results to
3473 * D3D_OK because it's a stub
3474 * (DDERR_INVALIDPARAMS if Centers, Radii or ReturnValues are NULL)
3475 * (D3DERR_INVALIDMATRIX if the combined world, view and proj matrix
3478 *****************************************************************************/
3479 static HRESULT WINAPI
3480 IDirect3DDeviceImpl_7_ComputeSphereVisibility(IDirect3DDevice7
*iface
,
3485 DWORD
*ReturnValues
)
3487 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3488 FIXME("(%p)->(%p,%p,%08lx,%08lx,%p): stub!\n", This
, Centers
, Radii
, NumSpheres
, Flags
, ReturnValues
);
3490 /* the DirectX 7 sdk says that the visibility is computed by
3491 * back-transforming the viewing frustum to model space
3492 * using the inverse of the combined world, view and projection
3493 * matrix. If the matrix can't be reversed, D3DERR_INVALIDMATRIX
3496 * Basic implementation idea:
3497 * 1) Check if the center is in the viewing frustum
3498 * 2) Cut the sphere with the planes of the viewing
3501 * ->Center inside the frustum, no intersections:
3503 * ->Center outside the frustum, no intersections:
3505 * ->Some intersections: Partially visible
3507 * Implement this call in WineD3D. Eighter implement the
3508 * matrix and vector stuff in WineD3D, or use some external
3515 static HRESULT WINAPI
3516 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility(IDirect3DDevice3
*iface
,
3521 DWORD
*ReturnValues
)
3523 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3524 TRACE_(ddraw_thunk
)("(%p)->(%p,%p,%08lx,%08lx,%p) thunking to IDirect3DDevice7 interface.\n", This
, Centers
, Radii
, NumSpheres
, Flags
, ReturnValues
);
3525 return IDirect3DDevice7_ComputeSphereVisibility(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3533 /*****************************************************************************
3534 * IDirect3DDevice7::GetTexture
3536 * Returns the texture interface handle assigned to a texture stage.
3537 * The returned texture is AddRefed. This is taken from old ddraw,
3538 * not checked in Windows.
3543 * Stage: Texture stage to read the texture from
3544 * Texture: Address to store the interface pointer at
3548 * DDERR_INVALIDPARAMS if Texture is NULL
3549 * For details, see IWineD3DDevice::GetTexture
3551 *****************************************************************************/
3552 static HRESULT WINAPI
3553 IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7
*iface
,
3555 IDirectDrawSurface7
**Texture
)
3557 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3558 IWineD3DBaseTexture
*Surf
;
3560 TRACE("(%p)->(%ld,%p): Relay\n", This
, Stage
, Texture
);
3564 TRACE("Texture == NULL, failing with DDERR_INVALIDPARAMS\n");
3565 return DDERR_INVALIDPARAMS
;
3568 hr
= IWineD3DDevice_GetTexture(This
->wineD3DDevice
, Stage
, (IWineD3DBaseTexture
**) &Surf
);
3569 if( (hr
!= D3D_OK
) || (!Surf
) )
3575 /* GetParent AddRef()s, which is perfectly OK.
3576 * We have passed the IDirectDrawSurface7 interface to WineD3D, so that's OK too.
3578 return IWineD3DBaseTexture_GetParent(Surf
,
3579 (IUnknown
**) Texture
);
3582 static HRESULT WINAPI
3583 Thunk_IDirect3DDeviceImpl_3_GetTexture(IDirect3DDevice3
*iface
,
3585 IDirect3DTexture2
**Texture2
)
3587 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3589 IDirectDrawSurface7
*ret_val
;
3591 TRACE_(ddraw_thunk
)("(%p)->(%ld,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, Texture2
);
3592 ret
= IDirect3DDevice7_GetTexture(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3596 *Texture2
= COM_INTERFACE_CAST(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, IDirect3DTexture2
, ret_val
);
3598 TRACE_(ddraw_thunk
)(" returning interface %p.\n", *Texture2
);
3603 /*****************************************************************************
3604 * IDirect3DDevice7::SetTexture
3606 * Assignes a texture to a texture stage. Is the texture AddRefed?
3611 * Stage: The stage to assign the texture to
3612 * Texture: Interface pointer to the texture surface
3616 * For details, see IWineD3DDevice::SetTexture
3618 *****************************************************************************/
3619 static HRESULT WINAPI
3620 IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7
*iface
,
3622 IDirectDrawSurface7
*Texture
)
3624 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3625 IDirectDrawSurfaceImpl
*surf
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, Texture
);
3626 TRACE("(%p)->(%08lx,%p): Relay!\n", This
, Stage
, surf
);
3628 /* Texture may be NULL here */
3629 return IWineD3DDevice_SetTexture(This
->wineD3DDevice
,
3631 surf
? (IWineD3DBaseTexture
* ) surf
->wineD3DTexture
: NULL
);
3634 static HRESULT WINAPI
3635 Thunk_IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3
*iface
,
3637 IDirect3DTexture2
*Texture2
)
3639 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3640 IDirectDrawSurfaceImpl
*tex
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirect3DTexture2
, Texture2
);
3641 TRACE_(ddraw_thunk
)("(%p)->(%ld,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, tex
);
3642 return IDirect3DDevice7_SetTexture(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3644 ICOM_INTERFACE(tex
, IDirectDrawSurface7
));
3647 /*****************************************************************************
3648 * IDirect3DDevice7::GetTextureStageState
3650 * Retrieves a state from a texture stage.
3655 * Stage: The stage to retrieve the state from
3656 * TexStageStateType: The state type to retrieve
3657 * State: Address to store the state's value at
3661 * DDERR_INVALIDPARAMS if State is NULL
3662 * For details, see IWineD3DDevice::GetTextureStageState
3664 *****************************************************************************/
3665 static HRESULT WINAPI
3666 IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7
*iface
,
3668 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3671 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3672 TRACE("(%p)->(%08lx,%08x,%p): Relay!\n", This
, Stage
, TexStageStateType
, State
);
3675 return DDERR_INVALIDPARAMS
;
3677 return IWineD3DDevice_GetTextureStageState(This
->wineD3DDevice
,
3683 static HRESULT WINAPI
3684 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState(IDirect3DDevice3
*iface
,
3686 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3689 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3690 TRACE_(ddraw_thunk
)("(%p)->(%08lx,%08x,%p) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, TexStageStateType
, State
);
3691 return IDirect3DDevice7_GetTextureStageState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3697 /*****************************************************************************
3698 * IDirect3DDevice7::SetTextureStageState
3700 * Sets a texture stage state. Some stage types need to be handled specially,
3701 * because they do not exist in WineD3D and were moved to another place
3706 * Stage: The stage to modify
3707 * TexStageStateType: The state to change
3708 * State: The new value for the state
3712 * For details, see IWineD3DDevice::SetTextureStageState
3714 *****************************************************************************/
3715 static HRESULT WINAPI
3716 IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7
*iface
,
3718 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3721 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3722 TRACE("(%p)->(%08lx,%08x,%08lx): Relay!\n", This
, Stage
, TexStageStateType
, State
);
3723 switch(TexStageStateType
)
3725 /* Mipfilter is a sampler state with different values */
3726 case D3DTSS_MIPFILTER
:
3728 WINED3DTEXTUREFILTERTYPE value
;
3731 case D3DTFP_NONE
: value
= WINED3DTEXF_NONE
; break;
3732 case D3DTFP_POINT
: value
= WINED3DTEXF_POINT
; break;
3733 case 0: /* Unchecked */
3734 case D3DTFP_LINEAR
: value
= WINED3DTEXF_LINEAR
; break;
3736 ERR("Unexpected mipfilter value %ld\n", State
);
3737 value
= WINED3DTEXF_NONE
;
3739 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
3741 WINED3DSAMP_MIPFILTER
,
3745 /* Minfilter is a sampler state too, equal values */
3746 case D3DTSS_MINFILTER
:
3747 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
3749 WINED3DSAMP_MINFILTER
,
3751 /* Same for MAGFILTER */
3752 case D3DTSS_MAGFILTER
:
3753 return IWineD3DDevice_SetSamplerState(This
->wineD3DDevice
,
3755 WINED3DSAMP_MAGFILTER
,
3760 return IWineD3DDevice_SetTextureStageState(This
->wineD3DDevice
,
3767 static HRESULT WINAPI
3768 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState(IDirect3DDevice3
*iface
,
3770 D3DTEXTURESTAGESTATETYPE TexStageStateType
,
3773 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3774 TRACE_(ddraw_thunk
)("(%p)->(%08lx,%08x,%08lx) thunking to IDirect3DDevice7 interface.\n", This
, Stage
, TexStageStateType
, State
);
3775 return IDirect3DDevice7_SetTextureStageState(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3781 /*****************************************************************************
3782 * IDirect3DDevice7::ValidateDevice
3784 * SDK: "Reports the device's ability to render the currently set
3785 * texture-blending operations in a single pass". Whatever that means
3791 * NumPasses: Address to write the number of neccessary passes for the
3792 * desired effect to.
3796 * See IWineD3DDevice::ValidateDevice for more details
3798 *****************************************************************************/
3799 static HRESULT WINAPI
3800 IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7
*iface
,
3803 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3804 TRACE("(%p)->(%p): Relay\n", This
, NumPasses
);
3806 return IWineD3DDevice_ValidateDevice(This
->wineD3DDevice
, NumPasses
);
3809 static HRESULT WINAPI
3810 Thunk_IDirect3DDeviceImpl_3_ValidateDevice(IDirect3DDevice3
*iface
,
3813 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice3
, iface
);
3814 TRACE_(ddraw_thunk
)("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", This
, Passes
);
3815 return IDirect3DDevice7_ValidateDevice(ICOM_INTERFACE(This
, IDirect3DDevice7
),
3819 /*****************************************************************************
3820 * IDirect3DDevice7::Clear
3822 * Fills the render target, the z buffer and the stencil buffer with a
3823 * clear color / value
3828 * Count: Number of rectangles in Rects must be 0 if Rects is NULL
3829 * Rects: Rectangles to clear. If NULL, the whole surface is cleared
3830 * Flags: Some flags, as usual
3831 * Color: Clear color for the render target
3832 * Z: Clear value for the Z buffer
3833 * Stencil: Clear value to store in each stencil buffer entry
3837 * For details, see IWineD3DDevice::Clear
3839 *****************************************************************************/
3840 static HRESULT WINAPI
3841 IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7
*iface
,
3849 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3850 TRACE("(%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx): Relay\n", This
, Count
, Rects
, Flags
, (DWORD
) Color
, Z
, Stencil
);
3852 return IWineD3DDevice_Clear(This
->wineD3DDevice
, Count
, Rects
, Flags
, Color
, Z
, Stencil
);
3855 /*****************************************************************************
3856 * IDirect3DDevice7::SetViewport
3858 * Sets the current viewport.
3860 * Version 7 only, but IDirect3DViewport uses this call for older
3864 * Data: The new viewport to set
3868 * DDERR_INVALIDPARAMS if Data is NULL
3869 * For more details, see IWineDDDevice::SetViewport
3871 *****************************************************************************/
3872 static HRESULT WINAPI
3873 IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7
*iface
,
3876 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3877 TRACE("(%p)->(%p) Relay!\n", This
, Data
);
3880 return DDERR_INVALIDPARAMS
;
3882 return IWineD3DDevice_SetViewport(This
->wineD3DDevice
,
3886 /*****************************************************************************
3887 * IDirect3DDevice::GetViewport
3889 * Returns the current viewport
3894 * Data: D3D7Viewport structure to write the viewport information to
3898 * DDERR_INVALIDPARAMS if Data is NULL
3899 * For more details, see IWineD3DDevice::GetViewport
3901 *****************************************************************************/
3902 static HRESULT WINAPI
3903 IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7
*iface
,
3906 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3908 TRACE("(%p)->(%p) Relay!\n", This
, Data
);
3911 return DDERR_INVALIDPARAMS
;
3913 hr
= IWineD3DDevice_GetViewport(This
->wineD3DDevice
,
3915 return hr_ddraw_from_wined3d(hr
);
3918 /*****************************************************************************
3919 * IDirect3DDevice7::SetMaterial
3926 * Mat: The material to set
3930 * DDERR_INVALIDPARAMS if Mat is NULL.
3931 * For more details, see IWineD3DDevice::SetMaterial
3933 *****************************************************************************/
3934 static HRESULT WINAPI
3935 IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7
*iface
,
3938 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3940 TRACE("(%p)->(%p): Relay!\n", This
, Mat
);
3942 hr
= IWineD3DDevice_SetMaterial(This
->wineD3DDevice
,
3944 return hr_ddraw_from_wined3d(hr
);
3947 /*****************************************************************************
3948 * IDirect3DDevice7::GetMaterial
3950 * Returns the current material
3955 * Mat: D3DMATERIAL7 structure to write the material paramters to
3959 * DDERR_INVALIDPARAMS if Mat is NULL
3960 * For more details, see IWineD3DDevice::GetMaterial
3962 *****************************************************************************/
3963 static HRESULT WINAPI
3964 IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7
*iface
,
3967 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3969 TRACE("(%p)->(%p): Relay!\n", This
, Mat
);
3971 hr
= IWineD3DDevice_GetMaterial(This
->wineD3DDevice
,
3973 return hr_ddraw_from_wined3d(hr
);
3976 /*****************************************************************************
3977 * IDirect3DDevice7::SetLight
3979 * Assigns a light to a light index, but doesn't activate it yet.
3981 * Version 7, IDirect3DLight uses this method for older versions
3984 * LightIndex: The index of the new light
3985 * Light: A D3DLIGHT7 structure describing the light
3989 * For more details, see IWineD3DDevice::SetLight
3991 *****************************************************************************/
3992 static HRESULT WINAPI
3993 IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7
*iface
,
3997 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
3999 TRACE("(%p)->(%08lx,%p): Relay!\n", This
, LightIndex
, Light
);
4001 hr
= IWineD3DDevice_SetLight(This
->wineD3DDevice
,
4004 return hr_ddraw_from_wined3d(hr
);
4007 /*****************************************************************************
4008 * IDirect3DDevice7::GetLight
4010 * Returns the light assigned to a light index
4013 * Light: Structure to write the light information to
4017 * DDERR_INVALIDPARAMS if Light is NULL
4018 * For details, see IWineD3DDevice::GetLight
4020 *****************************************************************************/
4021 static HRESULT WINAPI
4022 IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7
*iface
,
4026 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4028 TRACE("(%p)->(%08lx,%p): Relay!\n", This
, LightIndex
, Light
);
4030 rc
= IWineD3DDevice_GetLight(This
->wineD3DDevice
,
4034 /* Translate the result. WineD3D returns other values than D3D7 */
4035 return hr_ddraw_from_wined3d(rc
);
4038 /*****************************************************************************
4039 * IDirect3DDevice7::BeginStateBlock
4041 * Begins recording to a stateblock
4047 * For details see IWineD3DDevice::BeginStateBlock
4049 *****************************************************************************/
4050 static HRESULT WINAPI
4051 IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7
*iface
)
4053 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4055 TRACE("(%p)->(): Relay!\n", This
);
4057 hr
= IWineD3DDevice_BeginStateBlock(This
->wineD3DDevice
);
4058 return hr_ddraw_from_wined3d(hr
);
4061 /*****************************************************************************
4062 * IDirect3DDevice7::EndStateBlock
4064 * Stops recording to a state block and returns the created stateblock
4065 * handle. The d3d7 stateblock handles are the interface pointers of the
4066 * IWineD3DStateBlock interface
4071 * BlockHandle: Address to store the stateblock's handle to
4075 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4076 * See IWineD3DDevice::EndStateBlock for more details
4078 *****************************************************************************/
4079 static HRESULT WINAPI
4080 IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7
*iface
,
4083 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4085 TRACE("(%p)->(%p): Relay!\n", This
, BlockHandle
);
4088 return DDERR_INVALIDPARAMS
;
4090 hr
= IWineD3DDevice_EndStateBlock(This
->wineD3DDevice
,
4091 (IWineD3DStateBlock
**) BlockHandle
);
4092 return hr_ddraw_from_wined3d(hr
);
4095 /*****************************************************************************
4096 * IDirect3DDevice7::PreLoad
4098 * Allows the app to signal that a texture will be used soon, to allow
4099 * the Direct3DDevice to load it to the video card in the meantime.
4104 * Texture: The texture to preload
4108 * DDERR_INVALIDPARAMS if Texture is NULL
4109 * See IWineD3DSurface::PreLoad for details
4111 *****************************************************************************/
4112 static HRESULT WINAPI
4113 IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7
*iface
,
4114 IDirectDrawSurface7
*Texture
)
4116 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4117 IDirectDrawSurfaceImpl
*surf
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, Texture
);
4119 TRACE("(%p)->(%p): Relay!\n", This
, surf
);
4122 return DDERR_INVALIDPARAMS
;
4124 IWineD3DSurface_PreLoad(surf
->WineD3DSurface
);
4128 /*****************************************************************************
4129 * IDirect3DDevice7::ApplyStateBlock
4131 * Activates the state stored in a state block handle.
4134 * BlockHandle: The stateblock handle to activate
4138 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4140 *****************************************************************************/
4141 static HRESULT WINAPI
4142 IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7
*iface
,
4145 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4147 TRACE("(%p)->(%08lx): Relay!\n", This
, BlockHandle
);
4150 return D3DERR_INVALIDSTATEBLOCK
;
4152 hr
= IWineD3DStateBlock_Apply((IWineD3DStateBlock
*) BlockHandle
);
4153 return hr_ddraw_from_wined3d(hr
);
4156 /*****************************************************************************
4157 * IDirect3DDevice7::CaptureStateBlock
4159 * Updates a stateblock's values to the values currently set for the device
4164 * BlockHandle: Stateblock to update
4168 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
4169 * See IWineD3DDevice::CaptureStateBlock for more details
4171 *****************************************************************************/
4172 static HRESULT WINAPI
4173 IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7
*iface
,
4176 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4178 TRACE("(%p)->(%08lx): Relay!\n", This
, BlockHandle
);
4180 if(BlockHandle
== 0)
4181 return D3DERR_INVALIDSTATEBLOCK
;
4183 hr
= IWineD3DStateBlock_Capture((IWineD3DStateBlock
*) BlockHandle
);
4184 return hr_ddraw_from_wined3d(hr
);
4187 /*****************************************************************************
4188 * IDirect3DDevice7::DeleteStateBlock
4190 * Deletes a stateblock handle. This means releasing the WineD3DStateBlock
4195 * BlockHandle: Stateblock handle to delete
4199 * D3DERR_INVALIDSTATEBLOCK if BlockHandle is 0
4201 *****************************************************************************/
4202 static HRESULT WINAPI
4203 IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7
*iface
,
4206 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4207 TRACE("(%p)->(%08lx): Relay!\n", This
, BlockHandle
);
4209 if(BlockHandle
== 0)
4210 return D3DERR_INVALIDSTATEBLOCK
;
4212 IWineD3DStateBlock_Release((IWineD3DStateBlock
*) BlockHandle
);
4217 /*****************************************************************************
4218 * IDirect3DDevice7::CreateStateBlock
4220 * Creates a new state block handle.
4225 * Type: The state block type
4226 * BlockHandle: Address to write the created handle to
4230 * DDERR_INVALIDPARAMS if BlockHandle is NULL
4232 *****************************************************************************/
4233 static HRESULT WINAPI
4234 IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7
*iface
,
4235 D3DSTATEBLOCKTYPE Type
,
4238 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4240 TRACE("(%p)->(%08x,%p)!\n", This
, Type
, BlockHandle
);
4243 return DDERR_INVALIDPARAMS
;
4245 /* The D3DSTATEBLOCKTYPE enum is fine here */
4246 hr
= IWineD3DDevice_CreateStateBlock(This
->wineD3DDevice
,
4248 (IWineD3DStateBlock
**) BlockHandle
,
4249 NULL
/* Parent, hope that works */);
4250 return hr_ddraw_from_wined3d(hr
);
4253 /*****************************************************************************
4254 * IDirect3DDevice7::Load
4256 * Loads an rectangular area from the source into the destination texture.
4257 * It can also copy the source to the faces of a cubic environment map
4262 * DestTex: Destination texture
4263 * DestPoint: Point in the destination where the source image should be
4265 * SrcTex: Source texture
4266 * SrcRect: Source rectangle
4271 * DDERR_INVALIDPARAMS if DestTex or SrcTex are NULL
4272 * See IDirect3DTexture2::Load for details
4274 *****************************************************************************/
4275 static HRESULT WINAPI
4276 IDirect3DDeviceImpl_7_Load(IDirect3DDevice7
*iface
,
4277 IDirectDrawSurface7
*DestTex
,
4279 IDirectDrawSurface7
*SrcTex
,
4283 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4284 IDirectDrawSurfaceImpl
*dest
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, DestTex
);
4285 IDirectDrawSurfaceImpl
*src
= ICOM_OBJECT(IDirectDrawSurfaceImpl
, IDirectDrawSurface7
, SrcTex
);
4286 FIXME("(%p)->(%p,%p,%p,%p,%08lx): Partially Implemented!\n", This
, dest
, DestPoint
, src
, SrcRect
, Flags
);
4288 if( (!src
) || (!dest
) )
4289 return DDERR_INVALIDPARAMS
;
4291 IDirect3DTexture2_Load(ICOM_INTERFACE(dest
, IDirect3DTexture2
),
4292 ICOM_INTERFACE(src
, IDirect3DTexture2
));
4296 /*****************************************************************************
4297 * IDirect3DDevice7::LightEnable
4299 * Enables or disables a light
4301 * Version 7, IDirect3DLight uses this method too.
4304 * LightIndex: The index of the light to enable / disable
4305 * Enable: Enable or disable the light
4309 * For more details, see IWineD3DDevice::SetLightEnable
4311 *****************************************************************************/
4312 static HRESULT WINAPI
4313 IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7
*iface
,
4317 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4319 TRACE("(%p)->(%08lx,%d): Relay!\n", This
, LightIndex
, Enable
);
4321 hr
= IWineD3DDevice_SetLightEnable(This
->wineD3DDevice
, LightIndex
, Enable
);
4322 return hr_ddraw_from_wined3d(hr
);
4325 /*****************************************************************************
4326 * IDirect3DDevice7::GetLightEnable
4328 * Retrieves if the light with the given index is enables or not
4333 * LightIndex: Index of desired light
4334 * Enable: Pointer to a BOOL which contains the result
4338 * DDERR_INVALIDPARAMS if Enable is NULL
4339 * See IWineD3DDevice::GetLightEnable for more details
4341 *****************************************************************************/
4342 static HRESULT WINAPI
4343 IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7
*iface
,
4347 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4349 TRACE("(%p)->(%08lx,%p): Relay\n", This
, LightIndex
, Enable
);
4352 return DDERR_INVALIDPARAMS
;
4354 hr
= IWineD3DDevice_GetLightEnable(This
->wineD3DDevice
, LightIndex
, Enable
);
4355 return hr_ddraw_from_wined3d(hr
);
4358 /*****************************************************************************
4359 * IDirect3DDevice7::SetClipPlane
4361 * Sets custom clipping plane
4366 * Index: The index of the clipping plane
4367 * PlaneEquation: An equation defining the clipping plane
4371 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4372 * See IWineD3DDevice::SetClipPlane for more details
4374 *****************************************************************************/
4375 static HRESULT WINAPI
4376 IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7
*iface
,
4378 D3DVALUE
* PlaneEquation
)
4380 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4381 TRACE("(%p)->(%08lx,%p): Relay!\n", This
, Index
, PlaneEquation
);
4384 return DDERR_INVALIDPARAMS
;
4386 return IWineD3DDevice_SetClipPlane(This
->wineD3DDevice
, Index
, PlaneEquation
);
4389 /*****************************************************************************
4390 * IDirect3DDevice7::GetClipPlane
4392 * Returns the clipping plane with a specific index
4395 * Index: The index of the desired plane
4396 * PlaneEquation: Address to store the plane equation to
4400 * DDERR_INVALIDPARAMS if PlaneEquation is NULL
4401 * See IWineD3DDevice::GetClipPlane for more details
4403 *****************************************************************************/
4404 static HRESULT WINAPI
4405 IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7
*iface
,
4407 D3DVALUE
* PlaneEquation
)
4409 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4410 TRACE("(%p)->(%ld,%p): Relay!\n", This
, Index
, PlaneEquation
);
4413 return DDERR_INVALIDPARAMS
;
4415 return IWineD3DDevice_GetClipPlane(This
->wineD3DDevice
, Index
, PlaneEquation
);
4418 /*****************************************************************************
4419 * IDirect3DDevice7::GetInfo
4421 * Retrieves some information about the device. The DirectX sdk says that
4422 * this version returnes S_FALSE for all retail build of DirectX, that's
4423 * this implementation does.
4426 * DevInfoID: Information type requested
4427 * DevInfoStruct: Pointer to a structure to store the info to
4428 * Size: Size of the structure
4431 * S_FALSE, because it's a non-debug driver
4433 *****************************************************************************/
4434 static HRESULT WINAPI
4435 IDirect3DDeviceImpl_7_GetInfo(IDirect3DDevice7
*iface
,
4437 void *DevInfoStruct
,
4440 ICOM_THIS_FROM(IDirect3DDeviceImpl
, IDirect3DDevice7
, iface
);
4441 TRACE("(%p)->(%08lx,%p,%08lx)\n", This
, DevInfoID
, DevInfoStruct
, Size
);
4445 TRACE(" info requested : ");
4448 case D3DDEVINFOID_TEXTUREMANAGER
: TRACE("D3DDEVINFOID_TEXTUREMANAGER\n"); break;
4449 case D3DDEVINFOID_D3DTEXTUREMANAGER
: TRACE("D3DDEVINFOID_D3DTEXTUREMANAGER\n"); break;
4450 case D3DDEVINFOID_TEXTURING
: TRACE("D3DDEVINFOID_TEXTURING\n"); break;
4451 default: ERR(" invalid flag !!!\n"); return DDERR_INVALIDPARAMS
;
4455 return S_FALSE
; /* According to MSDN, this is valid for a non-debug driver */
4458 const IDirect3DDevice7Vtbl IDirect3DDevice7_Vtbl
=
4460 /*** IUnknown Methods ***/
4461 IDirect3DDeviceImpl_7_QueryInterface
,
4462 IDirect3DDeviceImpl_7_AddRef
,
4463 IDirect3DDeviceImpl_7_Release
,
4464 /*** IDirect3DDevice7 ***/
4465 IDirect3DDeviceImpl_7_GetCaps
,
4466 IDirect3DDeviceImpl_7_EnumTextureFormats
,
4467 IDirect3DDeviceImpl_7_BeginScene
,
4468 IDirect3DDeviceImpl_7_EndScene
,
4469 IDirect3DDeviceImpl_7_GetDirect3D
,
4470 IDirect3DDeviceImpl_7_SetRenderTarget
,
4471 IDirect3DDeviceImpl_7_GetRenderTarget
,
4472 IDirect3DDeviceImpl_7_Clear
,
4473 IDirect3DDeviceImpl_7_SetTransform
,
4474 IDirect3DDeviceImpl_7_GetTransform
,
4475 IDirect3DDeviceImpl_7_SetViewport
,
4476 IDirect3DDeviceImpl_7_MultiplyTransform
,
4477 IDirect3DDeviceImpl_7_GetViewport
,
4478 IDirect3DDeviceImpl_7_SetMaterial
,
4479 IDirect3DDeviceImpl_7_GetMaterial
,
4480 IDirect3DDeviceImpl_7_SetLight
,
4481 IDirect3DDeviceImpl_7_GetLight
,
4482 IDirect3DDeviceImpl_7_SetRenderState
,
4483 IDirect3DDeviceImpl_7_GetRenderState
,
4484 IDirect3DDeviceImpl_7_BeginStateBlock
,
4485 IDirect3DDeviceImpl_7_EndStateBlock
,
4486 IDirect3DDeviceImpl_7_PreLoad
,
4487 IDirect3DDeviceImpl_7_DrawPrimitive
,
4488 IDirect3DDeviceImpl_7_DrawIndexedPrimitive
,
4489 IDirect3DDeviceImpl_7_SetClipStatus
,
4490 IDirect3DDeviceImpl_7_GetClipStatus
,
4491 IDirect3DDeviceImpl_7_DrawPrimitiveStrided
,
4492 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided
,
4493 IDirect3DDeviceImpl_7_DrawPrimitiveVB
,
4494 IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB
,
4495 IDirect3DDeviceImpl_7_ComputeSphereVisibility
,
4496 IDirect3DDeviceImpl_7_GetTexture
,
4497 IDirect3DDeviceImpl_7_SetTexture
,
4498 IDirect3DDeviceImpl_7_GetTextureStageState
,
4499 IDirect3DDeviceImpl_7_SetTextureStageState
,
4500 IDirect3DDeviceImpl_7_ValidateDevice
,
4501 IDirect3DDeviceImpl_7_ApplyStateBlock
,
4502 IDirect3DDeviceImpl_7_CaptureStateBlock
,
4503 IDirect3DDeviceImpl_7_DeleteStateBlock
,
4504 IDirect3DDeviceImpl_7_CreateStateBlock
,
4505 IDirect3DDeviceImpl_7_Load
,
4506 IDirect3DDeviceImpl_7_LightEnable
,
4507 IDirect3DDeviceImpl_7_GetLightEnable
,
4508 IDirect3DDeviceImpl_7_SetClipPlane
,
4509 IDirect3DDeviceImpl_7_GetClipPlane
,
4510 IDirect3DDeviceImpl_7_GetInfo
4513 const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl
=
4515 /*** IUnknown Methods ***/
4516 Thunk_IDirect3DDeviceImpl_3_QueryInterface
,
4517 Thunk_IDirect3DDeviceImpl_3_AddRef
,
4518 Thunk_IDirect3DDeviceImpl_3_Release
,
4519 /*** IDirect3DDevice3 ***/
4520 IDirect3DDeviceImpl_3_GetCaps
,
4521 IDirect3DDeviceImpl_3_GetStats
,
4522 IDirect3DDeviceImpl_3_AddViewport
,
4523 IDirect3DDeviceImpl_3_DeleteViewport
,
4524 IDirect3DDeviceImpl_3_NextViewport
,
4525 Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats
,
4526 Thunk_IDirect3DDeviceImpl_3_BeginScene
,
4527 Thunk_IDirect3DDeviceImpl_3_EndScene
,
4528 Thunk_IDirect3DDeviceImpl_3_GetDirect3D
,
4529 IDirect3DDeviceImpl_3_SetCurrentViewport
,
4530 IDirect3DDeviceImpl_3_GetCurrentViewport
,
4531 Thunk_IDirect3DDeviceImpl_3_SetRenderTarget
,
4532 Thunk_IDirect3DDeviceImpl_3_GetRenderTarget
,
4533 IDirect3DDeviceImpl_3_Begin
,
4534 IDirect3DDeviceImpl_3_BeginIndexed
,
4535 IDirect3DDeviceImpl_3_Vertex
,
4536 IDirect3DDeviceImpl_3_Index
,
4537 IDirect3DDeviceImpl_3_End
,
4538 Thunk_IDirect3DDeviceImpl_3_GetRenderState
,
4539 Thunk_IDirect3DDeviceImpl_3_SetRenderState
,
4540 IDirect3DDeviceImpl_3_GetLightState
,
4541 IDirect3DDeviceImpl_3_SetLightState
,
4542 Thunk_IDirect3DDeviceImpl_3_SetTransform
,
4543 Thunk_IDirect3DDeviceImpl_3_GetTransform
,
4544 Thunk_IDirect3DDeviceImpl_3_MultiplyTransform
,
4545 Thunk_IDirect3DDeviceImpl_3_DrawPrimitive
,
4546 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive
,
4547 Thunk_IDirect3DDeviceImpl_3_SetClipStatus
,
4548 Thunk_IDirect3DDeviceImpl_3_GetClipStatus
,
4549 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided
,
4550 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided
,
4551 Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB
,
4552 Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB
,
4553 Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility
,
4554 Thunk_IDirect3DDeviceImpl_3_GetTexture
,
4555 Thunk_IDirect3DDeviceImpl_3_SetTexture
,
4556 Thunk_IDirect3DDeviceImpl_3_GetTextureStageState
,
4557 Thunk_IDirect3DDeviceImpl_3_SetTextureStageState
,
4558 Thunk_IDirect3DDeviceImpl_3_ValidateDevice
4561 const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl
=
4563 /*** IUnknown Methods ***/
4564 Thunk_IDirect3DDeviceImpl_2_QueryInterface
,
4565 Thunk_IDirect3DDeviceImpl_2_AddRef
,
4566 Thunk_IDirect3DDeviceImpl_2_Release
,
4567 /*** IDirect3DDevice2 ***/
4568 Thunk_IDirect3DDeviceImpl_2_GetCaps
,
4569 IDirect3DDeviceImpl_2_SwapTextureHandles
,
4570 Thunk_IDirect3DDeviceImpl_2_GetStats
,
4571 Thunk_IDirect3DDeviceImpl_2_AddViewport
,
4572 Thunk_IDirect3DDeviceImpl_2_DeleteViewport
,
4573 Thunk_IDirect3DDeviceImpl_2_NextViewport
,
4574 IDirect3DDeviceImpl_2_EnumTextureFormats
,
4575 Thunk_IDirect3DDeviceImpl_2_BeginScene
,
4576 Thunk_IDirect3DDeviceImpl_2_EndScene
,
4577 Thunk_IDirect3DDeviceImpl_2_GetDirect3D
,
4578 Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport
,
4579 Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport
,
4580 Thunk_IDirect3DDeviceImpl_2_SetRenderTarget
,
4581 Thunk_IDirect3DDeviceImpl_2_GetRenderTarget
,
4582 Thunk_IDirect3DDeviceImpl_2_Begin
,
4583 Thunk_IDirect3DDeviceImpl_2_BeginIndexed
,
4584 Thunk_IDirect3DDeviceImpl_2_Vertex
,
4585 Thunk_IDirect3DDeviceImpl_2_Index
,
4586 Thunk_IDirect3DDeviceImpl_2_End
,
4587 Thunk_IDirect3DDeviceImpl_2_GetRenderState
,
4588 Thunk_IDirect3DDeviceImpl_2_SetRenderState
,
4589 Thunk_IDirect3DDeviceImpl_2_GetLightState
,
4590 Thunk_IDirect3DDeviceImpl_2_SetLightState
,
4591 Thunk_IDirect3DDeviceImpl_2_SetTransform
,
4592 Thunk_IDirect3DDeviceImpl_2_GetTransform
,
4593 Thunk_IDirect3DDeviceImpl_2_MultiplyTransform
,
4594 Thunk_IDirect3DDeviceImpl_2_DrawPrimitive
,
4595 Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive
,
4596 Thunk_IDirect3DDeviceImpl_2_SetClipStatus
,
4597 Thunk_IDirect3DDeviceImpl_2_GetClipStatus
4600 const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl
=
4602 /*** IUnknown Methods ***/
4603 Thunk_IDirect3DDeviceImpl_1_QueryInterface
,
4604 Thunk_IDirect3DDeviceImpl_1_AddRef
,
4605 Thunk_IDirect3DDeviceImpl_1_Release
,
4606 /*** IDirect3DDevice1 ***/
4607 IDirect3DDeviceImpl_1_Initialize
,
4608 Thunk_IDirect3DDeviceImpl_1_GetCaps
,
4609 Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles
,
4610 IDirect3DDeviceImpl_1_CreateExecuteBuffer
,
4611 Thunk_IDirect3DDeviceImpl_1_GetStats
,
4612 IDirect3DDeviceImpl_1_Execute
,
4613 Thunk_IDirect3DDeviceImpl_1_AddViewport
,
4614 Thunk_IDirect3DDeviceImpl_1_DeleteViewport
,
4615 Thunk_IDirect3DDeviceImpl_1_NextViewport
,
4616 IDirect3DDeviceImpl_1_Pick
,
4617 IDirect3DDeviceImpl_1_GetPickRecords
,
4618 Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats
,
4619 IDirect3DDeviceImpl_1_CreateMatrix
,
4620 IDirect3DDeviceImpl_1_SetMatrix
,
4621 IDirect3DDeviceImpl_1_GetMatrix
,
4622 IDirect3DDeviceImpl_1_DeleteMatrix
,
4623 Thunk_IDirect3DDeviceImpl_1_EndScene
,
4624 Thunk_IDirect3DDeviceImpl_1_BeginScene
,
4625 Thunk_IDirect3DDeviceImpl_1_GetDirect3D
4628 /*****************************************************************************
4629 * IDirect3DDeviceImpl_CreateHandle
4631 * Not called from the VTable
4633 * Some older interface versions operate with handles, which are basically
4634 * DWORDs which identify an interface, for example
4635 * IDirect3DDevice::SetRenderState with DIRECT3DRENDERSTATE_TEXTUREHANDLE
4637 * Those handle could be just casts to the interface pointers or vice versa,
4638 * but that is not 64 bit safe and would mean blindly derefering a DWORD
4639 * passed by the app. Instead there is a dynamic array in the device which
4640 * keeps a DWORD to pointer information and a type for the handle.
4642 * Basically this array only grows, when a handle is freed its pointer is
4643 * just set to NULL. There will be much more reads from the array than
4644 * insertion operations, so a dynamic array is fine.
4647 * This: D3DDevice implementation for which this handle should be created
4650 * A free handle on success
4653 *****************************************************************************/
4655 IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl
*This
)
4658 struct HandleEntry
*oldHandles
= This
->Handles
;
4660 TRACE("(%p)\n", This
);
4662 for(i
= 0; i
< This
->numHandles
; i
++)
4664 if(This
->Handles
[i
].ptr
== NULL
&&
4665 This
->Handles
[i
].type
== DDrawHandle_Unknown
)
4667 TRACE("Reusing freed handle %ld\n", i
+ 1);
4672 TRACE("Growing the handle array\n");
4675 This
->Handles
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct HandleEntry
) * This
->numHandles
);
4678 ERR("Out of memory\n");
4679 This
->Handles
= oldHandles
;
4685 memcpy(This
->Handles
, oldHandles
, (This
->numHandles
- 1) * sizeof(struct HandleEntry
));
4686 HeapFree(GetProcessHeap(), 0, oldHandles
);
4689 TRACE("Returning %ld\n", This
->numHandles
);
4690 return This
->numHandles
;