2006-06-09 19:36:12 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1998-2004 Lionel Ulmer
|
|
|
|
* Copyright (c) 2002-2005 Christian Costa
|
2008-10-18 19:19:45 +02:00
|
|
|
* Copyright (c) 2006 Stefan Dösinger
|
2008-05-05 23:49:28 +02:00
|
|
|
* Copyright (c) 2008 Alexander Dorofeyev
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
* IDirect3DDevice implementation, version 1, 2, 3 and 7. Rendering is relayed
|
|
|
|
* to WineD3D, some minimal DirectDraw specific management is handled here.
|
|
|
|
* The Direct3DDevice is NOT the parent of the WineD3DDevice, because d3d
|
|
|
|
* is initialized when DirectDraw creates the primary surface.
|
|
|
|
* Some type management is necessary, because some D3D types changed between
|
|
|
|
* D3D7 and D3D9.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include "ddraw_private.h"
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* The device ID */
|
|
|
|
const GUID IID_D3DDEVICE_WineD3D = {
|
|
|
|
0xaef72d43,
|
|
|
|
0xb09a,
|
|
|
|
0x4b7b,
|
|
|
|
{ 0xb7,0x98,0xc6,0x8a,0x77,0x2d,0x72,0x2a }
|
|
|
|
};
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static inline void set_fpu_control_word(WORD fpucw)
|
|
|
|
{
|
|
|
|
#if defined(__i386__) && defined(__GNUC__)
|
|
|
|
__asm__ volatile ("fldcw %0" : : "m" (fpucw));
|
|
|
|
#elif defined(__i386__) && defined(_MSC_VER)
|
|
|
|
__asm fldcw fpucw;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline WORD d3d_fpu_setup(void)
|
|
|
|
{
|
|
|
|
WORD oldcw;
|
|
|
|
|
|
|
|
#if defined(__i386__) && defined(__GNUC__)
|
|
|
|
__asm__ volatile ("fnstcw %0" : "=m" (oldcw));
|
|
|
|
#elif defined(__i386__) && defined(_MSC_VER)
|
|
|
|
__asm fnstcw oldcw;
|
|
|
|
#else
|
|
|
|
static BOOL warned = FALSE;
|
|
|
|
if(!warned)
|
|
|
|
{
|
|
|
|
FIXME("FPUPRESERVE not implemented for this platform / compiler\n");
|
|
|
|
warned = TRUE;
|
|
|
|
}
|
2009-01-08 17:30:22 +01:00
|
|
|
return 0;
|
2008-06-20 01:49:46 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
set_fpu_control_word(0x37f);
|
|
|
|
|
|
|
|
return oldcw;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
2009-09-01 09:09:37 +02:00
|
|
|
* IUnknown Methods. Common for Version 1, 2, 3 and 7
|
2006-06-09 19:36:12 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::QueryInterface
|
|
|
|
*
|
|
|
|
* Used to query other interfaces from a Direct3DDevice interface.
|
|
|
|
* It can return interface pointers to all Direct3DDevice versions as well
|
2006-06-23 18:18:02 +02:00
|
|
|
* as IDirectDraw and IDirect3D. For a link to QueryInterface
|
2006-06-09 19:36:12 +02:00
|
|
|
* rules see ddraw.c, IDirectDraw7::QueryInterface
|
|
|
|
*
|
|
|
|
* Exists in Version 1, 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* refiid: Interface ID queried for
|
|
|
|
* obj: Used to return the interface pointer
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK or E_NOINTERFACE
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_QueryInterface(IDirect3DDevice7 *iface,
|
|
|
|
REFIID refiid,
|
|
|
|
void **obj)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(refiid), obj);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* According to COM docs, if the QueryInterface fails, obj should be set to NULL */
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if(!refiid)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( &IID_IUnknown, refiid ) )
|
|
|
|
{
|
2009-01-21 09:56:13 +01:00
|
|
|
*obj = iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-04-03 23:35:31 +02:00
|
|
|
/* Check DirectDraw Interfaces. */
|
2006-06-09 19:36:12 +02:00
|
|
|
else if( IsEqualGUID( &IID_IDirectDraw7, refiid ) )
|
|
|
|
{
|
2011-01-19 01:42:43 +01:00
|
|
|
*obj = &This->ddraw->IDirectDraw7_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirectDraw7 interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
else if ( IsEqualGUID( &IID_IDirectDraw4, refiid ) )
|
|
|
|
{
|
2011-01-19 01:40:53 +01:00
|
|
|
*obj = &This->ddraw->IDirectDraw4_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirectDraw4 interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
else if ( IsEqualGUID( &IID_IDirectDraw2, refiid ) )
|
|
|
|
{
|
2011-01-19 01:36:36 +01:00
|
|
|
*obj = &This->ddraw->IDirectDraw2_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirectDraw2 interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
else if( IsEqualGUID( &IID_IDirectDraw, refiid ) )
|
|
|
|
{
|
2011-01-19 01:33:42 +01:00
|
|
|
*obj = &This->ddraw->IDirectDraw_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirectDraw interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Direct3D */
|
|
|
|
else if ( IsEqualGUID( &IID_IDirect3D , refiid ) )
|
|
|
|
{
|
2011-01-18 12:28:15 +01:00
|
|
|
*obj = &This->ddraw->IDirect3D_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirect3D interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
else if ( IsEqualGUID( &IID_IDirect3D2 , refiid ) )
|
|
|
|
{
|
2011-01-18 12:30:17 +01:00
|
|
|
*obj = &This->ddraw->IDirect3D2_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirect3D2 interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
else if ( IsEqualGUID( &IID_IDirect3D3 , refiid ) )
|
|
|
|
{
|
2011-01-19 01:30:21 +01:00
|
|
|
*obj = &This->ddraw->IDirect3D3_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirect3D3 interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
else if ( IsEqualGUID( &IID_IDirect3D7 , refiid ) )
|
|
|
|
{
|
2011-01-19 01:32:36 +01:00
|
|
|
*obj = &This->ddraw->IDirect3D7_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirect3D7 interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Direct3DDevice */
|
|
|
|
else if ( IsEqualGUID( &IID_IDirect3DDevice , refiid ) )
|
|
|
|
{
|
2009-01-21 09:56:13 +01:00
|
|
|
*obj = &This->IDirect3DDevice_vtbl;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
else if ( IsEqualGUID( &IID_IDirect3DDevice2 , refiid ) ) {
|
2009-01-21 09:56:13 +01:00
|
|
|
*obj = &This->IDirect3DDevice2_vtbl;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirect3DDevice2 interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
else if ( IsEqualGUID( &IID_IDirect3DDevice3 , refiid ) ) {
|
2009-01-21 09:56:13 +01:00
|
|
|
*obj = &This->IDirect3DDevice3_vtbl;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirect3DDevice3 interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
else if ( IsEqualGUID( &IID_IDirect3DDevice7 , refiid ) ) {
|
2009-01-21 09:56:13 +01:00
|
|
|
*obj = This;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) Returning IDirect3DDevice7 interface at %p\n", This, *obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unknown interface */
|
|
|
|
else
|
|
|
|
{
|
2006-10-05 11:11:03 +02:00
|
|
|
ERR("(%p)->(%s, %p): No interface found\n", This, debugstr_guid(refiid), obj);
|
2006-06-09 19:36:12 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* AddRef the returned interface */
|
|
|
|
IUnknown_AddRef( (IUnknown *) *obj);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_QueryInterface(IDirect3DDevice3 *iface, REFIID riid,
|
|
|
|
void **obj)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_QueryInterface((IDirect3DDevice7 *)device_from_device3(iface), riid, obj);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_QueryInterface(IDirect3DDevice2 *iface, REFIID riid,
|
|
|
|
void **obj)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_QueryInterface((IDirect3DDevice7 *)device_from_device2(iface), riid, obj);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_1_QueryInterface(IDirect3DDevice *iface, REFIID riid,
|
|
|
|
void **obp)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obp);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_QueryInterface((IDirect3DDevice7 *)device_from_device1(iface), riid, obp);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::AddRef
|
|
|
|
*
|
|
|
|
* Increases the refcount....
|
2006-06-23 18:18:02 +02:00
|
|
|
* The most exciting Method, definitely
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Exists in Version 1, 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The new refcount
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_AddRef(IDirect3DDevice7 *iface)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", This, ref);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static ULONG WINAPI IDirect3DDeviceImpl_3_AddRef(IDirect3DDevice3 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_AddRef((IDirect3DDevice7 *)device_from_device3(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static ULONG WINAPI IDirect3DDeviceImpl_2_AddRef(IDirect3DDevice2 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_AddRef((IDirect3DDevice7 *)device_from_device2(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static ULONG WINAPI IDirect3DDeviceImpl_1_AddRef(IDirect3DDevice *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2009-01-22 10:33:37 +01:00
|
|
|
return IDirect3DDevice7_AddRef((IDirect3DDevice7 *)device_from_device1(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::Release
|
|
|
|
*
|
|
|
|
* Decreases the refcount of the interface
|
|
|
|
* When the refcount is reduced to 0, the object is destroyed.
|
|
|
|
*
|
|
|
|
* Exists in Version 1, 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Returns:d
|
|
|
|
* The new refcount
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static ULONG WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", This, ref);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* This method doesn't destroy the WineD3DDevice, because it's still in use for
|
|
|
|
* 2D rendering. IDirectDrawSurface7::Release will destroy the WineD3DDevice
|
|
|
|
* when the render target is released
|
|
|
|
*/
|
|
|
|
if (ref == 0)
|
|
|
|
{
|
2006-06-16 23:44:33 +02:00
|
|
|
DWORD i;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-03 23:35:30 +02:00
|
|
|
|
|
|
|
/* There is no need to unset any resources here, wined3d will take
|
|
|
|
* care of that on Uninit3D(). */
|
|
|
|
|
2007-01-06 18:26:08 +01:00
|
|
|
/* Free the index buffer. */
|
2011-03-03 21:49:09 +01:00
|
|
|
wined3d_buffer_decref(This->indexbuffer);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-10-05 14:32:35 +02:00
|
|
|
/* Set the device up to render to the front buffer since the back
|
|
|
|
* buffer will vanish soon. */
|
|
|
|
IWineD3DDevice_SetRenderTarget(This->wineD3DDevice, 0,
|
2011-04-29 13:03:41 +02:00
|
|
|
This->ddraw->d3d_target->wined3d_surface, TRUE);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Release the WineD3DDevice. This won't destroy it */
|
|
|
|
if(IWineD3DDevice_Release(This->wineD3DDevice) <= 0)
|
|
|
|
{
|
2008-05-06 15:54:52 +02:00
|
|
|
ERR(" (%p) The wineD3D device %p was destroyed unexpectedly. Prepare for trouble\n", This, This->wineD3DDevice);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2006-06-16 23:44:33 +02:00
|
|
|
/* The texture handles should be unset by now, but there might be some bits
|
2010-07-30 10:15:24 +02:00
|
|
|
* missing in our reference counting(needs test). Do a sanity check. */
|
2010-07-29 12:56:57 +02:00
|
|
|
for (i = 0; i < This->handle_table.entry_count; ++i)
|
|
|
|
{
|
|
|
|
struct ddraw_handle_entry *entry = &This->handle_table.entries[i];
|
|
|
|
|
|
|
|
switch (entry->type)
|
|
|
|
{
|
|
|
|
case DDRAW_HANDLE_FREE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDRAW_HANDLE_MATERIAL:
|
|
|
|
{
|
|
|
|
IDirect3DMaterialImpl *m = entry->object;
|
|
|
|
FIXME("Material handle %#x (%p) not unset properly.\n", i + 1, m);
|
|
|
|
m->Handle = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:56:58 +02:00
|
|
|
case DDRAW_HANDLE_MATRIX:
|
|
|
|
{
|
|
|
|
/* No FIXME here because this might happen because of sloppy applications. */
|
|
|
|
WARN("Leftover matrix handle %#x (%p), deleting.\n", i + 1, entry->object);
|
|
|
|
IDirect3DDevice_DeleteMatrix((IDirect3DDevice *)&This->IDirect3DDevice_vtbl, i + 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-07-30 10:15:23 +02:00
|
|
|
case DDRAW_HANDLE_STATEBLOCK:
|
|
|
|
{
|
|
|
|
/* No FIXME here because this might happen because of sloppy applications. */
|
|
|
|
WARN("Leftover stateblock handle %#x (%p), deleting.\n", i + 1, entry->object);
|
|
|
|
IDirect3DDevice7_DeleteStateBlock(iface, i + 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-07-30 10:15:24 +02:00
|
|
|
case DDRAW_HANDLE_SURFACE:
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *surf = entry->object;
|
|
|
|
FIXME("Texture handle %#x (%p) not unset properly.\n", i + 1, surf);
|
|
|
|
surf->Handle = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:56:57 +02:00
|
|
|
default:
|
|
|
|
FIXME("Handle %#x (%p) has unknown type %#x.\n", i + 1, entry->object, entry->type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ddraw_handle_table_destroy(&This->handle_table);
|
|
|
|
|
2007-04-27 15:31:12 +02:00
|
|
|
TRACE("Releasing target %p %p\n", This->target, This->ddraw->d3d_target);
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Release the render target and the WineD3D render target
|
|
|
|
* (See IDirect3D7::CreateDevice for more comments on this)
|
|
|
|
*/
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_Release((IDirectDrawSurface7 *)This->target);
|
|
|
|
IDirectDrawSurface7_Release((IDirectDrawSurface7 *)This->ddraw->d3d_target);
|
2007-04-27 15:31:12 +02:00
|
|
|
TRACE("Target release done\n");
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
This->ddraw->d3ddevice = NULL;
|
|
|
|
|
|
|
|
/* Now free the structure */
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2007-04-27 15:31:12 +02:00
|
|
|
TRACE("Done\n");
|
2006-06-09 19:36:12 +02:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static ULONG WINAPI IDirect3DDeviceImpl_3_Release(IDirect3DDevice3 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_Release((IDirect3DDevice7 *)device_from_device3(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static ULONG WINAPI IDirect3DDeviceImpl_2_Release(IDirect3DDevice2 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_Release((IDirect3DDevice7 *)device_from_device2(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static ULONG WINAPI IDirect3DDeviceImpl_1_Release(IDirect3DDevice *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_Release((IDirect3DDevice7 *)device_from_device1(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice Methods
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice::Initialize
|
|
|
|
*
|
|
|
|
* Initializes a Direct3DDevice. This implementation is a no-op, as all
|
|
|
|
* initialization is done at create time.
|
|
|
|
*
|
|
|
|
* Exists in Version 1
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* No idea what they mean, as the MSDN page is gone
|
|
|
|
*
|
|
|
|
* Returns: DD_OK
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_1_Initialize(IDirect3DDevice *iface,
|
|
|
|
IDirect3D *Direct3D, GUID *guid,
|
|
|
|
D3DDEVICEDESC *Desc)
|
|
|
|
{
|
|
|
|
/* It shouldn't be crucial, but print a FIXME, I'm interested if
|
2010-08-19 18:57:50 +02:00
|
|
|
* any game calls it and when. */
|
|
|
|
FIXME("iface %p, d3d %p, guid %s, device_desc %p nop!\n",
|
|
|
|
iface, Direct3D, debugstr_guid(guid), Desc);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetCaps
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Retrieves the device's capabilities
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* This implementation is used for Version 7 only, the older versions have
|
|
|
|
* their own implementation.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* Desc: Pointer to a D3DDEVICEDESC7 structure to fill
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* D3DERR_* if a problem occurs. See WineD3D
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetCaps(IDirect3DDevice7 *iface,
|
|
|
|
D3DDEVICEDESC7 *Desc)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
D3DDEVICEDESC OldDesc;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, device_desc %p.\n", iface, Desc);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Call the same function used by IDirect3D, this saves code */
|
|
|
|
return IDirect3DImpl_GetCaps(This->ddraw->wineD3D, &OldDesc, Desc);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetCaps_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DDEVICEDESC7 *Desc)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_GetCaps(iface, Desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetCaps_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DDEVICEDESC7 *Desc)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetCaps(iface, Desc);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::GetCaps
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Retrieves the capabilities of the hardware device and the emulation
|
|
|
|
* device. For Wine, hardware and emulation are the same (it's all HW).
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* This implementation is used for Version 1, 2, and 3. Version 7 has its own
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* HWDesc: Structure to fill with the HW caps
|
2008-04-02 21:26:42 +02:00
|
|
|
* HelDesc: Structure to fill with the hardware emulation caps
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* D3DERR_* if a problem occurs. See WineD3D
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_GetCaps(IDirect3DDevice3 *iface,
|
|
|
|
D3DDEVICEDESC *HWDesc,
|
|
|
|
D3DDEVICEDESC *HelDesc)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
D3DDEVICEDESC7 newDesc;
|
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, hw_desc %p, hel_desc %p.\n", iface, HWDesc, HelDesc);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
hr = IDirect3DImpl_GetCaps(This->ddraw->wineD3D, HWDesc, &newDesc);
|
|
|
|
if(hr != D3D_OK) return hr;
|
|
|
|
|
|
|
|
*HelDesc = *HWDesc;
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_GetCaps(IDirect3DDevice2 *iface,
|
|
|
|
D3DDEVICEDESC *D3DHWDevDesc, D3DDEVICEDESC *D3DHELDevDesc)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, hw_desc %p, hel_desc %p.\n", iface, D3DHWDevDesc, D3DHELDevDesc);
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_GetCaps((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, D3DHWDevDesc, D3DHELDevDesc);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_1_GetCaps(IDirect3DDevice *iface,
|
|
|
|
D3DDEVICEDESC *D3DHWDevDesc, D3DDEVICEDESC *D3DHELDevDesc)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, hw_desc %p, hel_desc %p.\n", iface, D3DHWDevDesc, D3DHELDevDesc);
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_GetCaps((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, D3DHWDevDesc, D3DHELDevDesc);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice2::SwapTextureHandles
|
|
|
|
*
|
|
|
|
* Swaps the texture handles of 2 Texture interfaces. Version 1 and 2
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* Tex1, Tex2: The 2 Textures to swap
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2 *iface,
|
|
|
|
IDirect3DTexture2 *Tex1,
|
|
|
|
IDirect3DTexture2 *Tex2)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirectDrawSurfaceImpl *surf1 = surface_from_texture2(Tex1);
|
|
|
|
IDirectDrawSurfaceImpl *surf2 = surface_from_texture2(Tex2);
|
2010-07-30 10:15:24 +02:00
|
|
|
DWORD h1, h2;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, tex1 %p, tex2 %p.\n", iface, Tex1, Tex2);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-07-30 10:15:24 +02:00
|
|
|
h1 = surf1->Handle - 1;
|
|
|
|
h2 = surf2->Handle - 1;
|
|
|
|
This->handle_table.entries[h1].object = surf2;
|
|
|
|
This->handle_table.entries[h2].object = surf1;
|
|
|
|
surf2->Handle = h1 + 1;
|
|
|
|
surf1->Handle = h2 + 1;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_1_SwapTextureHandles(IDirect3DDevice *iface,
|
|
|
|
IDirect3DTexture *D3DTex1, IDirect3DTexture *D3DTex2)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirectDrawSurfaceImpl *surf1 = surface_from_texture1(D3DTex1);
|
|
|
|
IDirectDrawSurfaceImpl *surf2 = surface_from_texture1(D3DTex2);
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirect3DTexture2 *t1 = surf1 ? (IDirect3DTexture2 *)&surf1->IDirect3DTexture2_vtbl : NULL;
|
|
|
|
IDirect3DTexture2 *t2 = surf2 ? (IDirect3DTexture2 *)&surf2->IDirect3DTexture2_vtbl : NULL;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, tex1 %p, tex2 %p.\n", iface, D3DTex1, D3DTex2);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice2_SwapTextureHandles((IDirect3DDevice2 *)&This->IDirect3DDevice2_vtbl, t1, t2);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::GetStats
|
|
|
|
*
|
|
|
|
* This method seems to retrieve some stats from the device.
|
|
|
|
* The MSDN documentation doesn't exist any more, but the D3DSTATS
|
2008-01-16 12:20:50 +01:00
|
|
|
* structure suggests that the amount of drawn primitives and processed
|
2006-06-09 19:36:12 +02:00
|
|
|
* vertices is returned.
|
|
|
|
*
|
|
|
|
* Exists in Version 1, 2 and 3
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* Stats: Pointer to a D3DSTATS structure to be filled
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Stats == NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_GetStats(IDirect3DDevice3 *iface,
|
|
|
|
D3DSTATS *Stats)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, stats %p stub!\n", iface, Stats);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Stats)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
/* Fill the Stats with 0 */
|
|
|
|
Stats->dwTrianglesDrawn = 0;
|
|
|
|
Stats->dwLinesDrawn = 0;
|
|
|
|
Stats->dwPointsDrawn = 0;
|
|
|
|
Stats->dwSpansDrawn = 0;
|
|
|
|
Stats->dwVerticesProcessed = 0;
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_GetStats(IDirect3DDevice2 *iface, D3DSTATS *Stats)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stats %p.\n", iface, Stats);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_GetStats((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, Stats);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_1_GetStats(IDirect3DDevice *iface, D3DSTATS *Stats)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stats %p.\n", iface, Stats);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_GetStats((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, Stats);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice::CreateExecuteBuffer
|
|
|
|
*
|
|
|
|
* Creates an IDirect3DExecuteBuffer, used for rendering with a
|
|
|
|
* Direct3DDevice.
|
|
|
|
*
|
|
|
|
* Version 1 only.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Desc: Buffer description
|
|
|
|
* ExecuteBuffer: Address to return the Interface pointer at
|
2006-06-23 18:18:02 +02:00
|
|
|
* UnkOuter: Must be NULL. Basically for aggregation, which ddraw doesn't
|
2006-06-09 19:36:12 +02:00
|
|
|
* support
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* CLASS_E_NOAGGREGATION if UnkOuter != NULL
|
|
|
|
* DDERR_OUTOFMEMORY if we ran out of memory
|
|
|
|
* D3D_OK on success
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_1_CreateExecuteBuffer(IDirect3DDevice *iface,
|
|
|
|
D3DEXECUTEBUFFERDESC *Desc,
|
|
|
|
IDirect3DExecuteBuffer **ExecuteBuffer,
|
|
|
|
IUnknown *UnkOuter)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DExecuteBufferImpl* object;
|
2010-08-19 18:57:45 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, buffer_desc %p, buffer %p, outer_unknown %p.\n",
|
|
|
|
iface, Desc, ExecuteBuffer, UnkOuter);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(UnkOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
/* Allocate the new Execute Buffer */
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DExecuteBufferImpl));
|
|
|
|
if(!object)
|
|
|
|
{
|
|
|
|
ERR("Out of memory when allocating a IDirect3DExecuteBufferImpl structure\n");
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2010-08-19 18:57:45 +02:00
|
|
|
hr = d3d_execute_buffer_init(object, This, Desc);
|
|
|
|
if (FAILED(hr))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:45 +02:00
|
|
|
WARN("Failed to initialize execute buffer, hr %#x.\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
*ExecuteBuffer = (IDirect3DExecuteBuffer *)object;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
TRACE(" Returning IDirect3DExecuteBuffer at %p, implementation is at %p\n", *ExecuteBuffer, object);
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice::Execute
|
|
|
|
*
|
|
|
|
* Executes all the stuff in an execute buffer.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* ExecuteBuffer: The buffer to execute
|
|
|
|
* Viewport: The viewport used for rendering
|
|
|
|
* Flags: Some flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_INVALIDPARAMS if ExecuteBuffer == NULL
|
2006-11-07 00:37:42 +01:00
|
|
|
* D3D_OK on success
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_1_Execute(IDirect3DDevice *iface,
|
|
|
|
IDirect3DExecuteBuffer *ExecuteBuffer,
|
|
|
|
IDirect3DViewport *Viewport,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DExecuteBufferImpl *Direct3DExecuteBufferImpl = (IDirect3DExecuteBufferImpl *)ExecuteBuffer;
|
|
|
|
IDirect3DViewportImpl *Direct3DViewportImpl = (IDirect3DViewportImpl *)Viewport;
|
2011-04-19 00:08:00 +02:00
|
|
|
HRESULT hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, buffer %p, viewport %p, flags %#x.\n", iface, ExecuteBuffer, Viewport, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Direct3DExecuteBufferImpl)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
/* Execute... */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-19 00:08:00 +02:00
|
|
|
hr = d3d_execute_buffer_execute(Direct3DExecuteBufferImpl, This, Direct3DViewportImpl);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-04-19 00:08:00 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::AddViewport
|
|
|
|
*
|
|
|
|
* Add a Direct3DViewport to the device's viewport list. These viewports
|
|
|
|
* are wrapped to IDirect3DDevice7 viewports in viewport.c
|
|
|
|
*
|
|
|
|
* Exists in Version 1, 2 and 3. Note that IDirect3DViewport 1, 2 and 3
|
|
|
|
* are the same interfaces.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Viewport: The viewport to add
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_INVALIDPARAMS if Viewport == NULL
|
|
|
|
* D3D_OK on success
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3 *iface,
|
|
|
|
IDirect3DViewport3 *Viewport)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Viewport);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Sanity check */
|
|
|
|
if(!vp)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-19 20:05:52 +02:00
|
|
|
list_add_head(&This->viewport_list, &vp->entry);
|
2008-04-10 22:11:52 +02:00
|
|
|
vp->active_device = This; /* Viewport must be usable for Clear() after AddViewport,
|
|
|
|
so set active_device here. */
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_AddViewport(IDirect3DDevice2 *iface,
|
|
|
|
IDirect3DViewport2 *Direct3DViewport2)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport2);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_AddViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, (IDirect3DViewport3 *)vp);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_1_AddViewport(IDirect3DDevice *iface,
|
|
|
|
IDirect3DViewport *Direct3DViewport)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_AddViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, (IDirect3DViewport3 *)vp);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::DeleteViewport
|
|
|
|
*
|
|
|
|
* Deletes a Direct3DViewport from the device's viewport list.
|
|
|
|
*
|
|
|
|
* Exists in Version 1, 2 and 3. Note that all Viewport interface versions
|
|
|
|
* are equal.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Viewport: The viewport to delete
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if the viewport wasn't found in the list
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-04-19 20:05:52 +02:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 *viewport)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-04-19 20:05:52 +02:00
|
|
|
IDirect3DDeviceImpl *device = device_from_device3(iface);
|
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)viewport;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-04-19 20:05:52 +02:00
|
|
|
TRACE("iface %p, viewport %p.\n", iface, viewport);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-19 20:05:52 +02:00
|
|
|
|
|
|
|
if (vp->active_device != device)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-04-19 20:05:52 +02:00
|
|
|
WARN("Viewport %p active device is %p.\n", vp, vp->active_device);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-04-19 20:05:52 +02:00
|
|
|
vp->active_device = NULL;
|
|
|
|
list_remove(&vp->entry);
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2011-04-19 20:05:52 +02:00
|
|
|
return D3D_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2 *iface,
|
|
|
|
IDirect3DViewport2 *Direct3DViewport2)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport2);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_DeleteViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, (IDirect3DViewport3 *)vp);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_1_DeleteViewport(IDirect3DDevice *iface,
|
|
|
|
IDirect3DViewport *Direct3DViewport)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_DeleteViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, (IDirect3DViewport3 *)vp);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::NextViewport
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Returns a viewport from the viewport list, depending on the
|
2006-06-09 19:36:12 +02:00
|
|
|
* passed viewport and the flags.
|
|
|
|
*
|
|
|
|
* Exists in Version 1, 2 and 3. Note that all Viewport interface versions
|
|
|
|
* are equal.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Viewport: Viewport to use for beginning the search
|
|
|
|
* Flags: D3DNEXT_NEXT, D3DNEXT_HEAD or D3DNEXT_TAIL
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
2006-06-23 18:18:02 +02:00
|
|
|
* DDERR_INVALIDPARAMS if the flags were wrong, or Viewport was NULL
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
|
|
|
|
IDirect3DViewport3 *Viewport3,
|
|
|
|
IDirect3DViewport3 **lplpDirect3DViewport3,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport3;
|
2011-04-19 20:05:52 +02:00
|
|
|
struct list *entry;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, viewport %p, next %p, flags %#x.\n",
|
|
|
|
iface, Viewport3, lplpDirect3DViewport3, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!vp)
|
|
|
|
{
|
|
|
|
*lplpDirect3DViewport3 = NULL;
|
2006-10-06 04:57:48 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
switch (Flags)
|
|
|
|
{
|
|
|
|
case D3DNEXT_NEXT:
|
2011-04-19 20:05:52 +02:00
|
|
|
entry = list_next(&This->viewport_list, &vp->entry);
|
|
|
|
break;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
case D3DNEXT_HEAD:
|
2011-04-19 20:05:52 +02:00
|
|
|
entry = list_head(&This->viewport_list);
|
|
|
|
break;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
case D3DNEXT_TAIL:
|
2011-04-19 20:05:52 +02:00
|
|
|
entry = list_tail(&This->viewport_list);
|
|
|
|
break;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
default:
|
2011-04-19 20:05:52 +02:00
|
|
|
WARN("Invalid flags %#x.\n", Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
*lplpDirect3DViewport3 = NULL;
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2011-04-19 20:05:52 +02:00
|
|
|
if (entry)
|
|
|
|
*lplpDirect3DViewport3 = (IDirect3DViewport3 *)LIST_ENTRY(entry, IDirect3DViewportImpl, entry);
|
|
|
|
else
|
|
|
|
*lplpDirect3DViewport3 = NULL;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2 *iface,
|
|
|
|
IDirect3DViewport2 *Viewport2, IDirect3DViewport2 **lplpDirect3DViewport2, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport2;
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DViewport3 *res;
|
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p, next %p, flags %#x.\n",
|
|
|
|
iface, Viewport2, lplpDirect3DViewport2, Flags);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
hr = IDirect3DDevice3_NextViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl,
|
|
|
|
(IDirect3DViewport3 *)vp, &res, Flags);
|
2009-01-22 10:33:37 +01:00
|
|
|
*lplpDirect3DViewport2 = (IDirect3DViewport2 *)res;
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_1_NextViewport(IDirect3DDevice *iface,
|
|
|
|
IDirect3DViewport *Viewport, IDirect3DViewport **lplpDirect3DViewport, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport;
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DViewport3 *res;
|
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p, next %p, flags %#x.\n",
|
|
|
|
iface, Viewport, lplpDirect3DViewport, Flags);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
hr = IDirect3DDevice3_NextViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl,
|
|
|
|
(IDirect3DViewport3 *)vp, &res, Flags);
|
2009-01-22 10:33:37 +01:00
|
|
|
*lplpDirect3DViewport = (IDirect3DViewport *)res;
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice::Pick
|
|
|
|
*
|
|
|
|
* Executes an execute buffer without performing rendering. Instead, a
|
|
|
|
* list of primitives that intersect with (x1,y1) of the passed rectangle
|
|
|
|
* is created. IDirect3DDevice::GetPickRecords can be used to retrieve
|
|
|
|
* this list.
|
|
|
|
*
|
|
|
|
* Version 1 only
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* ExecuteBuffer: Buffer to execute
|
|
|
|
* Viewport: Viewport to use for execution
|
|
|
|
* Flags: None are defined, according to the SDK
|
|
|
|
* Rect: Specifies the coordinates to be picked. Only x1 and y2 are used,
|
|
|
|
* x2 and y2 are ignored.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_1_Pick(IDirect3DDevice *iface,
|
|
|
|
IDirect3DExecuteBuffer *ExecuteBuffer,
|
|
|
|
IDirect3DViewport *Viewport,
|
|
|
|
DWORD Flags,
|
|
|
|
D3DRECT *Rect)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, buffer %p, viewport %p, flags %#x, rect %s stub!\n",
|
|
|
|
iface, ExecuteBuffer, Viewport, Flags, wine_dbgstr_rect((RECT *)Rect));
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice::GetPickRecords
|
|
|
|
*
|
|
|
|
* Retrieves the pick records generated by IDirect3DDevice::GetPickRecords
|
|
|
|
*
|
|
|
|
* Version 1 only
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Count: Pointer to a DWORD containing the numbers of pick records to
|
|
|
|
* retrieve
|
2008-04-02 21:26:42 +02:00
|
|
|
* D3DPickRec: Address to store the resulting D3DPICKRECORD array.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_1_GetPickRecords(IDirect3DDevice *iface,
|
|
|
|
DWORD *Count,
|
|
|
|
D3DPICKRECORD *D3DPickRec)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, count %p, records %p stub!\n", iface, Count, D3DPickRec);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::EnumTextureformats
|
|
|
|
*
|
2006-07-18 00:09:09 +02:00
|
|
|
* Enumerates the supported texture formats. It has a list of all possible
|
|
|
|
* formats and calls IWineD3D::CheckDeviceFormat for each format to see if
|
|
|
|
* WineD3D supports it. If so, then it is passed to the app.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* This is for Version 7 and 3, older versions have a different
|
2006-06-09 19:36:12 +02:00
|
|
|
* callback function and their own implementation
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Callback: Callback to call for each enumerated format
|
|
|
|
* Arg: Argument to pass to the callback
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Callback == NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
|
|
|
|
LPD3DENUMPIXELFORMATSCALLBACK Callback,
|
|
|
|
void *Arg)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2008-08-27 21:03:26 +02:00
|
|
|
WINED3DDISPLAYMODE mode;
|
2008-09-27 18:35:03 +02:00
|
|
|
unsigned int i;
|
2006-07-18 00:09:09 +02:00
|
|
|
|
2010-08-23 18:28:10 +02:00
|
|
|
static const enum wined3d_format_id FormatList[] =
|
2010-08-22 23:35:37 +02:00
|
|
|
{
|
2006-07-18 00:09:09 +02:00
|
|
|
/* 32 bit */
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_B8G8R8A8_UNORM,
|
|
|
|
WINED3DFMT_B8G8R8X8_UNORM,
|
2006-07-18 00:09:09 +02:00
|
|
|
/* 24 bit */
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_B8G8R8_UNORM,
|
2006-07-18 00:09:09 +02:00
|
|
|
/* 16 Bit */
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_B5G5R5A1_UNORM,
|
|
|
|
WINED3DFMT_B4G4R4A4_UNORM,
|
|
|
|
WINED3DFMT_B5G6R5_UNORM,
|
|
|
|
WINED3DFMT_B5G5R5X1_UNORM,
|
2006-07-18 00:09:09 +02:00
|
|
|
/* 8 Bit */
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_B2G3R3_UNORM,
|
|
|
|
WINED3DFMT_P8_UINT,
|
2006-07-18 00:09:09 +02:00
|
|
|
/* FOURCC codes */
|
|
|
|
WINED3DFMT_DXT1,
|
|
|
|
WINED3DFMT_DXT3,
|
|
|
|
WINED3DFMT_DXT5,
|
|
|
|
};
|
|
|
|
|
2010-08-23 18:28:10 +02:00
|
|
|
static const enum wined3d_format_id BumpFormatList[] =
|
2010-08-22 23:35:37 +02:00
|
|
|
{
|
2009-02-19 16:59:42 +01:00
|
|
|
WINED3DFMT_R8G8_SNORM,
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_R5G5_SNORM_L6_UNORM,
|
|
|
|
WINED3DFMT_R8G8_SNORM_L8X8_UNORM,
|
2009-02-19 16:59:42 +01:00
|
|
|
WINED3DFMT_R16G16_SNORM,
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_R10G11B11_SNORM,
|
|
|
|
WINED3DFMT_R10G10B10_SNORM_A2_UNORM
|
2007-05-04 14:28:09 +02:00
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, callback %p, context %p.\n", iface, Callback, Arg);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Callback)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2008-08-27 21:03:26 +02:00
|
|
|
|
|
|
|
memset(&mode, 0, sizeof(mode));
|
|
|
|
hr = IWineD3DDevice_GetDisplayMode(This->ddraw->wineD3DDevice,
|
|
|
|
0,
|
|
|
|
&mode);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
WARN("Cannot get the current adapter format\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-08-23 18:28:10 +02:00
|
|
|
for (i = 0; i < sizeof(FormatList) / sizeof(*FormatList); ++i)
|
2006-07-18 00:09:09 +02:00
|
|
|
{
|
2011-02-01 19:39:53 +01:00
|
|
|
hr = wined3d_check_device_format(This->ddraw->wineD3D, WINED3DADAPTER_DEFAULT, WINED3DDEVTYPE_HAL,
|
|
|
|
mode.Format, 0, WINED3DRTYPE_TEXTURE, FormatList[i], SURFACE_OPENGL);
|
|
|
|
if (hr == D3D_OK)
|
2006-07-18 00:09:09 +02:00
|
|
|
{
|
|
|
|
DDPIXELFORMAT pformat;
|
|
|
|
|
|
|
|
memset(&pformat, 0, sizeof(pformat));
|
|
|
|
pformat.dwSize = sizeof(pformat);
|
|
|
|
PixelFormat_WineD3DtoDD(&pformat, FormatList[i]);
|
|
|
|
|
|
|
|
TRACE("Enumerating WineD3DFormat %d\n", FormatList[i]);
|
|
|
|
hr = Callback(&pformat, Arg);
|
|
|
|
if(hr != DDENUMRET_OK)
|
|
|
|
{
|
|
|
|
TRACE("Format enumeration cancelled by application\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-07-18 00:09:09 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-04 14:28:09 +02:00
|
|
|
|
2010-08-23 18:28:10 +02:00
|
|
|
for (i = 0; i < sizeof(BumpFormatList) / sizeof(*BumpFormatList); ++i)
|
2007-05-04 14:28:09 +02:00
|
|
|
{
|
2011-02-01 19:39:53 +01:00
|
|
|
hr = wined3d_check_device_format(This->ddraw->wineD3D, WINED3DADAPTER_DEFAULT,
|
|
|
|
WINED3DDEVTYPE_HAL, mode.Format, WINED3DUSAGE_QUERY_LEGACYBUMPMAP,
|
|
|
|
WINED3DRTYPE_TEXTURE, BumpFormatList[i], SURFACE_OPENGL);
|
|
|
|
if (hr == D3D_OK)
|
2007-05-04 14:28:09 +02:00
|
|
|
{
|
|
|
|
DDPIXELFORMAT pformat;
|
|
|
|
|
|
|
|
memset(&pformat, 0, sizeof(pformat));
|
|
|
|
pformat.dwSize = sizeof(pformat);
|
|
|
|
PixelFormat_WineD3DtoDD(&pformat, BumpFormatList[i]);
|
|
|
|
|
|
|
|
TRACE("Enumerating WineD3DFormat %d\n", BumpFormatList[i]);
|
|
|
|
hr = Callback(&pformat, Arg);
|
|
|
|
if(hr != DDENUMRET_OK)
|
|
|
|
{
|
|
|
|
TRACE("Format enumeration cancelled by application\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-05-04 14:28:09 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-07-18 00:09:09 +02:00
|
|
|
TRACE("End of enumeration\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-07-18 00:09:09 +02:00
|
|
|
return D3D_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_EnumTextureFormats_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
LPD3DENUMPIXELFORMATSCALLBACK Callback,
|
|
|
|
void *Arg)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_EnumTextureFormats(iface, Callback, Arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_EnumTextureFormats_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
LPD3DENUMPIXELFORMATSCALLBACK Callback,
|
|
|
|
void *Arg)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_EnumTextureFormats(iface, Callback, Arg);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_EnumTextureFormats(IDirect3DDevice3 *iface,
|
|
|
|
LPD3DENUMPIXELFORMATSCALLBACK Callback, void *Arg)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, callback %p, context %p.\n", iface, Callback, Arg);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_EnumTextureFormats((IDirect3DDevice7 *)This, Callback, Arg);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice2::EnumTextureformats
|
|
|
|
*
|
|
|
|
* EnumTextureFormats for Version 1 and 2, see
|
2006-07-18 00:09:09 +02:00
|
|
|
* IDirect3DDevice7::EnumTexureFormats for a more detailed description.
|
|
|
|
*
|
|
|
|
* This version has a different callback and does not enumerate FourCC
|
|
|
|
* formats
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,
|
|
|
|
LPD3DENUMTEXTUREFORMATSCALLBACK Callback,
|
|
|
|
void *Arg)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2008-09-27 18:35:03 +02:00
|
|
|
unsigned int i;
|
2008-08-27 21:03:26 +02:00
|
|
|
WINED3DDISPLAYMODE mode;
|
2006-07-18 00:09:09 +02:00
|
|
|
|
2010-08-23 18:28:10 +02:00
|
|
|
static const enum wined3d_format_id FormatList[] =
|
2010-08-22 23:35:37 +02:00
|
|
|
{
|
2006-07-18 00:09:09 +02:00
|
|
|
/* 32 bit */
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_B8G8R8A8_UNORM,
|
|
|
|
WINED3DFMT_B8G8R8X8_UNORM,
|
2006-07-18 00:09:09 +02:00
|
|
|
/* 24 bit */
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_B8G8R8_UNORM,
|
2006-07-18 00:09:09 +02:00
|
|
|
/* 16 Bit */
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_B5G5R5A1_UNORM,
|
|
|
|
WINED3DFMT_B4G4R4A4_UNORM,
|
|
|
|
WINED3DFMT_B5G6R5_UNORM,
|
|
|
|
WINED3DFMT_B5G5R5X1_UNORM,
|
2006-07-18 00:09:09 +02:00
|
|
|
/* 8 Bit */
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_B2G3R3_UNORM,
|
|
|
|
WINED3DFMT_P8_UINT,
|
2006-07-18 00:09:09 +02:00
|
|
|
/* FOURCC codes - Not in this version*/
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, callback %p, context %p.\n", iface, Callback, Arg);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2006-07-18 00:09:09 +02:00
|
|
|
if(!Callback)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2008-08-27 21:03:26 +02:00
|
|
|
|
|
|
|
memset(&mode, 0, sizeof(mode));
|
|
|
|
hr = IWineD3DDevice_GetDisplayMode(This->ddraw->wineD3DDevice,
|
|
|
|
0,
|
|
|
|
&mode);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
WARN("Cannot get the current adapter format\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-08-23 18:28:10 +02:00
|
|
|
for (i = 0; i < sizeof(FormatList) / sizeof(*FormatList); ++i)
|
2006-07-18 00:09:09 +02:00
|
|
|
{
|
2011-02-01 19:39:53 +01:00
|
|
|
hr = wined3d_check_device_format(This->ddraw->wineD3D, 0, WINED3DDEVTYPE_HAL,
|
|
|
|
mode.Format, 0, WINED3DRTYPE_TEXTURE, FormatList[i], SURFACE_OPENGL);
|
|
|
|
if (hr == D3D_OK)
|
2006-07-18 00:09:09 +02:00
|
|
|
{
|
|
|
|
DDSURFACEDESC sdesc;
|
|
|
|
|
|
|
|
memset(&sdesc, 0, sizeof(sdesc));
|
|
|
|
sdesc.dwSize = sizeof(sdesc);
|
|
|
|
sdesc.dwFlags = DDSD_PIXELFORMAT | DDSD_CAPS;
|
|
|
|
sdesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
2007-03-17 23:22:38 +01:00
|
|
|
sdesc.ddpfPixelFormat.dwSize = sizeof(sdesc.ddpfPixelFormat);
|
2006-07-18 00:09:09 +02:00
|
|
|
PixelFormat_WineD3DtoDD(&sdesc.ddpfPixelFormat, FormatList[i]);
|
|
|
|
|
|
|
|
TRACE("Enumerating WineD3DFormat %d\n", FormatList[i]);
|
|
|
|
hr = Callback(&sdesc, Arg);
|
|
|
|
if(hr != DDENUMRET_OK)
|
|
|
|
{
|
|
|
|
TRACE("Format enumeration cancelled by application\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-07-18 00:09:09 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("End of enumeration\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-07-18 00:09:09 +02:00
|
|
|
return D3D_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_1_EnumTextureFormats(IDirect3DDevice *iface,
|
|
|
|
LPD3DENUMTEXTUREFORMATSCALLBACK Callback, void *Arg)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, callback %p, context %p.\n", iface, Callback, Arg);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice2_EnumTextureFormats((IDirect3DDevice2 *)&This->IDirect3DDevice2_vtbl, Callback, Arg);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice::CreateMatrix
|
|
|
|
*
|
2006-06-21 17:05:58 +02:00
|
|
|
* Creates a matrix handle. A handle is created and memory for a D3DMATRIX is
|
|
|
|
* allocated for the handle.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Version 1 only
|
|
|
|
*
|
|
|
|
* Params
|
|
|
|
* D3DMatHandle: Address to return the handle at
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if D3DMatHandle = NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE *D3DMatHandle)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2006-06-21 17:05:58 +02:00
|
|
|
D3DMATRIX *Matrix;
|
2010-07-29 12:56:58 +02:00
|
|
|
DWORD h;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, matrix_handle %p.\n", iface, D3DMatHandle);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!D3DMatHandle)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2006-06-21 17:05:58 +02:00
|
|
|
Matrix = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D3DMATRIX));
|
|
|
|
if(!Matrix)
|
|
|
|
{
|
|
|
|
ERR("Out of memory when allocating a D3DMATRIX\n");
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
2007-06-03 18:51:50 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-29 12:56:58 +02:00
|
|
|
|
|
|
|
h = ddraw_allocate_handle(&This->handle_table, Matrix, DDRAW_HANDLE_MATRIX);
|
|
|
|
if (h == DDRAW_INVALID_HANDLE)
|
2006-06-21 17:05:58 +02:00
|
|
|
{
|
2010-07-29 12:56:58 +02:00
|
|
|
ERR("Failed to allocate a matrix handle.\n");
|
2006-06-21 17:05:58 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, Matrix);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-21 17:05:58 +02:00
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
2010-07-29 12:56:58 +02:00
|
|
|
|
|
|
|
*D3DMatHandle = h + 1;
|
|
|
|
|
2006-10-10 19:23:27 +02:00
|
|
|
TRACE(" returning matrix handle %d\n", *D3DMatHandle);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice::SetMatrix
|
|
|
|
*
|
2006-06-21 17:05:58 +02:00
|
|
|
* Sets a matrix for a matrix handle. The matrix is copied into the memory
|
|
|
|
* allocated for the handle
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Version 1 only
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* D3DMatHandle: Handle to set the matrix to
|
|
|
|
* D3DMatrix: Matrix to set
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
2006-06-21 17:05:58 +02:00
|
|
|
* DDERR_INVALIDPARAMS if the handle of the matrix is invalid or the matrix
|
|
|
|
* to set is NULL
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice *iface,
|
|
|
|
D3DMATRIXHANDLE D3DMatHandle,
|
|
|
|
D3DMATRIX *D3DMatrix)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2010-07-29 12:56:58 +02:00
|
|
|
D3DMATRIX *m;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, matrix_handle %#x, matrix %p.\n", iface, D3DMatHandle, D3DMatrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-07-29 12:56:58 +02:00
|
|
|
if (!D3DMatrix) return DDERR_INVALIDPARAMS;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-29 12:56:58 +02:00
|
|
|
|
|
|
|
m = ddraw_get_object(&This->handle_table, D3DMatHandle - 1, DDRAW_HANDLE_MATRIX);
|
|
|
|
if (!m)
|
2006-06-21 17:05:58 +02:00
|
|
|
{
|
2010-07-29 12:56:58 +02:00
|
|
|
WARN("Invalid matrix handle.\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-21 17:05:58 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
if (TRACE_ON(ddraw))
|
2006-06-09 19:36:12 +02:00
|
|
|
dump_D3DMATRIX(D3DMatrix);
|
|
|
|
|
2010-07-29 12:56:58 +02:00
|
|
|
*m = *D3DMatrix;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-07-01 23:28:21 +02:00
|
|
|
if(This->world == D3DMatHandle)
|
|
|
|
{
|
|
|
|
IWineD3DDevice_SetTransform(This->wineD3DDevice,
|
|
|
|
WINED3DTS_WORLDMATRIX(0),
|
|
|
|
(WINED3DMATRIX *) D3DMatrix);
|
|
|
|
}
|
|
|
|
if(This->view == D3DMatHandle)
|
|
|
|
{
|
|
|
|
IWineD3DDevice_SetTransform(This->wineD3DDevice,
|
|
|
|
WINED3DTS_VIEW,
|
|
|
|
(WINED3DMATRIX *) D3DMatrix);
|
|
|
|
}
|
|
|
|
if(This->proj == D3DMatHandle)
|
|
|
|
{
|
|
|
|
IWineD3DDevice_SetTransform(This->wineD3DDevice,
|
|
|
|
WINED3DTS_PROJECTION,
|
|
|
|
(WINED3DMATRIX *) D3DMatrix);
|
|
|
|
}
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2010-08-19 18:57:50 +02:00
|
|
|
* IDirect3DDevice::GetMatrix
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Returns the content of a D3DMATRIX handle
|
|
|
|
*
|
|
|
|
* Version 1 only
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* D3DMatHandle: Matrix handle to read the content from
|
|
|
|
* D3DMatrix: Address to store the content at
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
2006-06-21 17:05:58 +02:00
|
|
|
* DDERR_INVALIDPARAMS if D3DMatHandle is invalid or D3DMatrix is NULL
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_1_GetMatrix(IDirect3DDevice *iface,
|
|
|
|
D3DMATRIXHANDLE D3DMatHandle,
|
|
|
|
D3DMATRIX *D3DMatrix)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2010-07-29 12:56:58 +02:00
|
|
|
D3DMATRIX *m;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, matrix_handle %#x, matrix %p.\n", iface, D3DMatHandle, D3DMatrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-07-29 12:56:58 +02:00
|
|
|
if (!D3DMatrix) return DDERR_INVALIDPARAMS;
|
2006-06-21 17:05:58 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-29 12:56:58 +02:00
|
|
|
|
|
|
|
m = ddraw_get_object(&This->handle_table, D3DMatHandle - 1, DDRAW_HANDLE_MATRIX);
|
|
|
|
if (!m)
|
2006-06-21 17:05:58 +02:00
|
|
|
{
|
2010-07-29 12:56:58 +02:00
|
|
|
WARN("Invalid matrix handle.\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-21 17:05:58 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-07-29 12:56:58 +02:00
|
|
|
*D3DMatrix = *m;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice::DeleteMatrix
|
|
|
|
*
|
2006-06-21 17:05:58 +02:00
|
|
|
* Destroys a Matrix handle. Frees the memory and unsets the handle data
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Version 1 only
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* D3DMatHandle: Handle to destroy
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
2006-06-21 17:05:58 +02:00
|
|
|
* DDERR_INVALIDPARAMS if D3DMatHandle is invalid
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_1_DeleteMatrix(IDirect3DDevice *iface,
|
|
|
|
D3DMATRIXHANDLE D3DMatHandle)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2010-07-29 12:56:58 +02:00
|
|
|
D3DMATRIX *m;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, matrix_handle %#x.\n", iface, D3DMatHandle);
|
2006-06-21 17:05:58 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-29 12:56:58 +02:00
|
|
|
|
|
|
|
m = ddraw_free_handle(&This->handle_table, D3DMatHandle - 1, DDRAW_HANDLE_MATRIX);
|
|
|
|
if (!m)
|
2006-06-21 17:05:58 +02:00
|
|
|
{
|
2010-07-29 12:56:58 +02:00
|
|
|
WARN("Invalid matrix handle.\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-21 17:05:58 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2010-07-29 12:56:58 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, m);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::BeginScene
|
|
|
|
*
|
|
|
|
* This method must be called before any rendering is performed.
|
|
|
|
* IDirect3DDevice::EndScene has to be called after the scene is complete
|
|
|
|
*
|
|
|
|
* Version 1, 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Returns:
|
2006-06-23 18:18:02 +02:00
|
|
|
* D3D_OK on success, for details see IWineD3DDevice::BeginScene
|
2007-02-09 16:35:45 +01:00
|
|
|
* D3DERR_SCENE_IN_SCENE if WineD3D returns an error(Only in case of an already
|
|
|
|
* started scene).
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7 *iface)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-02-09 16:35:45 +01:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2007-02-09 16:35:45 +01:00
|
|
|
hr = IWineD3DDevice_BeginScene(This->wineD3DDevice);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-02-09 16:35:45 +01:00
|
|
|
if(hr == WINED3D_OK) return D3D_OK;
|
|
|
|
else return D3DERR_SCENE_IN_SCENE; /* TODO: Other possible causes of failure */
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_BeginScene_FPUSetup(IDirect3DDevice7 *iface)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_BeginScene(iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_BeginScene_FPUPreserve(IDirect3DDevice7 *iface)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_BeginScene(iface);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_BeginScene(IDirect3DDevice3 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_BeginScene((IDirect3DDevice7 *)device_from_device3(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_BeginScene(IDirect3DDevice2 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_BeginScene((IDirect3DDevice7 *)device_from_device2(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_1_BeginScene(IDirect3DDevice *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_BeginScene((IDirect3DDevice7 *)device_from_device1(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::EndScene
|
|
|
|
*
|
|
|
|
* Ends a scene that has been begun with IDirect3DDevice7::BeginScene.
|
|
|
|
* This method must be called after rendering is finished.
|
|
|
|
*
|
|
|
|
* Version 1, 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success, for details see IWineD3DDevice::EndScene
|
2007-02-09 16:35:45 +01:00
|
|
|
* D3DERR_SCENE_NOT_IN_SCENE is returned if WineD3D returns an error. It does
|
|
|
|
* that only if the scene was already ended.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7 *iface)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-02-09 16:35:45 +01:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2007-02-09 16:35:45 +01:00
|
|
|
hr = IWineD3DDevice_EndScene(This->wineD3DDevice);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-02-09 16:35:45 +01:00
|
|
|
if(hr == WINED3D_OK) return D3D_OK;
|
|
|
|
else return D3DERR_SCENE_NOT_IN_SCENE;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2009-09-13 01:25:23 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH
|
2008-06-20 01:49:46 +02:00
|
|
|
IDirect3DDeviceImpl_7_EndScene_FPUSetup(IDirect3DDevice7 *iface)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_EndScene(iface);
|
|
|
|
}
|
|
|
|
|
2009-09-13 01:25:23 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH
|
2008-06-20 01:49:46 +02:00
|
|
|
IDirect3DDeviceImpl_7_EndScene_FPUPreserve(IDirect3DDevice7 *iface)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_EndScene(iface);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_EndScene((IDirect3DDevice7 *)device_from_device3(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_EndScene((IDirect3DDevice7 *)device_from_device2(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:03:36 +01:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_EndScene((IDirect3DDevice7 *)device_from_device1(iface));
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetDirect3D
|
|
|
|
*
|
|
|
|
* Returns the IDirect3D(= interface to the DirectDraw object) used to create
|
|
|
|
* this device.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Direct3D7: Address to store the interface pointer at
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Direct3D7 == NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetDirect3D(IDirect3DDevice7 *iface,
|
|
|
|
IDirect3D7 **Direct3D7)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, d3d %p.\n", iface, Direct3D7);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Direct3D7)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-01-19 01:32:36 +01:00
|
|
|
*Direct3D7 = &This->ddraw->IDirect3D7_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3D7_AddRef(*Direct3D7);
|
|
|
|
|
|
|
|
TRACE(" returning interface %p\n", *Direct3D7);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-18 12:22:48 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3 *iface,
|
|
|
|
IDirect3D3 **Direct3D3)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, d3d %p.\n", iface, Direct3D3);
|
|
|
|
|
2011-01-18 12:22:48 +01:00
|
|
|
if(!Direct3D3)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-01-19 01:30:21 +01:00
|
|
|
IDirect3D3_AddRef(&This->ddraw->IDirect3D3_iface);
|
|
|
|
*Direct3D3 = &This->ddraw->IDirect3D3_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE(" returning interface %p\n", *Direct3D3);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-18 12:22:48 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2 *iface,
|
|
|
|
IDirect3D2 **Direct3D2)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, d3d %p.\n", iface, Direct3D2);
|
|
|
|
|
2011-01-18 12:22:48 +01:00
|
|
|
if(!Direct3D2)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-01-18 12:30:17 +01:00
|
|
|
IDirect3D2_AddRef(&This->ddraw->IDirect3D2_iface);
|
|
|
|
*Direct3D2 = &This->ddraw->IDirect3D2_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE(" returning interface %p\n", *Direct3D2);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-18 12:22:48 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice *iface,
|
|
|
|
IDirect3D **Direct3D)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device1(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, d3d %p.\n", iface, Direct3D);
|
|
|
|
|
2011-01-18 12:22:48 +01:00
|
|
|
if(!Direct3D)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-01-18 12:28:15 +01:00
|
|
|
IDirect3D_AddRef(&This->ddraw->IDirect3D_iface);
|
|
|
|
*Direct3D = &This->ddraw->IDirect3D_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE(" returning interface %p\n", *Direct3D);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::SetCurrentViewport
|
|
|
|
*
|
|
|
|
* Sets a Direct3DViewport as the current viewport.
|
|
|
|
* For the thunks note that all viewport interface versions are equal
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Direct3DViewport3: The viewport to set
|
|
|
|
*
|
|
|
|
* Version 2 and 3
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* (Is a NULL viewport valid?)
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3 *iface,
|
|
|
|
IDirect3DViewport3 *Direct3DViewport3)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport3;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport3);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Do nothing if the specified viewport is the same as the current one */
|
|
|
|
if (This->current_viewport == vp )
|
2007-06-03 18:51:50 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-04-19 00:07:59 +02:00
|
|
|
if (vp->active_device != This)
|
|
|
|
{
|
|
|
|
WARN("Viewport %p active device is %p.\n", vp, vp->active_device);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Release previous viewport and AddRef the new one */
|
|
|
|
if (This->current_viewport)
|
|
|
|
{
|
2009-01-21 09:56:13 +01:00
|
|
|
TRACE("ViewportImpl is at %p, interface is at %p\n", This->current_viewport,
|
|
|
|
(IDirect3DViewport3 *)This->current_viewport);
|
|
|
|
IDirect3DViewport3_Release((IDirect3DViewport3 *)This->current_viewport);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
IDirect3DViewport3_AddRef(Direct3DViewport3);
|
|
|
|
|
|
|
|
/* Set this viewport as the current viewport */
|
|
|
|
This->current_viewport = vp;
|
|
|
|
|
|
|
|
/* Activate this viewport */
|
2010-08-17 19:03:25 +02:00
|
|
|
viewport_activate(This->current_viewport, FALSE);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2 *iface,
|
|
|
|
IDirect3DViewport2 *Direct3DViewport2)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport2);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_SetCurrentViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl,
|
|
|
|
(IDirect3DViewport3 *)vp);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::GetCurrentViewport
|
|
|
|
*
|
|
|
|
* Returns the currently active viewport.
|
|
|
|
*
|
|
|
|
* Version 2 and 3
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Direct3DViewport3: Address to return the interface pointer at
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Direct3DViewport == NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3 *iface,
|
|
|
|
IDirect3DViewport3 **Direct3DViewport3)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport3);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Direct3DViewport3)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2009-01-21 09:56:13 +01:00
|
|
|
*Direct3DViewport3 = (IDirect3DViewport3 *)This->current_viewport;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* AddRef the returned viewport */
|
2006-06-29 14:20:39 +02:00
|
|
|
if(*Direct3DViewport3) IDirect3DViewport3_AddRef(*Direct3DViewport3);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
TRACE(" returning interface %p\n", *Direct3DViewport3);
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_GetCurrentViewport(IDirect3DDevice2 *iface,
|
|
|
|
IDirect3DViewport2 **Direct3DViewport2)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Direct3DViewport2);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
hr = IDirect3DDevice3_GetCurrentViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl,
|
|
|
|
(IDirect3DViewport3 **)Direct3DViewport2);
|
2006-06-09 19:36:12 +02:00
|
|
|
if(hr != D3D_OK) return hr;
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::SetRenderTarget
|
|
|
|
*
|
|
|
|
* Sets the render target for the Direct3DDevice.
|
|
|
|
* For the thunks note that IDirectDrawSurface7 == IDirectDrawSurface4 and
|
|
|
|
* IDirectDrawSurface3 == IDirectDrawSurface
|
|
|
|
*
|
|
|
|
* Version 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* NewTarget: Pointer to an IDirectDrawSurface7 interface to set as the new
|
|
|
|
* render target
|
|
|
|
* Flags: Some flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success, for details see IWineD3DDevice::SetRenderTarget
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7 *iface,
|
|
|
|
IDirectDrawSurface7 *NewTarget,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirectDrawSurfaceImpl *Target = (IDirectDrawSurfaceImpl *)NewTarget;
|
2007-04-24 22:30:03 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, target %p, flags %#x.\n", iface, NewTarget, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Flags: Not used */
|
|
|
|
|
2008-02-28 19:10:19 +01:00
|
|
|
if(This->target == Target)
|
|
|
|
{
|
|
|
|
TRACE("No-op SetRenderTarget operation, not doing anything\n");
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = IWineD3DDevice_SetRenderTarget(This->wineD3DDevice, 0,
|
|
|
|
Target ? Target->wined3d_surface : NULL, FALSE);
|
2007-04-24 22:30:03 +02:00
|
|
|
if(hr != D3D_OK)
|
|
|
|
{
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-04-24 22:30:03 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
IDirectDrawSurface7_AddRef(NewTarget);
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_Release((IDirectDrawSurface7 *)This->target);
|
2007-04-24 22:30:03 +02:00
|
|
|
This->target = Target;
|
|
|
|
IDirect3DDeviceImpl_UpdateDepthStencil(This);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-04-24 22:30:03 +02:00
|
|
|
return D3D_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetRenderTarget_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
IDirectDrawSurface7 *NewTarget,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_SetRenderTarget(iface, NewTarget, Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetRenderTarget_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
IDirectDrawSurface7 *NewTarget,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_SetRenderTarget(iface, NewTarget, Flags);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3 *iface,
|
|
|
|
IDirectDrawSurface4 *NewRenderTarget, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirectDrawSurfaceImpl *Target = (IDirectDrawSurfaceImpl *)NewRenderTarget;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, target %p, flags %#x.\n", iface, NewRenderTarget, Flags);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_SetRenderTarget((IDirect3DDevice7 *)This, (IDirectDrawSurface7 *)Target, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2 *iface,
|
|
|
|
IDirectDrawSurface *NewRenderTarget, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirectDrawSurfaceImpl *Target = (IDirectDrawSurfaceImpl *)NewRenderTarget;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, target %p, flags %#x.\n", iface, NewRenderTarget, Flags);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_SetRenderTarget((IDirect3DDevice7 *)This, (IDirectDrawSurface7 *)Target, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetRenderTarget
|
|
|
|
*
|
|
|
|
* Returns the current render target.
|
|
|
|
* This is handled locally, because the WineD3D render target's parent
|
|
|
|
* is an IParent
|
|
|
|
*
|
|
|
|
* Version 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* RenderTarget: Address to store the surface interface pointer
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if RenderTarget == NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetRenderTarget(IDirect3DDevice7 *iface,
|
|
|
|
IDirectDrawSurface7 **RenderTarget)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, target %p.\n", iface, RenderTarget);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!RenderTarget)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2009-01-21 09:56:13 +01:00
|
|
|
*RenderTarget = (IDirectDrawSurface7 *)This->target;
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirectDrawSurface7_AddRef(*RenderTarget);
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3 *iface,
|
|
|
|
IDirectDrawSurface4 **RenderTarget)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, target %p.\n", iface, RenderTarget);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
hr = IDirect3DDevice7_GetRenderTarget((IDirect3DDevice7 *)This, (IDirectDrawSurface7 **)RenderTarget);
|
2006-06-09 19:36:12 +02:00
|
|
|
if(hr != D3D_OK) return hr;
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_GetRenderTarget(IDirect3DDevice2 *iface,
|
|
|
|
IDirectDrawSurface **RenderTarget)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, target %p.\n", iface, RenderTarget);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
hr = IDirect3DDevice7_GetRenderTarget((IDirect3DDevice7 *)This, (IDirectDrawSurface7 **)RenderTarget);
|
2006-06-09 19:36:12 +02:00
|
|
|
if(hr != D3D_OK) return hr;
|
2009-01-22 10:33:37 +01:00
|
|
|
*RenderTarget = *RenderTarget ?
|
|
|
|
(IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)*RenderTarget)->IDirectDrawSurface3_vtbl : NULL;
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::Begin
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Begins a description block of vertices. This is similar to glBegin()
|
2006-06-09 19:36:12 +02:00
|
|
|
* and glEnd(). After a call to IDirect3DDevice3::End, the vertices
|
|
|
|
* described with IDirect3DDevice::Vertex are drawn.
|
|
|
|
*
|
|
|
|
* Version 2 and 3
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* PrimitiveType: The type of primitives to draw
|
|
|
|
* VertexTypeDesc: A flexible vertex format description of the vertices
|
|
|
|
* Flags: Some flags..
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_Begin(IDirect3DDevice3 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexTypeDesc,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, primitive_type %#x, FVF %#x, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexTypeDesc, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
This->primitive_type = PrimitiveType;
|
|
|
|
This->vertex_type = VertexTypeDesc;
|
|
|
|
This->render_flags = Flags;
|
|
|
|
This->vertex_size = get_flexible_vertex_size(This->vertex_type);
|
|
|
|
This->nb_vertices = 0;
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_Begin(IDirect3DDevice2 *iface, D3DPRIMITIVETYPE d3dpt,
|
|
|
|
D3DVERTEXTYPE dwVertexTypeDesc, DWORD dwFlags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
DWORD FVF;
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, primitive_type %#x, vertex_type %#x, flags %#x.\n",
|
|
|
|
iface, d3dpt, dwVertexTypeDesc, dwFlags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
switch(dwVertexTypeDesc)
|
|
|
|
{
|
|
|
|
case D3DVT_VERTEX: FVF = D3DFVF_VERTEX; break;
|
|
|
|
case D3DVT_LVERTEX: FVF = D3DFVF_LVERTEX; break;
|
|
|
|
case D3DVT_TLVERTEX: FVF = D3DFVF_TLVERTEX; break;
|
|
|
|
default:
|
2006-06-26 23:15:55 +02:00
|
|
|
ERR("Unexpected vertex type %d\n", dwVertexTypeDesc);
|
|
|
|
return DDERR_INVALIDPARAMS; /* Should never happen */
|
2006-06-09 19:36:12 +02:00
|
|
|
};
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_Begin((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, d3dpt, FVF, dwFlags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::BeginIndexed
|
|
|
|
*
|
|
|
|
* Draws primitives based on vertices in a vertex array which are specified
|
|
|
|
* by indices.
|
|
|
|
*
|
|
|
|
* Version 2 and 3
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* PrimitiveType: Primitive type to draw
|
|
|
|
* VertexType: A FVF description of the vertex format
|
2006-06-23 18:18:02 +02:00
|
|
|
* Vertices: pointer to an array containing the vertices
|
2006-06-09 19:36:12 +02:00
|
|
|
* NumVertices: The number of vertices in the vertex array
|
|
|
|
* Flags: Some flags ...
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_BeginIndexed(IDirect3DDevice3 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
void *Vertices,
|
|
|
|
DWORD NumVertices,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, primitive_type %#x, FVF %#x, vertices %p, vertex_count %u, flags %#x stub!\n",
|
|
|
|
iface, PrimitiveType, VertexType, Vertices, NumVertices, Flags);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_BeginIndexed(IDirect3DDevice2 *iface,
|
|
|
|
D3DPRIMITIVETYPE d3dptPrimitiveType, D3DVERTEXTYPE d3dvtVertexType,
|
|
|
|
void *lpvVertices, DWORD dwNumVertices, DWORD dwFlags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
DWORD FVF;
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, primitive_type %#x, vertex_type %#x, vertices %p, vertex_count %u, flags %#x stub!\n",
|
|
|
|
iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwNumVertices, dwFlags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
switch(d3dvtVertexType)
|
|
|
|
{
|
|
|
|
case D3DVT_VERTEX: FVF = D3DFVF_VERTEX; break;
|
|
|
|
case D3DVT_LVERTEX: FVF = D3DFVF_LVERTEX; break;
|
|
|
|
case D3DVT_TLVERTEX: FVF = D3DFVF_TLVERTEX; break;
|
|
|
|
default:
|
2006-06-26 23:15:55 +02:00
|
|
|
ERR("Unexpected vertex type %d\n", d3dvtVertexType);
|
|
|
|
return DDERR_INVALIDPARAMS; /* Should never happen */
|
2006-06-09 19:36:12 +02:00
|
|
|
};
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_BeginIndexed((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl,
|
|
|
|
d3dptPrimitiveType, FVF, lpvVertices, dwNumVertices, dwFlags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::Vertex
|
|
|
|
*
|
|
|
|
* Draws a vertex as described by IDirect3DDevice3::Begin. It places all
|
2006-06-23 18:18:02 +02:00
|
|
|
* drawn vertices in a vertex buffer. If the buffer is too small, its
|
2006-06-09 19:36:12 +02:00
|
|
|
* size is increased.
|
|
|
|
*
|
|
|
|
* Version 2 and 3
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Vertex: Pointer to the vertex
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK, on success
|
|
|
|
* DDERR_INVALIDPARAMS if Vertex is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3 *iface,
|
|
|
|
void *Vertex)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, vertex %p.\n", iface, Vertex);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Vertex)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
if ((This->nb_vertices+1)*This->vertex_size > This->buffer_size)
|
|
|
|
{
|
|
|
|
BYTE *old_buffer;
|
|
|
|
This->buffer_size = This->buffer_size ? This->buffer_size * 2 : This->vertex_size * 3;
|
|
|
|
old_buffer = This->vertex_buffer;
|
|
|
|
This->vertex_buffer = HeapAlloc(GetProcessHeap(), 0, This->buffer_size);
|
|
|
|
if (old_buffer)
|
|
|
|
{
|
|
|
|
CopyMemory(This->vertex_buffer, old_buffer, This->nb_vertices * This->vertex_size);
|
|
|
|
HeapFree(GetProcessHeap(), 0, old_buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyMemory(This->vertex_buffer + This->nb_vertices++ * This->vertex_size, Vertex, This->vertex_size);
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_Vertex(IDirect3DDevice2 *iface, void *lpVertexType)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, vertex %p.\n", iface, lpVertexType);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_Vertex((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, lpVertexType);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::Index
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Specifies an index to a vertex to be drawn. The vertex array has to
|
2006-06-09 19:36:12 +02:00
|
|
|
* be specified with BeginIndexed first.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* VertexIndex: The index of the vertex to draw
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_Index(IDirect3DDevice3 *iface,
|
|
|
|
WORD VertexIndex)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, index %#x stub!\n", iface, VertexIndex);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_Index(IDirect3DDevice2 *iface, WORD wVertexIndex)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, index %#x.\n", iface, wVertexIndex);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_Index((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, wVertexIndex);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::End
|
|
|
|
*
|
|
|
|
* Ends a draw begun with IDirect3DDevice3::Begin or
|
|
|
|
* IDirect3DDevice::BeginIndexed. The vertices specified with
|
|
|
|
* IDirect3DDevice::Vertex or IDirect3DDevice::Index are drawn using
|
|
|
|
* the IDirect3DDevice7::DrawPrimitive method. So far only
|
|
|
|
* non-indexed mode is supported
|
|
|
|
*
|
|
|
|
* Version 2 and 3
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: Some flags, as usual. Don't know which are defined
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The return value of IDirect3DDevice7::DrawPrimitive
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_End(IDirect3DDevice3 *iface,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_DrawPrimitive((IDirect3DDevice7 *)This, This->primitive_type,
|
|
|
|
This->vertex_type, This->vertex_buffer, This->nb_vertices, This->render_flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_End(IDirect3DDevice2 *iface, DWORD dwFlags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, dwFlags);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_End((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, dwFlags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetRenderState
|
|
|
|
*
|
|
|
|
* Returns the value of a render state. The possible render states are
|
|
|
|
* defined in include/d3dtypes.h
|
|
|
|
*
|
|
|
|
* Version 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* RenderStateType: Render state to return the current setting of
|
|
|
|
* Value: Address to store the value at
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success, for details see IWineD3DDevice::GetRenderState
|
|
|
|
* DDERR_INVALIDPARAMS if Value == NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-05-08 17:23:14 +02:00
|
|
|
static const float zbias_factor = -0.000005f;
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
|
|
|
|
D3DRENDERSTATETYPE RenderStateType,
|
|
|
|
DWORD *Value)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-10-15 00:01:23 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, value %p.\n", iface, RenderStateType, Value);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Value)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-10-15 00:01:23 +02:00
|
|
|
switch(RenderStateType)
|
|
|
|
{
|
2006-10-16 12:43:57 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREMAG:
|
|
|
|
{
|
|
|
|
WINED3DTEXTUREFILTERTYPE tex_mag;
|
|
|
|
|
|
|
|
hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
|
|
|
|
0, WINED3DSAMP_MAGFILTER,
|
|
|
|
&tex_mag);
|
|
|
|
|
|
|
|
switch (tex_mag)
|
|
|
|
{
|
|
|
|
case WINED3DTEXF_POINT:
|
|
|
|
*Value = D3DFILTER_NEAREST;
|
|
|
|
break;
|
|
|
|
case WINED3DTEXF_LINEAR:
|
|
|
|
*Value = D3DFILTER_LINEAR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unhandled texture mag %d !\n",tex_mag);
|
|
|
|
*Value = 0;
|
|
|
|
}
|
2007-06-03 18:51:50 +02:00
|
|
|
break;
|
2006-10-16 12:43:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_TEXTUREMIN:
|
|
|
|
{
|
|
|
|
WINED3DTEXTUREFILTERTYPE tex_min;
|
2010-04-05 21:10:17 +02:00
|
|
|
WINED3DTEXTUREFILTERTYPE tex_mip;
|
2006-10-16 12:43:57 +02:00
|
|
|
|
|
|
|
hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
|
2010-04-05 21:10:17 +02:00
|
|
|
0, WINED3DSAMP_MINFILTER, &tex_min);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
|
|
|
|
0, WINED3DSAMP_MIPFILTER, &tex_mip);
|
2006-10-16 12:43:57 +02:00
|
|
|
|
|
|
|
switch (tex_min)
|
|
|
|
{
|
|
|
|
case WINED3DTEXF_POINT:
|
2010-04-05 21:10:17 +02:00
|
|
|
switch (tex_mip)
|
|
|
|
{
|
|
|
|
case WINED3DTEXF_NONE:
|
|
|
|
*Value = D3DFILTER_NEAREST;
|
|
|
|
break;
|
|
|
|
case WINED3DTEXF_POINT:
|
|
|
|
*Value = D3DFILTER_MIPNEAREST;
|
|
|
|
break;
|
|
|
|
case WINED3DTEXF_LINEAR:
|
|
|
|
*Value = D3DFILTER_LINEARMIPNEAREST;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unhandled mip filter %#x.\n", tex_mip);
|
|
|
|
*Value = D3DFILTER_NEAREST;
|
|
|
|
break;
|
|
|
|
}
|
2006-10-16 12:43:57 +02:00
|
|
|
break;
|
|
|
|
case WINED3DTEXF_LINEAR:
|
2010-04-05 21:10:17 +02:00
|
|
|
switch (tex_mip)
|
|
|
|
{
|
|
|
|
case WINED3DTEXF_NONE:
|
|
|
|
*Value = D3DFILTER_LINEAR;
|
|
|
|
break;
|
|
|
|
case WINED3DTEXF_POINT:
|
|
|
|
*Value = D3DFILTER_MIPLINEAR;
|
|
|
|
break;
|
|
|
|
case WINED3DTEXF_LINEAR:
|
|
|
|
*Value = D3DFILTER_LINEARMIPLINEAR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unhandled mip filter %#x.\n", tex_mip);
|
|
|
|
*Value = D3DFILTER_LINEAR;
|
|
|
|
break;
|
|
|
|
}
|
2006-10-16 12:43:57 +02:00
|
|
|
break;
|
|
|
|
default:
|
2010-04-05 21:10:17 +02:00
|
|
|
ERR("Unhandled texture min filter %#x.\n",tex_min);
|
|
|
|
*Value = D3DFILTER_NEAREST;
|
|
|
|
break;
|
2006-10-16 12:43:57 +02:00
|
|
|
}
|
2007-06-03 18:51:50 +02:00
|
|
|
break;
|
2006-10-16 12:43:57 +02:00
|
|
|
}
|
|
|
|
|
2007-02-15 13:48:23 +01:00
|
|
|
case D3DRENDERSTATE_TEXTUREADDRESS:
|
2006-10-16 12:40:51 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREADDRESSU:
|
2007-06-03 18:51:50 +02:00
|
|
|
hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
|
|
|
|
0, WINED3DSAMP_ADDRESSU,
|
|
|
|
Value);
|
|
|
|
break;
|
2006-10-16 12:40:51 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREADDRESSV:
|
2007-06-03 18:51:50 +02:00
|
|
|
hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
|
|
|
|
0, WINED3DSAMP_ADDRESSV,
|
|
|
|
Value);
|
|
|
|
break;
|
2006-10-16 12:40:51 +02:00
|
|
|
|
2010-04-01 21:28:53 +02:00
|
|
|
case D3DRENDERSTATE_BORDERCOLOR:
|
|
|
|
FIXME("Unhandled render state D3DRENDERSTATE_BORDERCOLOR.\n");
|
|
|
|
hr = E_NOTIMPL;
|
|
|
|
break;
|
|
|
|
|
2010-09-02 19:25:04 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREHANDLE:
|
|
|
|
case D3DRENDERSTATE_TEXTUREMAPBLEND:
|
|
|
|
WARN("Render state %#x is invalid in d3d7.\n", RenderStateType);
|
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
break;
|
|
|
|
|
2011-04-21 22:36:11 +02:00
|
|
|
case D3DRENDERSTATE_ZBIAS:
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
DWORD d;
|
|
|
|
float f;
|
|
|
|
} wined3d_value;
|
|
|
|
|
|
|
|
hr = IWineD3DDevice_GetRenderState(This->wineD3DDevice,
|
|
|
|
WINED3DRS_DEPTHBIAS,
|
|
|
|
&wined3d_value.d);
|
2011-05-08 17:23:14 +02:00
|
|
|
if (SUCCEEDED(hr)) *Value = wined3d_value.f / zbias_factor;
|
2011-05-01 15:37:51 +02:00
|
|
|
break;
|
2011-04-21 22:36:11 +02:00
|
|
|
}
|
|
|
|
|
2006-10-15 00:01:23 +02:00
|
|
|
default:
|
2010-04-01 21:28:54 +02:00
|
|
|
if (RenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00
|
|
|
|
&& RenderStateType <= D3DRENDERSTATE_STIPPLEPATTERN31)
|
|
|
|
{
|
|
|
|
FIXME("Unhandled stipple pattern render state (%#x).\n",
|
|
|
|
RenderStateType);
|
|
|
|
hr = E_NOTIMPL;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-03 18:51:50 +02:00
|
|
|
hr = IWineD3DDevice_GetRenderState(This->wineD3DDevice,
|
|
|
|
RenderStateType,
|
|
|
|
Value);
|
2006-10-15 00:01:23 +02:00
|
|
|
}
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetRenderState_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DRENDERSTATETYPE RenderStateType,
|
|
|
|
DWORD *Value)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_GetRenderState(iface, RenderStateType, Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetRenderState_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DRENDERSTATETYPE RenderStateType,
|
|
|
|
DWORD *Value)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetRenderState(iface, RenderStateType, Value);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
static HRESULT WINAPI
|
2008-05-04 14:05:02 +02:00
|
|
|
IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
|
|
|
|
D3DRENDERSTATETYPE dwRenderStateType,
|
|
|
|
DWORD *lpdwRenderState)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2008-05-04 14:05:02 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, value %p.\n", iface, dwRenderStateType, lpdwRenderState);
|
2008-05-04 14:05:02 +02:00
|
|
|
|
|
|
|
switch(dwRenderStateType)
|
|
|
|
{
|
|
|
|
case D3DRENDERSTATE_TEXTUREHANDLE:
|
|
|
|
{
|
|
|
|
/* This state is wrapped to SetTexture in SetRenderState, so
|
2011-03-18 19:10:59 +01:00
|
|
|
* it has to be wrapped to GetTexture here. */
|
|
|
|
struct wined3d_texture *tex = NULL;
|
2008-05-04 14:05:02 +02:00
|
|
|
*lpdwRenderState = 0;
|
|
|
|
|
2008-05-10 23:19:43 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
|
2010-08-31 18:41:40 +02:00
|
|
|
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex);
|
|
|
|
if (SUCCEEDED(hr) && tex)
|
2008-05-04 14:05:02 +02:00
|
|
|
{
|
2010-08-31 18:41:40 +02:00
|
|
|
/* The parent of the texture is the IDirectDrawSurface7
|
|
|
|
* interface of the ddraw surface. */
|
2011-03-18 19:10:59 +01:00
|
|
|
IDirectDrawSurfaceImpl *parent = wined3d_texture_get_parent(tex);
|
2010-08-31 18:41:40 +02:00
|
|
|
if (parent) *lpdwRenderState = parent->Handle;
|
2011-03-18 19:10:59 +01:00
|
|
|
wined3d_texture_decref(tex);
|
2008-05-04 14:05:02 +02:00
|
|
|
}
|
|
|
|
|
2008-05-10 23:19:43 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
|
2008-05-04 14:05:02 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-01-21 05:17:54 +01:00
|
|
|
case D3DRENDERSTATE_TEXTUREMAPBLEND:
|
|
|
|
{
|
2008-05-10 23:19:43 +02:00
|
|
|
/* D3DRENDERSTATE_TEXTUREMAPBLEND is mapped to texture state stages in SetRenderState; reverse
|
|
|
|
the mapping to get the value. */
|
2008-01-21 05:17:54 +01:00
|
|
|
DWORD colorop, colorarg1, colorarg2;
|
|
|
|
DWORD alphaop, alphaarg1, alphaarg2;
|
|
|
|
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
|
2008-05-05 19:09:40 +02:00
|
|
|
This->legacyTextureBlending = TRUE;
|
|
|
|
|
2008-01-21 05:17:54 +01:00
|
|
|
IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, &colorop);
|
|
|
|
IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, &colorarg1);
|
|
|
|
IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, &colorarg2);
|
|
|
|
IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, &alphaop);
|
|
|
|
IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, &alphaarg1);
|
|
|
|
IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, &alphaarg2);
|
|
|
|
|
|
|
|
if (colorop == WINED3DTOP_SELECTARG1 && colorarg1 == WINED3DTA_TEXTURE &&
|
|
|
|
alphaop == WINED3DTOP_SELECTARG1 && alphaarg1 == WINED3DTA_TEXTURE)
|
|
|
|
{
|
|
|
|
*lpdwRenderState = D3DTBLEND_DECAL;
|
|
|
|
}
|
|
|
|
else if (colorop == WINED3DTOP_SELECTARG1 && colorarg1 == WINED3DTA_TEXTURE &&
|
|
|
|
alphaop == WINED3DTOP_MODULATE && alphaarg1 == WINED3DTA_TEXTURE && alphaarg2 == WINED3DTA_CURRENT)
|
|
|
|
{
|
|
|
|
*lpdwRenderState = D3DTBLEND_DECALALPHA;
|
|
|
|
}
|
|
|
|
else if (colorop == WINED3DTOP_MODULATE && colorarg1 == WINED3DTA_TEXTURE && colorarg2 == WINED3DTA_CURRENT &&
|
|
|
|
alphaop == WINED3DTOP_MODULATE && alphaarg1 == WINED3DTA_TEXTURE && alphaarg2 == WINED3DTA_CURRENT)
|
|
|
|
{
|
|
|
|
*lpdwRenderState = D3DTBLEND_MODULATEALPHA;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-18 19:10:59 +01:00
|
|
|
struct wined3d_texture *tex = NULL;
|
2008-01-21 05:17:54 +01:00
|
|
|
HRESULT hr;
|
|
|
|
BOOL tex_alpha = FALSE;
|
|
|
|
DDPIXELFORMAT ddfmt;
|
|
|
|
|
2011-03-09 19:16:17 +01:00
|
|
|
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex);
|
2008-01-21 05:17:54 +01:00
|
|
|
|
|
|
|
if(hr == WINED3D_OK && tex)
|
|
|
|
{
|
2011-03-09 19:16:17 +01:00
|
|
|
struct wined3d_resource *sub_resource;
|
|
|
|
|
2011-03-18 19:10:59 +01:00
|
|
|
if ((sub_resource = wined3d_texture_get_sub_resource(tex, 0)))
|
2008-01-21 05:17:54 +01:00
|
|
|
{
|
2011-03-09 19:16:17 +01:00
|
|
|
struct wined3d_resource_desc desc;
|
|
|
|
|
|
|
|
wined3d_resource_get_desc(sub_resource, &desc);
|
2008-01-21 05:17:54 +01:00
|
|
|
ddfmt.dwSize = sizeof(ddfmt);
|
2009-06-15 09:06:50 +02:00
|
|
|
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
|
2008-01-21 05:17:54 +01:00
|
|
|
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
|
|
|
|
}
|
|
|
|
|
2011-03-18 19:10:59 +01:00
|
|
|
wined3d_texture_decref(tex);
|
2008-01-21 05:17:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(colorop == WINED3DTOP_MODULATE && colorarg1 == WINED3DTA_TEXTURE && colorarg2 == WINED3DTA_CURRENT &&
|
2010-02-15 09:48:38 +01:00
|
|
|
alphaop == (tex_alpha ? WINED3DTOP_SELECTARG1 : WINED3DTOP_SELECTARG2) &&
|
|
|
|
alphaarg1 == WINED3DTA_TEXTURE && alphaarg2 == WINED3DTA_CURRENT))
|
2008-01-21 05:17:54 +01:00
|
|
|
{
|
|
|
|
ERR("Unexpected texture stage state setup, returning D3DTBLEND_MODULATE - likely erroneous\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
*lpdwRenderState = D3DTBLEND_MODULATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_GetRenderState((IDirect3DDevice7 *)This, dwRenderStateType, lpdwRenderState);
|
2008-01-21 05:17:54 +01:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_GetRenderState(IDirect3DDevice2 *iface,
|
|
|
|
D3DRENDERSTATETYPE dwRenderStateType, DWORD *lpdwRenderState)
|
2008-05-05 19:09:40 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, value %p.\n", iface, dwRenderStateType, lpdwRenderState);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_GetRenderState((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl,
|
|
|
|
dwRenderStateType, lpdwRenderState);
|
2008-05-05 19:09:40 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::SetRenderState
|
|
|
|
*
|
|
|
|
* Sets a render state. The possible render states are defined in
|
|
|
|
* include/d3dtypes.h
|
|
|
|
*
|
|
|
|
* Version 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* RenderStateType: State to set
|
|
|
|
* Value: Value to assign to that state
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success,
|
|
|
|
* for details see IWineD3DDevice::SetRenderState
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
|
|
|
|
D3DRENDERSTATETYPE RenderStateType,
|
|
|
|
DWORD Value)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, value %#x.\n", iface, RenderStateType, Value);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Some render states need special care */
|
|
|
|
switch(RenderStateType)
|
|
|
|
{
|
2010-04-05 21:10:17 +02:00
|
|
|
/*
|
|
|
|
* The ddraw texture filter mapping works like this:
|
|
|
|
* D3DFILTER_NEAREST Point min/mag, no mip
|
|
|
|
* D3DFILTER_MIPNEAREST Point min/mag, point mip
|
|
|
|
* D3DFILTER_LINEARMIPNEAREST: Point min/mag, linear mip
|
|
|
|
*
|
|
|
|
* D3DFILTER_LINEAR Linear min/mag, no mip
|
|
|
|
* D3DFILTER_MIPLINEAR Linear min/mag, point mip
|
|
|
|
* D3DFILTER_LINEARMIPLINEAR Linear min/mag, linear mip
|
|
|
|
*
|
|
|
|
* This is the opposite of the GL naming convention,
|
|
|
|
* D3DFILTER_LINEARMIPNEAREST corresponds to GL_NEAREST_MIPMAP_LINEAR.
|
|
|
|
*/
|
2006-06-09 19:36:12 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREMAG:
|
|
|
|
{
|
2010-04-05 21:10:17 +02:00
|
|
|
WINED3DTEXTUREFILTERTYPE tex_mag;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-04-05 21:10:17 +02:00
|
|
|
switch (Value)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
case D3DFILTER_NEAREST:
|
2010-04-05 21:10:17 +02:00
|
|
|
case D3DFILTER_MIPNEAREST:
|
2007-02-15 13:49:34 +01:00
|
|
|
case D3DFILTER_LINEARMIPNEAREST:
|
2006-06-09 19:36:12 +02:00
|
|
|
tex_mag = WINED3DTEXF_POINT;
|
|
|
|
break;
|
|
|
|
case D3DFILTER_LINEAR:
|
2010-04-05 21:10:17 +02:00
|
|
|
case D3DFILTER_MIPLINEAR:
|
2007-02-15 13:49:34 +01:00
|
|
|
case D3DFILTER_LINEARMIPLINEAR:
|
2006-06-09 19:36:12 +02:00
|
|
|
tex_mag = WINED3DTEXF_LINEAR;
|
|
|
|
break;
|
|
|
|
default:
|
2010-04-05 21:10:17 +02:00
|
|
|
tex_mag = WINED3DTEXF_POINT;
|
2006-10-10 19:23:27 +02:00
|
|
|
ERR("Unhandled texture mag %d !\n",Value);
|
2010-04-05 21:10:17 +02:00
|
|
|
break;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
|
|
|
|
0, WINED3DSAMP_MAGFILTER,
|
|
|
|
tex_mag);
|
|
|
|
break;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_TEXTUREMIN:
|
|
|
|
{
|
2010-04-05 21:10:17 +02:00
|
|
|
WINED3DTEXTUREFILTERTYPE tex_min;
|
|
|
|
WINED3DTEXTUREFILTERTYPE tex_mip;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
switch ((D3DTEXTUREFILTER) Value)
|
|
|
|
{
|
|
|
|
case D3DFILTER_NEAREST:
|
|
|
|
tex_min = WINED3DTEXF_POINT;
|
2010-04-05 21:10:17 +02:00
|
|
|
tex_mip = WINED3DTEXF_NONE;
|
2006-06-09 19:36:12 +02:00
|
|
|
break;
|
|
|
|
case D3DFILTER_LINEAR:
|
|
|
|
tex_min = WINED3DTEXF_LINEAR;
|
2010-04-05 21:10:17 +02:00
|
|
|
tex_mip = WINED3DTEXF_NONE;
|
2006-06-09 19:36:12 +02:00
|
|
|
break;
|
2007-02-15 13:53:08 +01:00
|
|
|
case D3DFILTER_MIPNEAREST:
|
2009-08-05 09:01:03 +02:00
|
|
|
tex_min = WINED3DTEXF_POINT;
|
2007-02-15 13:53:08 +01:00
|
|
|
tex_mip = WINED3DTEXF_POINT;
|
|
|
|
break;
|
|
|
|
case D3DFILTER_MIPLINEAR:
|
2010-04-05 21:10:17 +02:00
|
|
|
tex_min = WINED3DTEXF_LINEAR;
|
|
|
|
tex_mip = WINED3DTEXF_POINT;
|
2007-02-15 13:53:08 +01:00
|
|
|
break;
|
|
|
|
case D3DFILTER_LINEARMIPNEAREST:
|
|
|
|
tex_min = WINED3DTEXF_POINT;
|
|
|
|
tex_mip = WINED3DTEXF_LINEAR;
|
|
|
|
break;
|
|
|
|
case D3DFILTER_LINEARMIPLINEAR:
|
|
|
|
tex_min = WINED3DTEXF_LINEAR;
|
|
|
|
tex_mip = WINED3DTEXF_LINEAR;
|
|
|
|
break;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
default:
|
2007-02-15 13:53:08 +01:00
|
|
|
ERR("Unhandled texture min %d !\n",Value);
|
2010-04-05 21:10:17 +02:00
|
|
|
tex_min = WINED3DTEXF_POINT;
|
|
|
|
tex_mip = WINED3DTEXF_NONE;
|
|
|
|
break;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2010-04-05 21:10:17 +02:00
|
|
|
IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
|
|
|
|
0, WINED3DSAMP_MIPFILTER, tex_mip);
|
2007-06-03 18:51:50 +02:00
|
|
|
hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
|
|
|
|
0, WINED3DSAMP_MINFILTER,
|
|
|
|
tex_min);
|
|
|
|
break;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2007-02-15 13:48:23 +01:00
|
|
|
case D3DRENDERSTATE_TEXTUREADDRESS:
|
|
|
|
IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
|
|
|
|
0, WINED3DSAMP_ADDRESSV,
|
|
|
|
Value);
|
|
|
|
/* Drop through */
|
2006-06-09 19:36:12 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREADDRESSU:
|
2007-06-03 18:51:50 +02:00
|
|
|
hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
|
|
|
|
0, WINED3DSAMP_ADDRESSU,
|
|
|
|
Value);
|
|
|
|
break;
|
2006-06-09 19:36:12 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREADDRESSV:
|
2007-06-03 18:51:50 +02:00
|
|
|
hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
|
|
|
|
0, WINED3DSAMP_ADDRESSV,
|
|
|
|
Value);
|
|
|
|
break;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-04-01 21:28:53 +02:00
|
|
|
case D3DRENDERSTATE_BORDERCOLOR:
|
|
|
|
/* This should probably just forward to the corresponding sampler
|
|
|
|
* state. Needs tests. */
|
|
|
|
FIXME("Unhandled render state D3DRENDERSTATE_BORDERCOLOR.\n");
|
|
|
|
hr = E_NOTIMPL;
|
|
|
|
break;
|
|
|
|
|
2010-09-02 19:25:04 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREHANDLE:
|
|
|
|
case D3DRENDERSTATE_TEXTUREMAPBLEND:
|
|
|
|
WARN("Render state %#x is invalid in d3d7.\n", RenderStateType);
|
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
break;
|
|
|
|
|
2011-04-21 22:36:11 +02:00
|
|
|
case D3DRENDERSTATE_ZBIAS:
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
DWORD d;
|
|
|
|
float f;
|
|
|
|
} wined3d_value;
|
2011-05-08 17:23:14 +02:00
|
|
|
wined3d_value.f = Value * zbias_factor;
|
2011-04-21 22:36:11 +02:00
|
|
|
hr = IWineD3DDevice_SetRenderState(This->wineD3DDevice,
|
|
|
|
WINED3DRS_DEPTHBIAS,
|
|
|
|
wined3d_value.d);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-01-21 05:17:54 +01:00
|
|
|
default:
|
2010-04-01 21:28:54 +02:00
|
|
|
if (RenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00
|
|
|
|
&& RenderStateType <= D3DRENDERSTATE_STIPPLEPATTERN31)
|
|
|
|
{
|
|
|
|
FIXME("Unhandled stipple pattern render state (%#x).\n",
|
|
|
|
RenderStateType);
|
|
|
|
hr = E_NOTIMPL;
|
|
|
|
break;
|
|
|
|
}
|
2008-01-21 05:17:54 +01:00
|
|
|
|
|
|
|
hr = IWineD3DDevice_SetRenderState(This->wineD3DDevice,
|
|
|
|
RenderStateType,
|
|
|
|
Value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetRenderState_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DRENDERSTATETYPE RenderStateType,
|
|
|
|
DWORD Value)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_SetRenderState(iface, RenderStateType, Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetRenderState_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DRENDERSTATETYPE RenderStateType,
|
|
|
|
DWORD Value)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_SetRenderState(iface, RenderStateType, Value);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-01-21 05:17:54 +01:00
|
|
|
static HRESULT WINAPI
|
2008-05-04 14:05:02 +02:00
|
|
|
IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
|
|
|
|
D3DRENDERSTATETYPE RenderStateType,
|
|
|
|
DWORD Value)
|
2008-01-21 05:17:54 +01:00
|
|
|
{
|
2008-05-05 19:09:40 +02:00
|
|
|
/* Note about D3DRENDERSTATE_TEXTUREMAPBLEND implementation: most of values
|
|
|
|
for this state can be directly mapped to texture stage colorop and alphaop, but
|
|
|
|
D3DTBLEND_MODULATE is tricky: it uses alpha from texture when available and alpha
|
|
|
|
from diffuse otherwise. So changing the texture must be monitored in SetTexture to modify
|
|
|
|
alphaarg when needed.
|
|
|
|
|
|
|
|
Aliens vs Predator 1 depends on accurate D3DTBLEND_MODULATE emulation
|
|
|
|
|
|
|
|
Legacy texture blending (TEXTUREMAPBLEND) and texture stage states: directx6 docs state that
|
|
|
|
TEXTUREMAPBLEND is deprecated, yet can still be used. Games must not use both or results
|
|
|
|
are undefined. D3DTBLEND_MODULATE mode in particular is dependent on texture pixel format and
|
|
|
|
requires fixup of stage 0 texture states when texture changes, but this fixup can interfere
|
|
|
|
with games not using this deprecated state. So a flag 'legacyTextureBlending' has to be kept
|
|
|
|
in device - TRUE if the app is using TEXTUREMAPBLEND.
|
|
|
|
|
|
|
|
Tests show that setting TEXTUREMAPBLEND on native doesn't seem to change values returned by
|
|
|
|
GetTextureStageState and vice versa. Not so on Wine, but it is 'undefined' anyway so, probably, ok,
|
|
|
|
unless some broken game will be found that cares. */
|
|
|
|
|
2008-05-04 14:05:02 +02:00
|
|
|
HRESULT hr;
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, value %#x.\n", iface, RenderStateType, Value);
|
2008-05-04 14:05:02 +02:00
|
|
|
|
2008-05-10 23:19:43 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
|
2008-05-04 14:05:02 +02:00
|
|
|
switch(RenderStateType)
|
|
|
|
{
|
|
|
|
case D3DRENDERSTATE_TEXTUREHANDLE:
|
|
|
|
{
|
2010-07-30 10:15:24 +02:00
|
|
|
IDirectDrawSurfaceImpl *surf;
|
|
|
|
|
2008-05-04 14:05:02 +02:00
|
|
|
if(Value == 0)
|
|
|
|
{
|
|
|
|
hr = IWineD3DDevice_SetTexture(This->wineD3DDevice,
|
|
|
|
0,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-07-30 10:15:24 +02:00
|
|
|
surf = ddraw_get_object(&This->handle_table, Value - 1, DDRAW_HANDLE_SURFACE);
|
|
|
|
if (!surf)
|
2008-05-04 14:05:02 +02:00
|
|
|
{
|
2010-07-30 10:15:24 +02:00
|
|
|
WARN("Invalid texture handle.\n");
|
2008-05-04 14:05:02 +02:00
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
break;
|
|
|
|
}
|
2010-07-30 10:15:24 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDevice3_SetTexture(iface, 0, (IDirect3DTexture2 *)&surf->IDirect3DTexture2_vtbl);
|
|
|
|
break;
|
2008-05-04 14:05:02 +02:00
|
|
|
}
|
|
|
|
|
2006-08-09 19:30:57 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREMAPBLEND:
|
|
|
|
{
|
2008-05-05 19:09:40 +02:00
|
|
|
This->legacyTextureBlending = TRUE;
|
|
|
|
|
2006-08-09 19:30:57 +02:00
|
|
|
switch ( (D3DTEXTUREBLEND) Value)
|
|
|
|
{
|
|
|
|
case D3DTBLEND_MODULATE:
|
2008-01-21 05:17:54 +01:00
|
|
|
{
|
2011-03-18 19:10:59 +01:00
|
|
|
struct wined3d_texture *tex = NULL;
|
2008-01-21 05:17:54 +01:00
|
|
|
BOOL tex_alpha = FALSE;
|
|
|
|
DDPIXELFORMAT ddfmt;
|
|
|
|
|
2011-03-09 19:16:17 +01:00
|
|
|
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex);
|
2008-01-21 05:17:54 +01:00
|
|
|
|
|
|
|
if(hr == WINED3D_OK && tex)
|
|
|
|
{
|
2011-03-09 19:16:17 +01:00
|
|
|
struct wined3d_resource *sub_resource;
|
|
|
|
|
2011-03-18 19:10:59 +01:00
|
|
|
if ((sub_resource = wined3d_texture_get_sub_resource(tex, 0)))
|
2008-01-21 05:17:54 +01:00
|
|
|
{
|
2011-03-09 19:16:17 +01:00
|
|
|
struct wined3d_resource_desc desc;
|
|
|
|
|
|
|
|
wined3d_resource_get_desc(sub_resource, &desc);
|
2008-01-21 05:17:54 +01:00
|
|
|
ddfmt.dwSize = sizeof(ddfmt);
|
2009-06-15 09:06:50 +02:00
|
|
|
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
|
2008-01-21 05:17:54 +01:00
|
|
|
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
|
|
|
|
}
|
|
|
|
|
2011-03-18 19:10:59 +01:00
|
|
|
wined3d_texture_decref(tex);
|
2008-01-21 05:17:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tex_alpha)
|
2010-02-15 09:48:38 +01:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
|
2008-01-21 05:17:54 +01:00
|
|
|
else
|
2010-02-15 09:48:38 +01:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
|
2006-12-01 00:15:18 +01:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE);
|
2008-01-21 05:17:54 +01:00
|
|
|
|
2006-08-09 19:30:57 +02:00
|
|
|
break;
|
2008-01-21 05:17:54 +01:00
|
|
|
}
|
2006-08-09 19:30:57 +02:00
|
|
|
|
2008-05-05 00:06:00 +02:00
|
|
|
case D3DTBLEND_ADD:
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_ADD);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
|
|
|
|
break;
|
|
|
|
|
2006-08-09 19:30:57 +02:00
|
|
|
case D3DTBLEND_MODULATEALPHA:
|
2006-12-01 00:15:18 +01:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_MODULATE);
|
2006-08-09 19:30:57 +02:00
|
|
|
break;
|
|
|
|
|
2008-05-05 00:06:00 +02:00
|
|
|
case D3DTBLEND_COPY:
|
2006-08-09 19:30:57 +02:00
|
|
|
case D3DTBLEND_DECAL:
|
2006-12-01 00:15:18 +01:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_SELECTARG1);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
|
2006-08-09 19:30:57 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DTBLEND_DECALALPHA:
|
2008-05-05 00:06:00 +02:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_BLENDTEXTUREALPHA);
|
2006-12-01 00:15:18 +01:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
|
2008-05-05 00:06:00 +02:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
|
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
|
2006-12-01 00:15:18 +01:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
|
2006-08-09 19:30:57 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2006-10-10 19:23:27 +02:00
|
|
|
ERR("Unhandled texture environment %d !\n",Value);
|
2008-01-21 05:17:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = D3D_OK;
|
2006-08-09 19:30:57 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-01-21 05:17:54 +01:00
|
|
|
default:
|
2009-01-21 09:56:13 +01:00
|
|
|
hr = IDirect3DDevice7_SetRenderState((IDirect3DDevice7 *)This, RenderStateType, Value);
|
2008-01-21 05:17:54 +01:00
|
|
|
break;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2008-05-10 23:19:43 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
|
2008-01-21 05:17:54 +01:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_SetRenderState(IDirect3DDevice2 *iface,
|
|
|
|
D3DRENDERSTATETYPE RenderStateType, DWORD Value)
|
2008-05-05 19:09:40 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, value %#x.\n", iface, RenderStateType, Value);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_SetRenderState((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, RenderStateType, Value);
|
2008-05-05 19:09:40 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* Direct3DDevice3::SetLightState
|
|
|
|
*
|
|
|
|
* Sets a light state for Direct3DDevice3 and Direct3DDevice2. The
|
|
|
|
* light states are forwarded to Direct3DDevice7 render states
|
|
|
|
*
|
|
|
|
* Version 2 and 3
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* LightStateType: The light state to change
|
|
|
|
* Value: The value to assign to that light state
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
2006-06-23 18:18:02 +02:00
|
|
|
* DDERR_INVALIDPARAMS if the parameters were incorrect
|
2006-06-09 19:36:12 +02:00
|
|
|
* Also check IDirect3DDevice7::SetRenderState
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
|
|
|
|
D3DLIGHTSTATETYPE LightStateType,
|
|
|
|
DWORD Value)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, state %#x, value %#x.\n", iface, LightStateType, Value);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2009-06-19 19:07:42 +02:00
|
|
|
if (!LightStateType || (LightStateType > D3DLIGHTSTATE_COLORVERTEX))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
TRACE("Unexpected Light State Type\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
if (LightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */)
|
|
|
|
{
|
2010-07-29 12:56:57 +02:00
|
|
|
IDirect3DMaterialImpl *m = ddraw_get_object(&This->handle_table, Value - 1, DDRAW_HANDLE_MATERIAL);
|
|
|
|
if (!m)
|
2006-06-29 14:20:39 +02:00
|
|
|
{
|
2010-07-29 12:56:57 +02:00
|
|
|
WARN("Invalid material handle.\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-29 14:20:39 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-07-29 12:56:57 +02:00
|
|
|
TRACE(" activating material %p.\n", m);
|
2010-08-17 19:03:24 +02:00
|
|
|
material_activate(m);
|
2010-07-29 12:56:57 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
This->material = Value;
|
|
|
|
}
|
|
|
|
else if (LightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */)
|
|
|
|
{
|
|
|
|
switch (Value)
|
|
|
|
{
|
|
|
|
case D3DCOLOR_MONO:
|
|
|
|
ERR("DDCOLOR_MONO should not happen!\n");
|
|
|
|
break;
|
|
|
|
case D3DCOLOR_RGB:
|
|
|
|
/* We are already in this mode */
|
|
|
|
TRACE("Setting color model to RGB (no-op).\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown color model!\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
D3DRENDERSTATETYPE rs;
|
|
|
|
switch (LightStateType)
|
|
|
|
{
|
|
|
|
case D3DLIGHTSTATE_AMBIENT: /* 2 */
|
|
|
|
rs = D3DRENDERSTATE_AMBIENT;
|
2010-09-08 11:24:49 +02:00
|
|
|
break;
|
2006-06-09 19:36:12 +02:00
|
|
|
case D3DLIGHTSTATE_FOGMODE: /* 4 */
|
|
|
|
rs = D3DRENDERSTATE_FOGVERTEXMODE;
|
|
|
|
break;
|
|
|
|
case D3DLIGHTSTATE_FOGSTART: /* 5 */
|
|
|
|
rs = D3DRENDERSTATE_FOGSTART;
|
|
|
|
break;
|
|
|
|
case D3DLIGHTSTATE_FOGEND: /* 6 */
|
|
|
|
rs = D3DRENDERSTATE_FOGEND;
|
|
|
|
break;
|
|
|
|
case D3DLIGHTSTATE_FOGDENSITY: /* 7 */
|
|
|
|
rs = D3DRENDERSTATE_FOGDENSITY;
|
|
|
|
break;
|
|
|
|
case D3DLIGHTSTATE_COLORVERTEX: /* 8 */
|
|
|
|
rs = D3DRENDERSTATE_COLORVERTEX;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
hr = IDirect3DDevice7_SetRenderState((IDirect3DDevice7 *)This, rs, Value);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_SetLightState(IDirect3DDevice2 *iface,
|
|
|
|
D3DLIGHTSTATETYPE LightStateType, DWORD Value)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, value %#x.\n", iface, LightStateType, Value);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_SetLightState((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, LightStateType, Value);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice3::GetLightState
|
|
|
|
*
|
|
|
|
* Returns the current setting of a light state. The state is read from
|
|
|
|
* the Direct3DDevice7 render state.
|
|
|
|
*
|
|
|
|
* Version 2 and 3
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* LightStateType: The light state to return
|
|
|
|
* Value: The address to store the light state setting at
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDDERR_INVALIDPARAMS if the parameters were incorrect
|
|
|
|
* Also see IDirect3DDevice7::GetRenderState
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3 *iface,
|
|
|
|
D3DLIGHTSTATETYPE LightStateType,
|
|
|
|
DWORD *Value)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, state %#x, value %p.\n", iface, LightStateType, Value);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2009-06-19 19:07:42 +02:00
|
|
|
if (!LightStateType || (LightStateType > D3DLIGHTSTATE_COLORVERTEX))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
TRACE("Unexpected Light State Type\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!Value)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
if (LightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */)
|
|
|
|
{
|
|
|
|
*Value = This->material;
|
|
|
|
}
|
|
|
|
else if (LightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */)
|
|
|
|
{
|
|
|
|
*Value = D3DCOLOR_RGB;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
D3DRENDERSTATETYPE rs;
|
|
|
|
switch (LightStateType)
|
|
|
|
{
|
|
|
|
case D3DLIGHTSTATE_AMBIENT: /* 2 */
|
|
|
|
rs = D3DRENDERSTATE_AMBIENT;
|
2010-09-08 11:24:49 +02:00
|
|
|
break;
|
2006-06-09 19:36:12 +02:00
|
|
|
case D3DLIGHTSTATE_FOGMODE: /* 4 */
|
|
|
|
rs = D3DRENDERSTATE_FOGVERTEXMODE;
|
|
|
|
break;
|
|
|
|
case D3DLIGHTSTATE_FOGSTART: /* 5 */
|
|
|
|
rs = D3DRENDERSTATE_FOGSTART;
|
|
|
|
break;
|
|
|
|
case D3DLIGHTSTATE_FOGEND: /* 6 */
|
|
|
|
rs = D3DRENDERSTATE_FOGEND;
|
|
|
|
break;
|
|
|
|
case D3DLIGHTSTATE_FOGDENSITY: /* 7 */
|
|
|
|
rs = D3DRENDERSTATE_FOGDENSITY;
|
|
|
|
break;
|
|
|
|
case D3DLIGHTSTATE_COLORVERTEX: /* 8 */
|
|
|
|
rs = D3DRENDERSTATE_COLORVERTEX;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown D3DLIGHTSTATETYPE %d.\n", LightStateType);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
hr = IDirect3DDevice7_GetRenderState((IDirect3DDevice7 *)This, rs, Value);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_GetLightState(IDirect3DDevice2 *iface,
|
|
|
|
D3DLIGHTSTATETYPE LightStateType, DWORD *Value)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, value %p.\n", iface, LightStateType, Value);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice3_GetLightState((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, LightStateType, Value);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::SetTransform
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Assigns a D3DMATRIX to a transform type. The transform types are defined
|
2006-06-09 19:36:12 +02:00
|
|
|
* in include/d3dtypes.h.
|
|
|
|
* The D3DTRANSFORMSTATE_WORLD (=1) is translated to D3DTS_WORLDMATRIX(0)
|
|
|
|
* (=255) for wined3d, because the 1 transform state was removed in d3d8
|
2006-06-23 18:18:02 +02:00
|
|
|
* and WineD3D already understands the replacement D3DTS_WORLDMATRIX(0)
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Version 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* TransformStateType: transform state to set
|
|
|
|
* Matrix: Matrix to assign to the state
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Matrix == NULL
|
|
|
|
* For details see IWineD3DDevice::SetTransform
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType,
|
|
|
|
D3DMATRIX *Matrix)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2008-10-09 15:33:05 +02:00
|
|
|
D3DTRANSFORMSTATETYPE type;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, matrix %p.\n", iface, TransformStateType, Matrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-04-25 16:44:47 +02:00
|
|
|
switch(TransformStateType)
|
|
|
|
{
|
|
|
|
case D3DTRANSFORMSTATE_WORLD : type = WINED3DTS_WORLDMATRIX(0); break;
|
|
|
|
case D3DTRANSFORMSTATE_WORLD1: type = WINED3DTS_WORLDMATRIX(1); break;
|
|
|
|
case D3DTRANSFORMSTATE_WORLD2: type = WINED3DTS_WORLDMATRIX(2); break;
|
|
|
|
case D3DTRANSFORMSTATE_WORLD3: type = WINED3DTS_WORLDMATRIX(3); break;
|
|
|
|
default: type = TransformStateType;
|
|
|
|
}
|
2006-10-12 08:21:00 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
if(!Matrix)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2006-10-12 08:21:39 +02:00
|
|
|
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DDevice_SetTransform(This->wineD3DDevice,
|
|
|
|
type,
|
|
|
|
(WINED3DMATRIX*) Matrix);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetTransform_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType,
|
|
|
|
D3DMATRIX *Matrix)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_SetTransform(iface, TransformStateType, Matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetTransform_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType,
|
|
|
|
D3DMATRIX *Matrix)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_SetTransform(iface, TransformStateType, Matrix);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_SetTransform(IDirect3DDevice3 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, matrix %p.\n", iface, TransformStateType, D3DMatrix);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_SetTransform((IDirect3DDevice7 *)This, TransformStateType, D3DMatrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_SetTransform(IDirect3DDevice2 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, matrix %p.\n", iface, TransformStateType, D3DMatrix);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_SetTransform((IDirect3DDevice7 *)This, TransformStateType, D3DMatrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetTransform
|
|
|
|
*
|
|
|
|
* Returns the matrix assigned to a transform state
|
|
|
|
* D3DTRANSFORMSTATE_WORLD is translated to D3DTS_WORLDMATRIX(0), see
|
|
|
|
* SetTransform
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* TransformStateType: State to read the matrix from
|
|
|
|
* Matrix: Address to store the matrix at
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Matrix == NULL
|
|
|
|
* For details, see IWineD3DDevice::GetTransform
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType,
|
|
|
|
D3DMATRIX *Matrix)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2008-10-09 15:33:05 +02:00
|
|
|
D3DTRANSFORMSTATETYPE type;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, matrix %p.\n", iface, TransformStateType, Matrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-04-25 16:44:47 +02:00
|
|
|
switch(TransformStateType)
|
|
|
|
{
|
|
|
|
case D3DTRANSFORMSTATE_WORLD : type = WINED3DTS_WORLDMATRIX(0); break;
|
|
|
|
case D3DTRANSFORMSTATE_WORLD1: type = WINED3DTS_WORLDMATRIX(1); break;
|
|
|
|
case D3DTRANSFORMSTATE_WORLD2: type = WINED3DTS_WORLDMATRIX(2); break;
|
|
|
|
case D3DTRANSFORMSTATE_WORLD3: type = WINED3DTS_WORLDMATRIX(3); break;
|
|
|
|
default: type = TransformStateType;
|
|
|
|
}
|
2006-10-12 08:21:00 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
if(!Matrix)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2006-10-12 08:21:39 +02:00
|
|
|
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DDevice_GetTransform(This->wineD3DDevice, type, (WINED3DMATRIX*) Matrix);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetTransform_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType,
|
|
|
|
D3DMATRIX *Matrix)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_GetTransform(iface, TransformStateType, Matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetTransform_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType,
|
|
|
|
D3DMATRIX *Matrix)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetTransform(iface, TransformStateType, Matrix);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_GetTransform(IDirect3DDevice3 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, matrix %p.\n", iface, TransformStateType, D3DMatrix);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_GetTransform((IDirect3DDevice7 *)This, TransformStateType, D3DMatrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_GetTransform(IDirect3DDevice2 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, matrix %p.\n", iface, TransformStateType, D3DMatrix);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_GetTransform((IDirect3DDevice7 *)This, TransformStateType, D3DMatrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::MultiplyTransform
|
|
|
|
*
|
|
|
|
* Multiplies the already-set transform matrix of a transform state
|
|
|
|
* with another matrix. For the world matrix, see SetTransform
|
|
|
|
*
|
|
|
|
* Version 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* TransformStateType: Transform state to multiply
|
|
|
|
* D3DMatrix Matrix to multiply with.
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if D3DMatrix is NULL
|
|
|
|
* For details, see IWineD3DDevice::MultiplyTransform
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType,
|
|
|
|
D3DMATRIX *D3DMatrix)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2007-04-25 16:44:47 +02:00
|
|
|
D3DTRANSFORMSTATETYPE type;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, matrix %p.\n", iface, TransformStateType, D3DMatrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-04-25 16:44:47 +02:00
|
|
|
switch(TransformStateType)
|
|
|
|
{
|
|
|
|
case D3DTRANSFORMSTATE_WORLD : type = WINED3DTS_WORLDMATRIX(0); break;
|
|
|
|
case D3DTRANSFORMSTATE_WORLD1: type = WINED3DTS_WORLDMATRIX(1); break;
|
|
|
|
case D3DTRANSFORMSTATE_WORLD2: type = WINED3DTS_WORLDMATRIX(2); break;
|
|
|
|
case D3DTRANSFORMSTATE_WORLD3: type = WINED3DTS_WORLDMATRIX(3); break;
|
|
|
|
default: type = TransformStateType;
|
|
|
|
}
|
2006-10-12 08:21:00 +02:00
|
|
|
|
2006-10-12 08:21:39 +02:00
|
|
|
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DDevice_MultiplyTransform(This->wineD3DDevice,
|
|
|
|
type,
|
|
|
|
(WINED3DMATRIX*) D3DMatrix);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_MultiplyTransform_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType,
|
|
|
|
D3DMATRIX *D3DMatrix)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_MultiplyTransform(iface, TransformStateType, D3DMatrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_MultiplyTransform_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType,
|
|
|
|
D3DMATRIX *D3DMatrix)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_MultiplyTransform(iface, TransformStateType, D3DMatrix);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_MultiplyTransform(IDirect3DDevice3 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, matrix %p.\n", iface, TransformStateType, D3DMatrix);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_MultiplyTransform((IDirect3DDevice7 *)This, TransformStateType, D3DMatrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_MultiplyTransform(IDirect3DDevice2 *iface,
|
|
|
|
D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device2(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state %#x, matrix %p.\n", iface, TransformStateType, D3DMatrix);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
return IDirect3DDevice7_MultiplyTransform((IDirect3DDevice7 *)This, TransformStateType, D3DMatrix);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::DrawPrimitive
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Draws primitives based on vertices in an application-provided pointer
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Version 2, 3 and 7. The IDirect3DDevice2 thunk converts the fixed vertex type into
|
|
|
|
* an FVF format for D3D7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* PrimitiveType: The type of the primitives to draw
|
|
|
|
* Vertex type: Flexible vertex format vertex description
|
|
|
|
* Vertices: Pointer to the vertex array
|
|
|
|
* VertexCount: The number of vertices to draw
|
|
|
|
* Flags: As usual a few flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Vertices is NULL
|
|
|
|
* For details, see IWineD3DDevice::DrawPrimitiveUP
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
void *Vertices,
|
|
|
|
DWORD VertexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2009-03-05 12:30:42 +01:00
|
|
|
UINT stride;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, primitive_type %#x, FVF %#x, vertices %p, vertex_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexType, Vertices, VertexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Vertices)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
/* Get the stride */
|
|
|
|
stride = get_flexible_vertex_size(VertexType);
|
|
|
|
|
|
|
|
/* Set the FVF */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-19 18:36:19 +02:00
|
|
|
hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice, ddraw_find_decl(This->ddraw, VertexType));
|
2007-06-03 18:51:50 +02:00
|
|
|
if(hr != D3D_OK)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* This method translates to the user pointer draw of WineD3D */
|
2009-03-05 12:30:43 +01:00
|
|
|
IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
|
|
|
|
hr = IWineD3DDevice_DrawPrimitiveUP(This->wineD3DDevice, VertexCount, Vertices, stride);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitive_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
void *Vertices,
|
|
|
|
DWORD VertexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_DrawPrimitive(iface, PrimitiveType, VertexType, Vertices, VertexCount, Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitive_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
void *Vertices,
|
|
|
|
DWORD VertexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_DrawPrimitive(iface, PrimitiveType, VertexType, Vertices, VertexCount, Flags);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawPrimitive(IDirect3DDevice3 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType, void *Vertices, DWORD VertexCount,
|
|
|
|
DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, primitive_type %#x, FVF %#x, vertices %p, vertex_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexType, Vertices, VertexCount, Flags);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_DrawPrimitive((IDirect3DDevice7 *)device_from_device3(iface),
|
2009-01-21 09:56:13 +01:00
|
|
|
PrimitiveType, VertexType, Vertices, VertexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_DrawPrimitive(IDirect3DDevice2 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType, D3DVERTEXTYPE VertexType, void *Vertices,
|
|
|
|
DWORD VertexCount, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
DWORD FVF;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, primitive_type %#x, vertex_type %#x, vertices %p, vertex_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexType, Vertices, VertexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
switch(VertexType)
|
|
|
|
{
|
|
|
|
case D3DVT_VERTEX: FVF = D3DFVF_VERTEX; break;
|
|
|
|
case D3DVT_LVERTEX: FVF = D3DFVF_LVERTEX; break;
|
|
|
|
case D3DVT_TLVERTEX: FVF = D3DFVF_TLVERTEX; break;
|
|
|
|
default:
|
2006-06-26 23:15:55 +02:00
|
|
|
ERR("Unexpected vertex type %d\n", VertexType);
|
|
|
|
return DDERR_INVALIDPARAMS; /* Should never happen */
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
return IDirect3DDevice7_DrawPrimitive((IDirect3DDevice7 *)device_from_device2(iface),
|
|
|
|
PrimitiveType, FVF, Vertices, VertexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::DrawIndexedPrimitive
|
|
|
|
*
|
|
|
|
* Draws vertices from an application-provided pointer, based on the index
|
|
|
|
* numbers in a WORD array.
|
|
|
|
*
|
|
|
|
* Version 2, 3 and 7. The version 7 thunk translates the vertex type into
|
|
|
|
* an FVF format for D3D7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* PrimitiveType: The primitive type to draw
|
|
|
|
* VertexType: The FVF vertex description
|
|
|
|
* Vertices: Pointer to the vertex array
|
|
|
|
* VertexCount: ?
|
|
|
|
* Indices: Pointer to the index array
|
|
|
|
* IndexCount: Number of indices = Number of vertices to draw
|
|
|
|
* Flags: As usual, some flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Vertices or Indices is NULL
|
|
|
|
* For details, see IWineD3DDevice::DrawIndexedPrimitiveUP
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
void *Vertices,
|
|
|
|
DWORD VertexCount,
|
|
|
|
WORD *Indices,
|
|
|
|
DWORD IndexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, primitive_type %#x, FVF %#x, vertices %p, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
|
2007-06-03 18:51:50 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Set the D3DDevice's FVF */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-19 18:36:19 +02:00
|
|
|
hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice, ddraw_find_decl(This->ddraw, VertexType));
|
2006-06-09 19:36:12 +02:00
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2006-10-10 19:23:27 +02:00
|
|
|
ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-03-05 12:30:43 +01:00
|
|
|
IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
|
2009-09-10 16:57:16 +02:00
|
|
|
hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->wineD3DDevice, IndexCount, Indices,
|
|
|
|
WINED3DFMT_R16_UINT, Vertices, get_flexible_vertex_size(VertexType));
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitive_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
void *Vertices,
|
|
|
|
DWORD VertexCount,
|
|
|
|
WORD *Indices,
|
|
|
|
DWORD IndexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_DrawIndexedPrimitive(iface, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitive_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
void *Vertices,
|
|
|
|
DWORD VertexCount,
|
|
|
|
WORD *Indices,
|
|
|
|
DWORD IndexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_DrawIndexedPrimitive(iface, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawIndexedPrimitive(IDirect3DDevice3 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType, void *Vertices, DWORD VertexCount,
|
|
|
|
WORD *Indices, DWORD IndexCount, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, primitive_type %#x, FVF %#x, vertices %p, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_DrawIndexedPrimitive((IDirect3DDevice7 *)device_from_device3(iface),
|
2009-01-21 09:56:13 +01:00
|
|
|
PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_DrawIndexedPrimitive(IDirect3DDevice2 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType, D3DVERTEXTYPE VertexType, void *Vertices,
|
|
|
|
DWORD VertexCount, WORD *Indices, DWORD IndexCount, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
DWORD FVF;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, primitive_type %#x, vertex_type %#x, vertices %p, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
switch(VertexType)
|
|
|
|
{
|
|
|
|
case D3DVT_VERTEX: FVF = D3DFVF_VERTEX; break;
|
|
|
|
case D3DVT_LVERTEX: FVF = D3DFVF_LVERTEX; break;
|
|
|
|
case D3DVT_TLVERTEX: FVF = D3DFVF_TLVERTEX; break;
|
|
|
|
default:
|
2006-06-26 23:15:55 +02:00
|
|
|
ERR("Unexpected vertex type %d\n", VertexType);
|
|
|
|
return DDERR_INVALIDPARAMS; /* Should never happen */
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
return IDirect3DDevice7_DrawIndexedPrimitive((IDirect3DDevice7 *)device_from_device2(iface),
|
2009-01-21 09:56:13 +01:00
|
|
|
PrimitiveType, FVF, Vertices, VertexCount, Indices, IndexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::SetClipStatus
|
|
|
|
*
|
|
|
|
* Sets the clip status. This defines things as clipping conditions and
|
|
|
|
* the extents of the clipping region.
|
|
|
|
*
|
|
|
|
* Version 2, 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* ClipStatus:
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK because it's a stub
|
|
|
|
* (DDERR_INVALIDPARAMS if ClipStatus == NULL)
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetClipStatus(IDirect3DDevice7 *iface,
|
|
|
|
D3DCLIPSTATUS *ClipStatus)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, clip_status %p stub!\n", iface, ClipStatus);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them
|
|
|
|
* Perhaps this needs a new data type and an additional IWineD3DDevice method
|
|
|
|
*/
|
|
|
|
/* return IWineD3DDevice_SetClipStatus(This->wineD3DDevice, ClipStatus);*/
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_SetClipStatus(IDirect3DDevice3 *iface,
|
|
|
|
D3DCLIPSTATUS *ClipStatus)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, clip_status %p.\n", iface, ClipStatus);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_SetClipStatus((IDirect3DDevice7 *)device_from_device3(iface), ClipStatus);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_SetClipStatus(IDirect3DDevice2 *iface,
|
|
|
|
D3DCLIPSTATUS *ClipStatus)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, clip_status %p.\n", iface, ClipStatus);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_SetClipStatus((IDirect3DDevice7 *)device_from_device2(iface), ClipStatus);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetClipStatus
|
|
|
|
*
|
|
|
|
* Returns the clip status
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* ClipStatus: Address to write the clip status to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetClipStatus(IDirect3DDevice7 *iface,
|
|
|
|
D3DCLIPSTATUS *ClipStatus)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, clip_status %p stub!\n", iface, ClipStatus);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* D3DCLIPSTATUS and WINED3DCLIPSTATUS are different. I don't know how to convert them */
|
|
|
|
/* return IWineD3DDevice_GetClipStatus(This->wineD3DDevice, ClipStatus);*/
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_GetClipStatus(IDirect3DDevice3 *iface,
|
|
|
|
D3DCLIPSTATUS *ClipStatus)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, clip_status %p.\n", iface, ClipStatus);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_GetClipStatus((IDirect3DDevice7 *)device_from_device3(iface), ClipStatus);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 02:05:06 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_GetClipStatus(IDirect3DDevice2 *iface,
|
|
|
|
D3DCLIPSTATUS *ClipStatus)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, clip_status %p.\n", iface, ClipStatus);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_GetClipStatus((IDirect3DDevice7 *)device_from_device2(iface), ClipStatus);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice::DrawPrimitiveStrided
|
|
|
|
*
|
|
|
|
* Draws vertices described by a D3DDRAWPRIMITIVESTRIDEDDATA structure.
|
|
|
|
*
|
|
|
|
* Version 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* PrimitiveType: The primitive type to draw
|
2006-06-23 18:18:02 +02:00
|
|
|
* VertexType: The FVF description of the vertices to draw (for the stride??)
|
2006-06-09 19:36:12 +02:00
|
|
|
* D3DDrawPrimStrideData: A D3DDRAWPRIMITIVESTRIDEDDATA structure describing
|
|
|
|
* the vertex data locations
|
|
|
|
* VertexCount: The number of vertices to draw
|
|
|
|
* Flags: Some flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK, because it's a stub
|
|
|
|
* (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
|
|
|
|
* (For details, see IWineD3DDevice::DrawPrimitiveStrided)
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
|
|
|
|
DWORD VertexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
WineDirect3DVertexStridedData WineD3DStrided;
|
2008-09-27 18:35:03 +02:00
|
|
|
DWORD i;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, primitive_type %#x, FVF %#x, strided_data %p, vertex_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-01-16 23:58:29 +01:00
|
|
|
memset(&WineD3DStrided, 0, sizeof(WineD3DStrided));
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Get the strided data right. the wined3d structure is a bit bigger
|
|
|
|
* Watch out: The contents of the strided data are determined by the fvf,
|
|
|
|
* not by the members set in D3DDrawPrimStrideData. So it's valid
|
2006-06-23 18:18:02 +02:00
|
|
|
* to have diffuse.lpvData set to 0xdeadbeef if the diffuse flag is
|
|
|
|
* not set in the fvf.
|
2006-06-09 19:36:12 +02:00
|
|
|
*/
|
|
|
|
if(VertexType & D3DFVF_POSITION_MASK)
|
|
|
|
{
|
2009-03-27 10:25:56 +01:00
|
|
|
WineD3DStrided.position.format = WINED3DFMT_R32G32B32_FLOAT;
|
2009-03-27 10:25:55 +01:00
|
|
|
WineD3DStrided.position.lpData = D3DDrawPrimStrideData->position.lpvData;
|
|
|
|
WineD3DStrided.position.dwStride = D3DDrawPrimStrideData->position.dwStride;
|
2006-06-09 19:36:12 +02:00
|
|
|
if (VertexType & D3DFVF_XYZRHW)
|
|
|
|
{
|
2009-03-27 10:25:56 +01:00
|
|
|
WineD3DStrided.position.format = WINED3DFMT_R32G32B32A32_FLOAT;
|
2009-01-08 10:19:16 +01:00
|
|
|
WineD3DStrided.position_transformed = TRUE;
|
2006-07-07 15:15:20 +02:00
|
|
|
} else
|
2009-01-08 10:19:16 +01:00
|
|
|
WineD3DStrided.position_transformed = FALSE;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(VertexType & D3DFVF_NORMAL)
|
|
|
|
{
|
2009-03-27 10:25:56 +01:00
|
|
|
WineD3DStrided.normal.format = WINED3DFMT_R32G32B32_FLOAT;
|
2009-03-27 10:25:55 +01:00
|
|
|
WineD3DStrided.normal.lpData = D3DDrawPrimStrideData->normal.lpvData;
|
|
|
|
WineD3DStrided.normal.dwStride = D3DDrawPrimStrideData->normal.dwStride;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(VertexType & D3DFVF_DIFFUSE)
|
|
|
|
{
|
2009-09-25 13:31:49 +02:00
|
|
|
WineD3DStrided.diffuse.format = WINED3DFMT_B8G8R8A8_UNORM;
|
2009-03-27 10:25:55 +01:00
|
|
|
WineD3DStrided.diffuse.lpData = D3DDrawPrimStrideData->diffuse.lpvData;
|
|
|
|
WineD3DStrided.diffuse.dwStride = D3DDrawPrimStrideData->diffuse.dwStride;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(VertexType & D3DFVF_SPECULAR)
|
|
|
|
{
|
2009-09-25 13:31:49 +02:00
|
|
|
WineD3DStrided.specular.format = WINED3DFMT_B8G8R8A8_UNORM;
|
2009-03-27 10:25:55 +01:00
|
|
|
WineD3DStrided.specular.lpData = D3DDrawPrimStrideData->specular.lpvData;
|
|
|
|
WineD3DStrided.specular.dwStride = D3DDrawPrimStrideData->specular.dwStride;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for( i = 0; i < GET_TEXCOUNT_FROM_FVF(VertexType); i++)
|
|
|
|
{
|
|
|
|
switch(GET_TEXCOORD_SIZE_FROM_FVF(VertexType, i))
|
|
|
|
{
|
2009-03-27 10:25:56 +01:00
|
|
|
case 1: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32_FLOAT; break;
|
|
|
|
case 2: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32_FLOAT; break;
|
|
|
|
case 3: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32B32_FLOAT; break;
|
|
|
|
case 4: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32B32A32_FLOAT; break;
|
2006-10-10 19:23:27 +02:00
|
|
|
default: ERR("Unexpected texture coordinate size %d\n",
|
2006-06-09 19:36:12 +02:00
|
|
|
GET_TEXCOORD_SIZE_FROM_FVF(VertexType, i));
|
|
|
|
}
|
2009-03-27 10:25:56 +01:00
|
|
|
WineD3DStrided.texCoords[i].lpData = D3DDrawPrimStrideData->textureCoords[i].lpvData;
|
|
|
|
WineD3DStrided.texCoords[i].dwStride = D3DDrawPrimStrideData->textureCoords[i].dwStride;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2007-04-22 17:55:30 +02:00
|
|
|
/* WineD3D doesn't need the FVF here */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2009-03-05 12:30:43 +01:00
|
|
|
IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
|
|
|
|
hr = IWineD3DDevice_DrawPrimitiveStrided(This->wineD3DDevice, VertexCount, &WineD3DStrided);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitiveStrided_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
|
|
|
|
DWORD VertexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_DrawPrimitiveStrided(iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitiveStrided_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
|
|
|
|
DWORD VertexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_DrawPrimitiveStrided(iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawPrimitiveStrided(IDirect3DDevice3 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType,
|
|
|
|
D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, primitive_type %#x, FVF %#x, strided_data %p, vertex_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_DrawPrimitiveStrided((IDirect3DDevice7 *)device_from_device3(iface),
|
2009-01-21 09:56:13 +01:00
|
|
|
PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::DrawIndexedPrimitiveStrided
|
|
|
|
*
|
|
|
|
* Draws primitives specified by strided data locations based on indices
|
|
|
|
*
|
|
|
|
* Version 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* PrimitiveType:
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK, because it's a stub
|
|
|
|
* (DDERR_INVALIDPARAMS if D3DDrawPrimStrideData is NULL)
|
|
|
|
* (DDERR_INVALIDPARAMS if Indices is NULL)
|
|
|
|
* (For more details, see IWineD3DDevice::DrawIndexedPrimitiveStrided)
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
|
|
|
|
DWORD VertexCount,
|
|
|
|
WORD *Indices,
|
|
|
|
DWORD IndexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-07-27 14:39:55 +02:00
|
|
|
WineDirect3DVertexStridedData WineD3DStrided;
|
2008-09-27 18:35:03 +02:00
|
|
|
DWORD i;
|
2007-07-27 14:39:55 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, primitive_type %#x, FVF %#x, strided_data %p, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-07-27 14:39:55 +02:00
|
|
|
memset(&WineD3DStrided, 0, sizeof(WineD3DStrided));
|
|
|
|
/* Get the strided data right. the wined3d structure is a bit bigger
|
|
|
|
* Watch out: The contents of the strided data are determined by the fvf,
|
|
|
|
* not by the members set in D3DDrawPrimStrideData. So it's valid
|
|
|
|
* to have diffuse.lpvData set to 0xdeadbeef if the diffuse flag is
|
|
|
|
* not set in the fvf.
|
2006-06-09 19:36:12 +02:00
|
|
|
*/
|
2007-07-27 14:39:55 +02:00
|
|
|
if(VertexType & D3DFVF_POSITION_MASK)
|
|
|
|
{
|
2009-03-27 10:25:56 +01:00
|
|
|
WineD3DStrided.position.format = WINED3DFMT_R32G32B32_FLOAT;
|
2009-03-27 10:25:55 +01:00
|
|
|
WineD3DStrided.position.lpData = D3DDrawPrimStrideData->position.lpvData;
|
|
|
|
WineD3DStrided.position.dwStride = D3DDrawPrimStrideData->position.dwStride;
|
2007-07-27 14:39:55 +02:00
|
|
|
if (VertexType & D3DFVF_XYZRHW)
|
|
|
|
{
|
2009-03-27 10:25:56 +01:00
|
|
|
WineD3DStrided.position.format = WINED3DFMT_R32G32B32A32_FLOAT;
|
2009-01-08 10:19:16 +01:00
|
|
|
WineD3DStrided.position_transformed = TRUE;
|
2007-07-27 14:39:55 +02:00
|
|
|
} else
|
2009-01-08 10:19:16 +01:00
|
|
|
WineD3DStrided.position_transformed = FALSE;
|
2007-07-27 14:39:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(VertexType & D3DFVF_NORMAL)
|
|
|
|
{
|
2009-03-27 10:25:56 +01:00
|
|
|
WineD3DStrided.normal.format = WINED3DFMT_R32G32B32_FLOAT;
|
2009-03-27 10:25:55 +01:00
|
|
|
WineD3DStrided.normal.lpData = D3DDrawPrimStrideData->normal.lpvData;
|
|
|
|
WineD3DStrided.normal.dwStride = D3DDrawPrimStrideData->normal.dwStride;
|
2007-07-27 14:39:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(VertexType & D3DFVF_DIFFUSE)
|
|
|
|
{
|
2009-09-25 13:31:49 +02:00
|
|
|
WineD3DStrided.diffuse.format = WINED3DFMT_B8G8R8A8_UNORM;
|
2009-03-27 10:25:55 +01:00
|
|
|
WineD3DStrided.diffuse.lpData = D3DDrawPrimStrideData->diffuse.lpvData;
|
|
|
|
WineD3DStrided.diffuse.dwStride = D3DDrawPrimStrideData->diffuse.dwStride;
|
2007-07-27 14:39:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(VertexType & D3DFVF_SPECULAR)
|
|
|
|
{
|
2009-09-25 13:31:49 +02:00
|
|
|
WineD3DStrided.specular.format = WINED3DFMT_B8G8R8A8_UNORM;
|
2009-03-27 10:25:55 +01:00
|
|
|
WineD3DStrided.specular.lpData = D3DDrawPrimStrideData->specular.lpvData;
|
|
|
|
WineD3DStrided.specular.dwStride = D3DDrawPrimStrideData->specular.dwStride;
|
2007-07-27 14:39:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for( i = 0; i < GET_TEXCOUNT_FROM_FVF(VertexType); i++)
|
|
|
|
{
|
|
|
|
switch(GET_TEXCOORD_SIZE_FROM_FVF(VertexType, i))
|
|
|
|
{
|
2009-03-27 10:25:56 +01:00
|
|
|
case 1: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32_FLOAT; break;
|
|
|
|
case 2: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32_FLOAT; break;
|
|
|
|
case 3: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32B32_FLOAT; break;
|
|
|
|
case 4: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32B32A32_FLOAT; break;
|
2007-07-27 14:39:55 +02:00
|
|
|
default: ERR("Unexpected texture coordinate size %d\n",
|
|
|
|
GET_TEXCOORD_SIZE_FROM_FVF(VertexType, i));
|
|
|
|
}
|
2009-03-27 10:25:56 +01:00
|
|
|
WineD3DStrided.texCoords[i].lpData = D3DDrawPrimStrideData->textureCoords[i].lpvData;
|
|
|
|
WineD3DStrided.texCoords[i].dwStride = D3DDrawPrimStrideData->textureCoords[i].dwStride;
|
2007-07-27 14:39:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* WineD3D doesn't need the FVF here */
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2009-03-05 12:30:43 +01:00
|
|
|
IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
|
|
|
|
hr = IWineD3DDevice_DrawIndexedPrimitiveStrided(This->wineD3DDevice,
|
2009-03-05 12:30:42 +01:00
|
|
|
IndexCount, &WineD3DStrided, VertexCount, Indices, WINED3DFMT_R16_UINT);
|
2007-07-27 14:39:55 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
2008-06-20 01:49:46 +02:00
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
|
|
|
|
DWORD VertexCount,
|
|
|
|
WORD *Indices,
|
|
|
|
DWORD IndexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
DWORD VertexType,
|
|
|
|
D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
|
|
|
|
DWORD VertexCount,
|
|
|
|
WORD *Indices,
|
|
|
|
DWORD IndexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(IDirect3DDevice3 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType,
|
|
|
|
D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, WORD *Indices,
|
|
|
|
DWORD IndexCount, DWORD Flags)
|
2008-06-20 01:49:46 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, primitive_type %#x, FVF %#x, strided_data %p, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_DrawIndexedPrimitiveStrided((IDirect3DDevice7 *)device_from_device3(iface),
|
|
|
|
PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::DrawPrimitiveVB
|
|
|
|
*
|
|
|
|
* Draws primitives from a vertex buffer to the screen.
|
|
|
|
*
|
|
|
|
* Version 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* PrimitiveType: Type of primitive to be rendered.
|
|
|
|
* D3DVertexBuf: Source Vertex Buffer
|
|
|
|
* StartVertex: Index of the first vertex from the buffer to be rendered
|
|
|
|
* NumVertices: Number of vertices to be rendered
|
|
|
|
* Flags: Can be D3DDP_WAIT to wait until rendering has finished
|
|
|
|
*
|
|
|
|
* Return values
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if D3DVertexBuf is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
IDirect3DVertexBuffer7 *D3DVertexBuf,
|
|
|
|
DWORD StartVertex,
|
|
|
|
DWORD NumVertices,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
|
|
|
DWORD stride;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %u, vertex_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
if(!vb)
|
|
|
|
{
|
|
|
|
ERR("(%p) No Vertex buffer specified\n", This);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2009-04-06 14:09:54 +02:00
|
|
|
stride = get_flexible_vertex_size(vb->fvf);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2007-04-22 17:55:30 +02:00
|
|
|
hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
|
|
|
|
vb->wineD3DVertexDeclaration);
|
2006-06-09 19:36:12 +02:00
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2006-10-10 19:23:27 +02:00
|
|
|
ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-23 18:18:02 +02:00
|
|
|
/* Set the vertex stream source */
|
2006-06-09 19:36:12 +02:00
|
|
|
hr = IWineD3DDevice_SetStreamSource(This->wineD3DDevice,
|
|
|
|
0 /* StreamNumber */,
|
|
|
|
vb->wineD3DVertexBuffer,
|
|
|
|
0 /* StartVertex - we pass this to DrawPrimitive */,
|
|
|
|
stride);
|
|
|
|
if(hr != D3D_OK)
|
|
|
|
{
|
2006-10-10 19:23:27 +02:00
|
|
|
ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This, hr);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now draw the primitives */
|
2009-03-05 12:30:43 +01:00
|
|
|
IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
|
|
|
|
hr = IWineD3DDevice_DrawPrimitive(This->wineD3DDevice, StartVertex, NumVertices);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitiveVB_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
IDirect3DVertexBuffer7 *D3DVertexBuf,
|
|
|
|
DWORD StartVertex,
|
|
|
|
DWORD NumVertices,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_DrawPrimitiveVB(iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitiveVB_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
IDirect3DVertexBuffer7 *D3DVertexBuf,
|
|
|
|
DWORD StartVertex,
|
|
|
|
DWORD NumVertices,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_DrawPrimitiveVB(iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer *D3DVertexBuf, DWORD StartVertex,
|
|
|
|
DWORD NumVertices, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DVertexBufferImpl *vb = D3DVertexBuf ? vb_from_vb1(D3DVertexBuf) : NULL;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %u, vertex_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_DrawPrimitiveVB((IDirect3DDevice7 *)device_from_device3(iface),
|
|
|
|
PrimitiveType, (IDirect3DVertexBuffer7 *)vb, StartVertex, NumVertices, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::DrawIndexedPrimitiveVB
|
|
|
|
*
|
|
|
|
* Draws primitives from a vertex buffer to the screen
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* PrimitiveType: Type of primitive to be rendered.
|
|
|
|
* D3DVertexBuf: Source Vertex Buffer
|
|
|
|
* StartVertex: Index of the first vertex from the buffer to be rendered
|
|
|
|
* NumVertices: Number of vertices to be rendered
|
|
|
|
* Indices: Array of DWORDs used to index into the Vertices
|
|
|
|
* IndexCount: Number of indices in Indices
|
|
|
|
* Flags: Can be D3DDP_WAIT to wait until rendering has finished
|
|
|
|
*
|
|
|
|
* Return values
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
IDirect3DVertexBuffer7 *D3DVertexBuf,
|
|
|
|
DWORD StartVertex,
|
|
|
|
DWORD NumVertices,
|
|
|
|
WORD *Indices,
|
|
|
|
DWORD IndexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf;
|
2009-04-06 14:09:54 +02:00
|
|
|
DWORD stride = get_flexible_vertex_size(vb->fvf);
|
2011-03-10 19:07:10 +01:00
|
|
|
struct wined3d_resource *wined3d_resource;
|
2011-03-08 19:41:05 +01:00
|
|
|
struct wined3d_resource_desc desc;
|
2006-06-09 19:36:12 +02:00
|
|
|
WORD *LockedIndices;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %u, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Indices, IndexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Steps:
|
2009-04-06 14:09:54 +02:00
|
|
|
* 1) Upload the Indices to the index buffer
|
|
|
|
* 2) Set the index source
|
|
|
|
* 3) Set the Vertex Buffer as the Stream source
|
|
|
|
* 4) Call IWineD3DDevice::DrawIndexedPrimitive
|
2006-06-09 19:36:12 +02:00
|
|
|
*/
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-04-22 17:55:30 +02:00
|
|
|
hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
|
|
|
|
vb->wineD3DVertexDeclaration);
|
2006-06-09 19:36:12 +02:00
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2006-10-10 19:23:27 +02:00
|
|
|
ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-06-30 10:40:29 +02:00
|
|
|
/* check that the buffer is large enough to hold the indices,
|
2010-09-14 13:38:38 +02:00
|
|
|
* reallocate if necessary. */
|
2011-03-10 19:07:10 +01:00
|
|
|
wined3d_resource = wined3d_buffer_get_resource(This->indexbuffer);
|
|
|
|
wined3d_resource_get_desc(wined3d_resource, &desc);
|
2011-03-08 19:41:05 +01:00
|
|
|
if (desc.size < IndexCount * sizeof(WORD))
|
2010-06-30 10:40:29 +02:00
|
|
|
{
|
2011-03-08 19:41:05 +01:00
|
|
|
UINT size = max(desc.size * 2, IndexCount * sizeof(WORD));
|
2011-03-03 21:49:09 +01:00
|
|
|
struct wined3d_buffer *buffer;
|
2010-06-30 10:40:29 +02:00
|
|
|
|
|
|
|
TRACE("Growing index buffer to %u bytes\n", size);
|
|
|
|
|
2011-05-10 21:18:47 +02:00
|
|
|
hr = wined3d_buffer_create_ib(This->wineD3DDevice, size, WINED3DUSAGE_DYNAMIC /* Usage */,
|
2011-03-03 21:49:08 +01:00
|
|
|
WINED3DPOOL_DEFAULT, NULL, &ddraw_null_wined3d_parent_ops, &buffer);
|
2010-08-31 18:41:40 +02:00
|
|
|
if (FAILED(hr))
|
2010-06-30 10:40:29 +02:00
|
|
|
{
|
|
|
|
ERR("(%p) IWineD3DDevice::CreateIndexBuffer failed with hr = %08x\n", This, hr);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-03-03 21:49:09 +01:00
|
|
|
wined3d_buffer_decref(This->indexbuffer);
|
2010-06-30 10:40:29 +02:00
|
|
|
This->indexbuffer = buffer;
|
|
|
|
}
|
|
|
|
|
2011-03-03 21:49:09 +01:00
|
|
|
/* Copy the index stream into the index buffer. A new IWineD3DDevice
|
|
|
|
* method could be created which takes an user pointer containing the
|
|
|
|
* indices or a SetData-Method for the index buffer, which overrides the
|
|
|
|
* index buffer data with our pointer. */
|
|
|
|
hr = wined3d_buffer_map(This->indexbuffer, 0, IndexCount * sizeof(WORD),
|
|
|
|
(BYTE **)&LockedIndices, 0);
|
|
|
|
if (FAILED(hr))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-03-03 21:49:09 +01:00
|
|
|
ERR("Failed to map buffer, hr %#x.\n", hr);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
memcpy(LockedIndices, Indices, IndexCount * sizeof(WORD));
|
2011-03-03 21:49:09 +01:00
|
|
|
wined3d_buffer_unmap(This->indexbuffer);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Set the index stream */
|
2007-06-05 18:52:21 +02:00
|
|
|
IWineD3DDevice_SetBaseVertexIndex(This->wineD3DDevice, StartVertex);
|
2009-09-25 13:31:45 +02:00
|
|
|
hr = IWineD3DDevice_SetIndexBuffer(This->wineD3DDevice, This->indexbuffer,
|
2009-04-09 10:50:31 +02:00
|
|
|
WINED3DFMT_R16_UINT);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2006-06-23 18:18:02 +02:00
|
|
|
/* Set the vertex stream source */
|
2006-06-09 19:36:12 +02:00
|
|
|
hr = IWineD3DDevice_SetStreamSource(This->wineD3DDevice,
|
|
|
|
0 /* StreamNumber */,
|
|
|
|
vb->wineD3DVertexBuffer,
|
|
|
|
0 /* offset, we pass this to DrawIndexedPrimitive */,
|
|
|
|
stride);
|
|
|
|
if(hr != D3D_OK)
|
|
|
|
{
|
2006-10-10 19:23:27 +02:00
|
|
|
ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This, hr);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-05 12:30:43 +01:00
|
|
|
IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
|
2009-09-10 16:57:16 +02:00
|
|
|
hr = IWineD3DDevice_DrawIndexedPrimitive(This->wineD3DDevice, 0 /* StartIndex */, IndexCount);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
IDirect3DVertexBuffer7 *D3DVertexBuf,
|
|
|
|
DWORD StartVertex,
|
|
|
|
DWORD NumVertices,
|
|
|
|
WORD *Indices,
|
|
|
|
DWORD IndexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Indices, IndexCount, Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType,
|
|
|
|
IDirect3DVertexBuffer7 *D3DVertexBuf,
|
|
|
|
DWORD StartVertex,
|
|
|
|
DWORD NumVertices,
|
|
|
|
WORD *Indices,
|
|
|
|
DWORD IndexCount,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Indices, IndexCount, Flags);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevice3 *iface,
|
|
|
|
D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer *D3DVertexBuf, WORD *Indices,
|
|
|
|
DWORD IndexCount, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirect3DVertexBufferImpl *VB = vb_from_vb1(D3DVertexBuf);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, primitive_type %#x, vb %p, indices %p, index_count %u, flags %#x.\n",
|
|
|
|
iface, PrimitiveType, D3DVertexBuf, Indices, IndexCount, Flags);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_DrawIndexedPrimitiveVB((IDirect3DDevice7 *)device_from_device3(iface),
|
|
|
|
PrimitiveType, (IDirect3DVertexBuffer7 *)VB, 0, IndexCount, Indices, IndexCount, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::ComputeSphereVisibility
|
|
|
|
*
|
|
|
|
* Calculates the visibility of spheres in the current viewport. The spheres
|
|
|
|
* are passed in the Centers and Radii arrays, the results are passed back
|
2006-06-23 18:18:02 +02:00
|
|
|
* in the ReturnValues array. Return values are either completely visible,
|
2006-06-09 19:36:12 +02:00
|
|
|
* partially visible or completely invisible.
|
|
|
|
* The return value consist of a combination of D3DCLIP_* flags, or it's
|
|
|
|
* 0 if the sphere is completely visible(according to the SDK, not checked)
|
|
|
|
*
|
|
|
|
* Version 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Centers: Array containing the sphere centers
|
2006-06-23 18:18:02 +02:00
|
|
|
* Radii: Array containing the sphere radii
|
|
|
|
* NumSpheres: The number of centers and radii in the arrays
|
2006-06-09 19:36:12 +02:00
|
|
|
* Flags: Some flags
|
|
|
|
* ReturnValues: Array to write the results to
|
|
|
|
*
|
|
|
|
* Returns:
|
2009-04-11 13:46:47 +02:00
|
|
|
* D3D_OK
|
2006-06-09 19:36:12 +02:00
|
|
|
* (DDERR_INVALIDPARAMS if Centers, Radii or ReturnValues are NULL)
|
|
|
|
* (D3DERR_INVALIDMATRIX if the combined world, view and proj matrix
|
|
|
|
* is singular)
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2009-02-26 08:55:07 +01:00
|
|
|
|
|
|
|
static DWORD in_plane(UINT plane, D3DVECTOR normal, D3DVALUE origin_plane, D3DVECTOR center, D3DVALUE radius)
|
|
|
|
{
|
|
|
|
float distance, norm;
|
|
|
|
|
|
|
|
norm = sqrt( normal.u1.x * normal.u1.x + normal.u2.y * normal.u2.y + normal.u3.z * normal.u3.z );
|
|
|
|
distance = ( origin_plane + normal.u1.x * center.u1.x + normal.u2.y * center.u2.y + normal.u3.z * center.u3.z ) / norm;
|
|
|
|
|
|
|
|
if ( fabs( distance ) < radius ) return D3DSTATUS_CLIPUNIONLEFT << plane;
|
|
|
|
if ( distance < -radius ) return (D3DSTATUS_CLIPUNIONLEFT | D3DSTATUS_CLIPINTERSECTIONLEFT) << plane;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_ComputeSphereVisibility(IDirect3DDevice7 *iface,
|
|
|
|
D3DVECTOR *Centers,
|
|
|
|
D3DVALUE *Radii,
|
|
|
|
DWORD NumSpheres,
|
|
|
|
DWORD Flags,
|
|
|
|
DWORD *ReturnValues)
|
|
|
|
{
|
2009-02-26 08:55:07 +01:00
|
|
|
D3DMATRIX m, temp;
|
|
|
|
D3DVALUE origin_plane[6];
|
|
|
|
D3DVECTOR vec[6];
|
|
|
|
HRESULT hr;
|
|
|
|
UINT i, j;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, centers %p, radii %p, sphere_count %u, flags %#x, return_values %p.\n",
|
|
|
|
iface, Centers, Radii, NumSpheres, Flags, ReturnValues);
|
2009-02-26 08:55:07 +01:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetTransform(iface, D3DTRANSFORMSTATE_WORLD, &m);
|
|
|
|
if ( hr != DD_OK ) return DDERR_INVALIDPARAMS;
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetTransform(iface, D3DTRANSFORMSTATE_VIEW, &temp);
|
|
|
|
if ( hr != DD_OK ) return DDERR_INVALIDPARAMS;
|
2010-10-21 15:01:24 +02:00
|
|
|
multiply_matrix(&m, &temp, &m);
|
2009-02-26 08:55:07 +01:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetTransform(iface, D3DTRANSFORMSTATE_PROJECTION, &temp);
|
|
|
|
if ( hr != DD_OK ) return DDERR_INVALIDPARAMS;
|
2010-10-21 15:01:24 +02:00
|
|
|
multiply_matrix(&m, &temp, &m);
|
2009-02-26 08:55:07 +01:00
|
|
|
|
|
|
|
/* Left plane */
|
|
|
|
vec[0].u1.x = m._14 + m._11;
|
|
|
|
vec[0].u2.y = m._24 + m._21;
|
|
|
|
vec[0].u3.z = m._34 + m._31;
|
|
|
|
origin_plane[0] = m._44 + m._41;
|
|
|
|
|
|
|
|
/* Right plane */
|
|
|
|
vec[1].u1.x = m._14 - m._11;
|
|
|
|
vec[1].u2.y = m._24 - m._21;
|
|
|
|
vec[1].u3.z = m._34 - m._31;
|
|
|
|
origin_plane[1] = m._44 - m._41;
|
|
|
|
|
|
|
|
/* Top plane */
|
|
|
|
vec[2].u1.x = m._14 - m._12;
|
|
|
|
vec[2].u2.y = m._24 - m._22;
|
|
|
|
vec[2].u3.z = m._34 - m._32;
|
|
|
|
origin_plane[2] = m._44 - m._42;
|
|
|
|
|
|
|
|
/* Bottom plane */
|
|
|
|
vec[3].u1.x = m._14 + m._12;
|
|
|
|
vec[3].u2.y = m._24 + m._22;
|
|
|
|
vec[3].u3.z = m._34 + m._32;
|
|
|
|
origin_plane[3] = m._44 + m._42;
|
|
|
|
|
|
|
|
/* Front plane */
|
|
|
|
vec[4].u1.x = m._13;
|
|
|
|
vec[4].u2.y = m._23;
|
|
|
|
vec[4].u3.z = m._33;
|
|
|
|
origin_plane[4] = m._43;
|
|
|
|
|
|
|
|
/* Back plane*/
|
|
|
|
vec[5].u1.x = m._14 - m._13;
|
|
|
|
vec[5].u2.y = m._24 - m._23;
|
|
|
|
vec[5].u3.z = m._34 - m._33;
|
|
|
|
origin_plane[5] = m._44 - m._43;
|
|
|
|
|
|
|
|
for(i=0; i<NumSpheres; i++)
|
|
|
|
{
|
|
|
|
ReturnValues[i] = 0;
|
|
|
|
for(j=0; j<6; j++) ReturnValues[i] |= in_plane(j, vec[j], origin_plane[j], Centers[i], Radii[i]);
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_ComputeSphereVisibility(IDirect3DDevice3 *iface,
|
|
|
|
D3DVECTOR *Centers, D3DVALUE *Radii, DWORD NumSpheres, DWORD Flags, DWORD *ReturnValues)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, centers %p, radii %p, sphere_count %u, flags %#x, return_values %p.\n",
|
|
|
|
iface, Centers, Radii, NumSpheres, Flags, ReturnValues);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_ComputeSphereVisibility((IDirect3DDevice7 *)device_from_device3(iface),
|
2009-01-21 09:56:13 +01:00
|
|
|
Centers, Radii, NumSpheres, Flags, ReturnValues);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetTexture
|
|
|
|
*
|
|
|
|
* Returns the texture interface handle assigned to a texture stage.
|
|
|
|
* The returned texture is AddRefed. This is taken from old ddraw,
|
|
|
|
* not checked in Windows.
|
|
|
|
*
|
|
|
|
* Version 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Stage: Texture stage to read the texture from
|
|
|
|
* Texture: Address to store the interface pointer at
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Texture is NULL
|
|
|
|
* For details, see IWineD3DDevice::GetTexture
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
IDirectDrawSurface7 **Texture)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2011-03-18 19:10:59 +01:00
|
|
|
struct wined3d_texture *wined3d_texture;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, Texture);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Texture)
|
|
|
|
{
|
|
|
|
TRACE("Texture == NULL, failing with DDERR_INVALIDPARAMS\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-03-18 19:10:59 +01:00
|
|
|
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, Stage, &wined3d_texture);
|
|
|
|
if (FAILED(hr) || !wined3d_texture)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
*Texture = NULL;
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-03-18 19:10:59 +01:00
|
|
|
*Texture = wined3d_texture_get_parent(wined3d_texture);
|
2010-08-31 18:41:40 +02:00
|
|
|
IDirectDrawSurface7_AddRef(*Texture);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetTexture_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
IDirectDrawSurface7 **Texture)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_GetTexture(iface, Stage, Texture);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetTexture_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
IDirectDrawSurface7 **Texture)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetTexture(iface, Stage, Texture);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_GetTexture(IDirect3DDevice3 *iface, DWORD Stage,
|
|
|
|
IDirect3DTexture2 **Texture2)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
IDirectDrawSurface7 *ret_val;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, Texture2);
|
|
|
|
|
|
|
|
ret = IDirect3DDevice7_GetTexture((IDirect3DDevice7 *)device_from_device3(iface), Stage, &ret_val);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2009-01-22 10:33:37 +01:00
|
|
|
*Texture2 = ret_val ? (IDirect3DTexture2 *)&((IDirectDrawSurfaceImpl *)ret_val)->IDirect3DTexture2_vtbl : NULL;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("Returning texture %p.\n", *Texture2);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::SetTexture
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Assigns a texture to a texture stage. Is the texture AddRef-ed?
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Version 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Stage: The stage to assign the texture to
|
|
|
|
* Texture: Interface pointer to the texture surface
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* D3D_OK on success
|
|
|
|
* For details, see IWineD3DDevice::SetTexture
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
IDirectDrawSurface7 *Texture)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirectDrawSurfaceImpl *surf = (IDirectDrawSurfaceImpl *)Texture;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, Texture);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Texture may be NULL here */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DDevice_SetTexture(This->wineD3DDevice,
|
2011-03-18 19:10:59 +01:00
|
|
|
Stage, surf ? surf->wined3d_texture : NULL);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetTexture_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
IDirectDrawSurface7 *Texture)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_SetTexture(iface, Stage, Texture);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetTexture_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
IDirectDrawSurface7 *Texture)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_SetTexture(iface, Stage, Texture);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
static HRESULT WINAPI
|
2008-05-05 19:09:40 +02:00
|
|
|
IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
IDirect3DTexture2 *Texture2)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirectDrawSurfaceImpl *tex = Texture2 ? surface_from_texture2(Texture2) : NULL;
|
2008-05-05 19:09:40 +02:00
|
|
|
DWORD texmapblend;
|
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, Texture2);
|
2008-05-05 19:09:40 +02:00
|
|
|
|
2008-05-10 23:19:43 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
|
2008-05-05 19:09:40 +02:00
|
|
|
if (This->legacyTextureBlending)
|
|
|
|
IDirect3DDevice3_GetRenderState(iface, D3DRENDERSTATE_TEXTUREMAPBLEND, &texmapblend);
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
hr = IDirect3DDevice7_SetTexture((IDirect3DDevice7 *)This, Stage, (IDirectDrawSurface7 *)tex);
|
2008-05-05 19:09:40 +02:00
|
|
|
|
|
|
|
if (This->legacyTextureBlending && texmapblend == D3DTBLEND_MODULATE)
|
|
|
|
{
|
|
|
|
/* This fixup is required by the way D3DTBLEND_MODULATE maps to texture stage states.
|
|
|
|
See IDirect3DDeviceImpl_3_SetRenderState for details. */
|
2011-03-18 19:10:59 +01:00
|
|
|
struct wined3d_texture *tex = NULL;
|
2008-05-05 19:09:40 +02:00
|
|
|
BOOL tex_alpha = FALSE;
|
|
|
|
DDPIXELFORMAT ddfmt;
|
|
|
|
HRESULT result;
|
|
|
|
|
2011-03-09 19:16:17 +01:00
|
|
|
result = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex);
|
2008-05-05 19:09:40 +02:00
|
|
|
|
|
|
|
if(result == WINED3D_OK && tex)
|
|
|
|
{
|
2011-03-09 19:16:17 +01:00
|
|
|
struct wined3d_resource *sub_resource;
|
|
|
|
|
2011-03-18 19:10:59 +01:00
|
|
|
if ((sub_resource = wined3d_texture_get_sub_resource(tex, 0)))
|
2008-05-05 19:09:40 +02:00
|
|
|
{
|
2011-03-09 19:16:17 +01:00
|
|
|
struct wined3d_resource_desc desc;
|
|
|
|
|
|
|
|
wined3d_resource_get_desc(sub_resource, &desc);
|
2008-05-05 19:09:40 +02:00
|
|
|
ddfmt.dwSize = sizeof(ddfmt);
|
2009-06-15 09:06:50 +02:00
|
|
|
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
|
2008-05-05 19:09:40 +02:00
|
|
|
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
|
|
|
|
}
|
|
|
|
|
2011-03-18 19:10:59 +01:00
|
|
|
wined3d_texture_decref(tex);
|
2008-05-05 19:09:40 +02:00
|
|
|
}
|
|
|
|
|
2010-02-15 09:48:38 +01:00
|
|
|
/* Arg 1/2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */
|
2008-05-05 19:09:40 +02:00
|
|
|
if (tex_alpha)
|
2010-02-15 09:48:38 +01:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
|
2008-05-05 19:09:40 +02:00
|
|
|
else
|
2010-02-15 09:48:38 +01:00
|
|
|
IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
|
2008-05-05 19:09:40 +02:00
|
|
|
}
|
|
|
|
|
2008-05-10 23:19:43 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
|
2008-05-05 19:09:40 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2009-01-06 11:43:45 +01:00
|
|
|
static const struct tss_lookup
|
|
|
|
{
|
|
|
|
BOOL sampler_state;
|
|
|
|
DWORD state;
|
|
|
|
}
|
|
|
|
tss_lookup[] =
|
|
|
|
{
|
|
|
|
{FALSE, WINED3DTSS_FORCE_DWORD}, /* 0, unused */
|
|
|
|
{FALSE, WINED3DTSS_COLOROP}, /* 1, D3DTSS_COLOROP */
|
|
|
|
{FALSE, WINED3DTSS_COLORARG1}, /* 2, D3DTSS_COLORARG1 */
|
|
|
|
{FALSE, WINED3DTSS_COLORARG2}, /* 3, D3DTSS_COLORARG2 */
|
|
|
|
{FALSE, WINED3DTSS_ALPHAOP}, /* 4, D3DTSS_ALPHAOP */
|
|
|
|
{FALSE, WINED3DTSS_ALPHAARG1}, /* 5, D3DTSS_ALPHAARG1 */
|
|
|
|
{FALSE, WINED3DTSS_ALPHAARG2}, /* 6, D3DTSS_ALPHAARG2 */
|
|
|
|
{FALSE, WINED3DTSS_BUMPENVMAT00}, /* 7, D3DTSS_BUMPENVMAT00 */
|
|
|
|
{FALSE, WINED3DTSS_BUMPENVMAT01}, /* 8, D3DTSS_BUMPENVMAT01 */
|
|
|
|
{FALSE, WINED3DTSS_BUMPENVMAT10}, /* 9, D3DTSS_BUMPENVMAT10 */
|
|
|
|
{FALSE, WINED3DTSS_BUMPENVMAT11}, /* 10, D3DTSS_BUMPENVMAT11 */
|
|
|
|
{FALSE, WINED3DTSS_TEXCOORDINDEX}, /* 11, D3DTSS_TEXCOORDINDEX */
|
|
|
|
{TRUE, WINED3DSAMP_ADDRESSU}, /* 12, D3DTSS_ADDRESS */
|
|
|
|
{TRUE, WINED3DSAMP_ADDRESSU}, /* 13, D3DTSS_ADDRESSU */
|
|
|
|
{TRUE, WINED3DSAMP_ADDRESSV}, /* 14, D3DTSS_ADDRESSV */
|
|
|
|
{TRUE, WINED3DSAMP_BORDERCOLOR}, /* 15, D3DTSS_BORDERCOLOR */
|
|
|
|
{TRUE, WINED3DSAMP_MAGFILTER}, /* 16, D3DTSS_MAGFILTER */
|
|
|
|
{TRUE, WINED3DSAMP_MINFILTER}, /* 17, D3DTSS_MINFILTER */
|
|
|
|
{TRUE, WINED3DSAMP_MIPFILTER}, /* 18, D3DTSS_MIPFILTER */
|
|
|
|
{TRUE, WINED3DSAMP_MIPMAPLODBIAS}, /* 19, D3DTSS_MIPMAPLODBIAS */
|
|
|
|
{TRUE, WINED3DSAMP_MAXMIPLEVEL}, /* 20, D3DTSS_MAXMIPLEVEL */
|
|
|
|
{TRUE, WINED3DSAMP_MAXANISOTROPY}, /* 21, D3DTSS_MAXANISOTROPY */
|
|
|
|
{FALSE, WINED3DTSS_BUMPENVLSCALE}, /* 22, D3DTSS_BUMPENVLSCALE */
|
|
|
|
{FALSE, WINED3DTSS_BUMPENVLOFFSET}, /* 23, D3DTSS_BUMPENVLOFFSET */
|
|
|
|
{FALSE, WINED3DTSS_TEXTURETRANSFORMFLAGS}, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
|
|
|
|
};
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetTextureStageState
|
|
|
|
*
|
|
|
|
* Retrieves a state from a texture stage.
|
|
|
|
*
|
|
|
|
* Version 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Stage: The stage to retrieve the state from
|
|
|
|
* TexStageStateType: The state type to retrieve
|
|
|
|
* State: Address to store the state's value at
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if State is NULL
|
|
|
|
* For details, see IWineD3DDevice::GetTextureStageState
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
D3DTEXTURESTAGESTATETYPE TexStageStateType,
|
|
|
|
DWORD *State)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-09-12 10:34:20 +02:00
|
|
|
const struct tss_lookup *l;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stage %u, state %#x, value %p.\n",
|
|
|
|
iface, Stage, TexStageStateType, State);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!State)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2009-04-01 12:23:00 +02:00
|
|
|
if (TexStageStateType > D3DTSS_TEXTURETRANSFORMFLAGS)
|
|
|
|
{
|
|
|
|
WARN("Invalid TexStageStateType %#x passed.\n", TexStageStateType);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-12 10:34:20 +02:00
|
|
|
l = &tss_lookup[TexStageStateType];
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2009-01-06 11:43:45 +01:00
|
|
|
|
|
|
|
if (l->sampler_state)
|
2007-01-10 11:29:55 +01:00
|
|
|
{
|
2009-01-06 11:43:45 +01:00
|
|
|
hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice, Stage, l->state, State);
|
2007-01-10 11:29:55 +01:00
|
|
|
|
2009-01-06 11:43:45 +01:00
|
|
|
switch(TexStageStateType)
|
|
|
|
{
|
|
|
|
/* Mipfilter is a sampler state with different values */
|
|
|
|
case D3DTSS_MIPFILTER:
|
2007-01-10 11:29:55 +01:00
|
|
|
{
|
2009-01-06 11:43:45 +01:00
|
|
|
switch(*State)
|
|
|
|
{
|
|
|
|
case WINED3DTEXF_NONE: *State = D3DTFP_NONE; break;
|
|
|
|
case WINED3DTEXF_POINT: *State = D3DTFP_POINT; break;
|
|
|
|
case WINED3DTEXF_LINEAR: *State = D3DTFP_LINEAR; break;
|
|
|
|
default:
|
|
|
|
ERR("Unexpected mipfilter value %#x\n", *State);
|
|
|
|
*State = D3DTFP_NONE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2007-01-10 11:29:55 +01:00
|
|
|
}
|
2007-06-03 18:51:50 +02:00
|
|
|
|
2009-01-06 11:43:45 +01:00
|
|
|
/* Magfilter has slightly different values */
|
|
|
|
case D3DTSS_MAGFILTER:
|
2007-04-29 14:23:06 +02:00
|
|
|
{
|
2009-01-06 11:43:45 +01:00
|
|
|
switch(*State)
|
|
|
|
{
|
|
|
|
case WINED3DTEXF_POINT: *State = D3DTFG_POINT; break;
|
|
|
|
case WINED3DTEXF_LINEAR: *State = D3DTFG_LINEAR; break;
|
|
|
|
case WINED3DTEXF_ANISOTROPIC: *State = D3DTFG_ANISOTROPIC; break;
|
|
|
|
case WINED3DTEXF_FLATCUBIC: *State = D3DTFG_FLATCUBIC; break;
|
|
|
|
case WINED3DTEXF_GAUSSIANCUBIC: *State = D3DTFG_GAUSSIANCUBIC; break;
|
|
|
|
default:
|
|
|
|
ERR("Unexpected wined3d mag filter value %#x\n", *State);
|
|
|
|
*State = D3DTFG_POINT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2007-04-29 14:23:06 +02:00
|
|
|
}
|
2009-01-06 11:43:44 +01:00
|
|
|
|
2009-01-06 11:43:45 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, Stage, l->state, State);
|
2007-01-10 11:29:55 +01:00
|
|
|
}
|
2009-01-06 11:43:45 +01:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetTextureStageState_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
D3DTEXTURESTAGESTATETYPE TexStageStateType,
|
|
|
|
DWORD *State)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_GetTextureStageState(iface, Stage, TexStageStateType, State);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetTextureStageState_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
D3DTEXTURESTAGESTATETYPE TexStageStateType,
|
|
|
|
DWORD *State)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetTextureStageState(iface, Stage, TexStageStateType, State);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_GetTextureStageState(IDirect3DDevice3 *iface,
|
|
|
|
DWORD Stage, D3DTEXTURESTAGESTATETYPE TexStageStateType, DWORD *State)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, stage %u, state %#x, value %p.\n",
|
|
|
|
iface, Stage, TexStageStateType, State);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_GetTextureStageState((IDirect3DDevice7 *)device_from_device3(iface),
|
|
|
|
Stage, TexStageStateType, State);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::SetTextureStageState
|
|
|
|
*
|
|
|
|
* Sets a texture stage state. Some stage types need to be handled specially,
|
|
|
|
* because they do not exist in WineD3D and were moved to another place
|
|
|
|
*
|
|
|
|
* Version 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Stage: The stage to modify
|
|
|
|
* TexStageStateType: The state to change
|
|
|
|
* State: The new value for the state
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* For details, see IWineD3DDevice::SetTextureStageState
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
D3DTEXTURESTAGESTATETYPE TexStageStateType,
|
|
|
|
DWORD State)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2010-09-12 10:34:20 +02:00
|
|
|
const struct tss_lookup *l;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stage %u, state %#x, value %#x.\n",
|
|
|
|
iface, Stage, TexStageStateType, State);
|
2007-06-03 18:51:50 +02:00
|
|
|
|
2009-04-01 12:23:00 +02:00
|
|
|
if (TexStageStateType > D3DTSS_TEXTURETRANSFORMFLAGS)
|
|
|
|
{
|
|
|
|
WARN("Invalid TexStageStateType %#x passed.\n", TexStageStateType);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-12 10:34:20 +02:00
|
|
|
l = &tss_lookup[TexStageStateType];
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2009-01-06 11:43:45 +01:00
|
|
|
|
|
|
|
if (l->sampler_state)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-06 11:43:45 +01:00
|
|
|
switch(TexStageStateType)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-06 11:43:45 +01:00
|
|
|
/* Mipfilter is a sampler state with different values */
|
|
|
|
case D3DTSS_MIPFILTER:
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-06 11:43:45 +01:00
|
|
|
switch(State)
|
|
|
|
{
|
|
|
|
case D3DTFP_NONE: State = WINED3DTEXF_NONE; break;
|
|
|
|
case D3DTFP_POINT: State = WINED3DTEXF_POINT; break;
|
|
|
|
case 0: /* Unchecked */
|
|
|
|
case D3DTFP_LINEAR: State = WINED3DTEXF_LINEAR; break;
|
|
|
|
default:
|
|
|
|
ERR("Unexpected mipfilter value %d\n", State);
|
|
|
|
State = WINED3DTEXF_NONE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2009-01-06 11:43:45 +01:00
|
|
|
/* Magfilter has slightly different values */
|
|
|
|
case D3DTSS_MAGFILTER:
|
2007-04-29 14:23:06 +02:00
|
|
|
{
|
2009-01-06 11:43:45 +01:00
|
|
|
switch(State)
|
|
|
|
{
|
|
|
|
case D3DTFG_POINT: State = WINED3DTEXF_POINT; break;
|
|
|
|
case D3DTFG_LINEAR: State = WINED3DTEXF_LINEAR; break;
|
|
|
|
case D3DTFG_FLATCUBIC: State = WINED3DTEXF_FLATCUBIC; break;
|
|
|
|
case D3DTFG_GAUSSIANCUBIC: State = WINED3DTEXF_GAUSSIANCUBIC; break;
|
|
|
|
case D3DTFG_ANISOTROPIC: State = WINED3DTEXF_ANISOTROPIC; break;
|
|
|
|
default:
|
|
|
|
ERR("Unexpected d3d7 mag filter type %d\n", State);
|
|
|
|
State = WINED3DTEXF_POINT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2007-04-29 14:23:06 +02:00
|
|
|
}
|
2009-01-06 11:43:44 +01:00
|
|
|
|
2009-01-06 11:43:45 +01:00
|
|
|
case D3DTSS_ADDRESS:
|
|
|
|
IWineD3DDevice_SetSamplerState(This->wineD3DDevice, Stage, WINED3DSAMP_ADDRESSV, State);
|
|
|
|
break;
|
2009-01-06 11:43:44 +01:00
|
|
|
|
2009-01-06 11:43:45 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-01-06 11:43:44 +01:00
|
|
|
|
2009-01-06 11:43:45 +01:00
|
|
|
hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice, Stage, l->state, State);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2009-01-06 11:43:45 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, Stage, l->state, State);
|
|
|
|
}
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetTextureStageState_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
D3DTEXTURESTAGESTATETYPE TexStageStateType,
|
|
|
|
DWORD State)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_SetTextureStageState(iface, Stage, TexStageStateType, State);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetTextureStageState_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Stage,
|
|
|
|
D3DTEXTURESTAGESTATETYPE TexStageStateType,
|
|
|
|
DWORD State)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_SetTextureStageState(iface, Stage, TexStageStateType, State);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_SetTextureStageState(IDirect3DDevice3 *iface,
|
|
|
|
DWORD Stage, D3DTEXTURESTAGESTATETYPE TexStageStateType, DWORD State)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, stage %u, state %#x, value %#x.\n",
|
|
|
|
iface, Stage, TexStageStateType, State);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_SetTextureStageState((IDirect3DDevice7 *)device_from_device3(iface),
|
|
|
|
Stage, TexStageStateType, State);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::ValidateDevice
|
|
|
|
*
|
|
|
|
* SDK: "Reports the device's ability to render the currently set
|
|
|
|
* texture-blending operations in a single pass". Whatever that means
|
|
|
|
* exactly...
|
|
|
|
*
|
|
|
|
* Version 3 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
2006-06-23 18:18:02 +02:00
|
|
|
* NumPasses: Address to write the number of necessary passes for the
|
2006-06-09 19:36:12 +02:00
|
|
|
* desired effect to.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* See IWineD3DDevice::ValidateDevice for more details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7 *iface,
|
|
|
|
DWORD *NumPasses)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, pass_count %p.\n", iface, NumPasses);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DDevice_ValidateDevice(This->wineD3DDevice, NumPasses);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_ValidateDevice_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD *NumPasses)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_ValidateDevice(iface, NumPasses);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_ValidateDevice_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD *NumPasses)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_ValidateDevice(iface, NumPasses);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-20 02:06:25 +01:00
|
|
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_ValidateDevice(IDirect3DDevice3 *iface, DWORD *Passes)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, pass_count %p.\n", iface, Passes);
|
|
|
|
|
|
|
|
return IDirect3DDevice7_ValidateDevice((IDirect3DDevice7 *)device_from_device3(iface), Passes);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::Clear
|
|
|
|
*
|
|
|
|
* Fills the render target, the z buffer and the stencil buffer with a
|
|
|
|
* clear color / value
|
|
|
|
*
|
|
|
|
* Version 7 only
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Count: Number of rectangles in Rects must be 0 if Rects is NULL
|
|
|
|
* Rects: Rectangles to clear. If NULL, the whole surface is cleared
|
|
|
|
* Flags: Some flags, as usual
|
|
|
|
* Color: Clear color for the render target
|
|
|
|
* Z: Clear value for the Z buffer
|
|
|
|
* Stencil: Clear value to store in each stencil buffer entry
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* For details, see IWineD3DDevice::Clear
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Count,
|
|
|
|
D3DRECT *Rects,
|
|
|
|
DWORD Flags,
|
|
|
|
D3DCOLOR Color,
|
|
|
|
D3DVALUE Z,
|
|
|
|
DWORD Stencil)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %#x.\n",
|
|
|
|
iface, Count, Rects, Flags, Color, Z, Stencil);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-08-30 20:29:47 +02:00
|
|
|
hr = IWineD3DDevice_Clear(This->wineD3DDevice, Count, (RECT *)Rects, Flags, Color, Z, Stencil);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_Clear_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Count,
|
|
|
|
D3DRECT *Rects,
|
|
|
|
DWORD Flags,
|
|
|
|
D3DCOLOR Color,
|
|
|
|
D3DVALUE Z,
|
|
|
|
DWORD Stencil)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_Clear(iface, Count, Rects, Flags, Color, Z, Stencil);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_Clear_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Count,
|
|
|
|
D3DRECT *Rects,
|
|
|
|
DWORD Flags,
|
|
|
|
D3DCOLOR Color,
|
|
|
|
D3DVALUE Z,
|
|
|
|
DWORD Stencil)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_Clear(iface, Count, Rects, Flags, Color, Z, Stencil);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::SetViewport
|
|
|
|
*
|
|
|
|
* Sets the current viewport.
|
|
|
|
*
|
|
|
|
* Version 7 only, but IDirect3DViewport uses this call for older
|
|
|
|
* versions
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Data: The new viewport to set
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Data is NULL
|
|
|
|
* For more details, see IWineDDDevice::SetViewport
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7 *iface,
|
|
|
|
D3DVIEWPORT7 *Data)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Data);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Data)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2006-10-11 03:57:25 +02:00
|
|
|
/* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DDevice_SetViewport(This->wineD3DDevice,
|
|
|
|
(WINED3DVIEWPORT*) Data);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetViewport_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DVIEWPORT7 *Data)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_SetViewport(iface, Data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetViewport_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DVIEWPORT7 *Data)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_SetViewport(iface, Data);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice::GetViewport
|
|
|
|
*
|
|
|
|
* Returns the current viewport
|
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Data: D3D7Viewport structure to write the viewport information to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Data is NULL
|
|
|
|
* For more details, see IWineD3DDevice::GetViewport
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7 *iface,
|
|
|
|
D3DVIEWPORT7 *Data)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p.\n", iface, Data);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Data)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2006-10-11 03:57:25 +02:00
|
|
|
/* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
hr = IWineD3DDevice_GetViewport(This->wineD3DDevice,
|
2006-10-11 03:57:25 +02:00
|
|
|
(WINED3DVIEWPORT*) Data);
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetViewport_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DVIEWPORT7 *Data)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_GetViewport(iface, Data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetViewport_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DVIEWPORT7 *Data)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetViewport(iface, Data);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::SetMaterial
|
|
|
|
*
|
|
|
|
* Sets the Material
|
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Mat: The material to set
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Mat is NULL.
|
|
|
|
* For more details, see IWineD3DDevice::SetMaterial
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7 *iface,
|
|
|
|
D3DMATERIAL7 *Mat)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, material %p.\n", iface, Mat);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2008-08-21 18:54:27 +02:00
|
|
|
if (!Mat) return DDERR_INVALIDPARAMS;
|
2006-10-11 03:56:41 +02:00
|
|
|
/* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
hr = IWineD3DDevice_SetMaterial(This->wineD3DDevice,
|
2006-10-11 03:56:41 +02:00
|
|
|
(WINED3DMATERIAL*) Mat);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetMaterial_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DMATERIAL7 *Mat)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_SetMaterial(iface, Mat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetMaterial_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DMATERIAL7 *Mat)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_SetMaterial(iface, Mat);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetMaterial
|
|
|
|
*
|
|
|
|
* Returns the current material
|
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
2006-06-23 18:18:02 +02:00
|
|
|
* Mat: D3DMATERIAL7 structure to write the material parameters to
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Mat is NULL
|
|
|
|
* For more details, see IWineD3DDevice::GetMaterial
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7 *iface,
|
|
|
|
D3DMATERIAL7 *Mat)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, material %p.\n", iface, Mat);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2009-09-01 09:09:37 +02:00
|
|
|
/* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
|
2006-06-09 19:36:12 +02:00
|
|
|
hr = IWineD3DDevice_GetMaterial(This->wineD3DDevice,
|
2006-10-11 03:56:41 +02:00
|
|
|
(WINED3DMATERIAL*) Mat);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetMaterial_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DMATERIAL7 *Mat)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_GetMaterial(iface, Mat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetMaterial_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DMATERIAL7 *Mat)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetMaterial(iface, Mat);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::SetLight
|
|
|
|
*
|
|
|
|
* Assigns a light to a light index, but doesn't activate it yet.
|
|
|
|
*
|
|
|
|
* Version 7, IDirect3DLight uses this method for older versions
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* LightIndex: The index of the new light
|
|
|
|
* Light: A D3DLIGHT7 structure describing the light
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* For more details, see IWineD3DDevice::SetLight
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
D3DLIGHT7 *Light)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, light_idx %u, light %p.\n", iface, LightIndex, Light);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-10-11 03:55:47 +02:00
|
|
|
/* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
|
2006-06-09 19:36:12 +02:00
|
|
|
hr = IWineD3DDevice_SetLight(This->wineD3DDevice,
|
|
|
|
LightIndex,
|
2006-10-11 03:55:47 +02:00
|
|
|
(WINED3DLIGHT*) Light);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetLight_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
D3DLIGHT7 *Light)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_SetLight(iface, LightIndex, Light);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetLight_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
D3DLIGHT7 *Light)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_SetLight(iface, LightIndex, Light);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetLight
|
|
|
|
*
|
|
|
|
* Returns the light assigned to a light index
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Light: Structure to write the light information to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Light is NULL
|
|
|
|
* For details, see IWineD3DDevice::GetLight
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
D3DLIGHT7 *Light)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT rc;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, light_idx %u, light %p.\n", iface, LightIndex, Light);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-10-11 03:55:47 +02:00
|
|
|
/* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
|
2006-06-09 19:36:12 +02:00
|
|
|
rc = IWineD3DDevice_GetLight(This->wineD3DDevice,
|
|
|
|
LightIndex,
|
2006-10-11 03:55:47 +02:00
|
|
|
(WINED3DLIGHT*) Light);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Translate the result. WineD3D returns other values than D3D7 */
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(rc);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetLight_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
D3DLIGHT7 *Light)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_GetLight(iface, LightIndex, Light);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetLight_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
D3DLIGHT7 *Light)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetLight(iface, LightIndex, Light);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::BeginStateBlock
|
|
|
|
*
|
|
|
|
* Begins recording to a stateblock
|
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* For details see IWineD3DDevice::BeginStateBlock
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7 *iface)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
hr = IWineD3DDevice_BeginStateBlock(This->wineD3DDevice);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_BeginStateBlock_FPUSetup(IDirect3DDevice7 *iface)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_BeginStateBlock(iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_BeginStateBlock_FPUPreserve(IDirect3DDevice7 *iface)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_BeginStateBlock(iface);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::EndStateBlock
|
|
|
|
*
|
|
|
|
* Stops recording to a state block and returns the created stateblock
|
2006-10-14 23:58:42 +02:00
|
|
|
* handle.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* BlockHandle: Address to store the stateblock's handle to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if BlockHandle is NULL
|
|
|
|
* See IWineD3DDevice::EndStateBlock for more details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
|
|
|
|
DWORD *BlockHandle)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2011-01-28 20:05:41 +01:00
|
|
|
struct wined3d_stateblock *wined3d_sb;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-07-30 10:15:23 +02:00
|
|
|
DWORD h;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, stateblock %p.\n", iface, BlockHandle);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!BlockHandle)
|
2006-10-14 23:58:42 +02:00
|
|
|
{
|
|
|
|
WARN("BlockHandle == NULL, returning DDERR_INVALIDPARAMS\n");
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-10-14 23:58:42 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-30 10:15:23 +02:00
|
|
|
|
|
|
|
hr = IWineD3DDevice_EndStateBlock(This->wineD3DDevice, &wined3d_sb);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to end stateblock, hr %#x.\n", hr);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
*BlockHandle = 0;
|
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
h = ddraw_allocate_handle(&This->handle_table, wined3d_sb, DDRAW_HANDLE_STATEBLOCK);
|
|
|
|
if (h == DDRAW_INVALID_HANDLE)
|
2006-10-14 23:58:42 +02:00
|
|
|
{
|
2010-07-30 10:15:23 +02:00
|
|
|
ERR("Failed to allocate a stateblock handle.\n");
|
2011-01-28 20:05:41 +01:00
|
|
|
wined3d_stateblock_decref(wined3d_sb);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2010-07-30 10:15:23 +02:00
|
|
|
*BlockHandle = 0;
|
2006-10-14 23:58:42 +02:00
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
2010-07-30 10:15:23 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2010-07-30 10:15:23 +02:00
|
|
|
*BlockHandle = h + 1;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_EndStateBlock_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD *BlockHandle)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_EndStateBlock(iface, BlockHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_EndStateBlock_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD *BlockHandle)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_EndStateBlock(iface, BlockHandle);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::PreLoad
|
|
|
|
*
|
|
|
|
* Allows the app to signal that a texture will be used soon, to allow
|
|
|
|
* the Direct3DDevice to load it to the video card in the meantime.
|
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Texture: The texture to preload
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Texture is NULL
|
|
|
|
* See IWineD3DSurface::PreLoad for details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7 *iface,
|
|
|
|
IDirectDrawSurface7 *Texture)
|
|
|
|
{
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirectDrawSurfaceImpl *surf = (IDirectDrawSurfaceImpl *)Texture;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, texture %p.\n", iface, Texture);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Texture)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_preload(surf->wined3d_surface);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_PreLoad_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
IDirectDrawSurface7 *Texture)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_PreLoad(iface, Texture);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_PreLoad_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
IDirectDrawSurface7 *Texture)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_PreLoad(iface, Texture);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::ApplyStateBlock
|
|
|
|
*
|
|
|
|
* Activates the state stored in a state block handle.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* BlockHandle: The stateblock handle to activate
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7 *iface,
|
|
|
|
DWORD BlockHandle)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2011-01-28 20:05:41 +01:00
|
|
|
struct wined3d_stateblock *wined3d_sb;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stateblock %#x.\n", iface, BlockHandle);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-30 10:15:23 +02:00
|
|
|
|
|
|
|
wined3d_sb = ddraw_get_object(&This->handle_table, BlockHandle - 1, DDRAW_HANDLE_STATEBLOCK);
|
|
|
|
if (!wined3d_sb)
|
2006-10-14 23:58:42 +02:00
|
|
|
{
|
2010-07-30 10:15:23 +02:00
|
|
|
WARN("Invalid stateblock handle.\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3DERR_INVALIDSTATEBLOCK;
|
2006-10-14 23:58:42 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-01-28 20:05:41 +01:00
|
|
|
hr = wined3d_stateblock_apply(wined3d_sb);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2010-07-30 10:15:23 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_ApplyStateBlock_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD BlockHandle)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_ApplyStateBlock(iface, BlockHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_ApplyStateBlock_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD BlockHandle)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_ApplyStateBlock(iface, BlockHandle);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::CaptureStateBlock
|
|
|
|
*
|
|
|
|
* Updates a stateblock's values to the values currently set for the device
|
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* BlockHandle: Stateblock to update
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* D3DERR_INVALIDSTATEBLOCK if BlockHandle is NULL
|
|
|
|
* See IWineD3DDevice::CaptureStateBlock for more details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7 *iface,
|
|
|
|
DWORD BlockHandle)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2011-01-28 20:05:41 +01:00
|
|
|
struct wined3d_stateblock *wined3d_sb;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stateblock %#x.\n", iface, BlockHandle);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-30 10:15:23 +02:00
|
|
|
|
|
|
|
wined3d_sb = ddraw_get_object(&This->handle_table, BlockHandle - 1, DDRAW_HANDLE_STATEBLOCK);
|
|
|
|
if (!wined3d_sb)
|
2006-10-14 23:58:42 +02:00
|
|
|
{
|
2010-07-30 10:15:23 +02:00
|
|
|
WARN("Invalid stateblock handle.\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-10-14 23:58:42 +02:00
|
|
|
return D3DERR_INVALIDSTATEBLOCK;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-01-28 20:05:41 +01:00
|
|
|
hr = wined3d_stateblock_capture(wined3d_sb);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_CaptureStateBlock_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD BlockHandle)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_CaptureStateBlock(iface, BlockHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_CaptureStateBlock_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD BlockHandle)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_CaptureStateBlock(iface, BlockHandle);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::DeleteStateBlock
|
|
|
|
*
|
|
|
|
* Deletes a stateblock handle. This means releasing the WineD3DStateBlock
|
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* BlockHandle: Stateblock handle to delete
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* D3DERR_INVALIDSTATEBLOCK if BlockHandle is 0
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7 *iface,
|
|
|
|
DWORD BlockHandle)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2011-01-28 20:05:41 +01:00
|
|
|
struct wined3d_stateblock *wined3d_sb;
|
2006-10-14 23:58:42 +02:00
|
|
|
ULONG ref;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stateblock %#x.\n", iface, BlockHandle);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-30 10:15:23 +02:00
|
|
|
|
|
|
|
wined3d_sb = ddraw_free_handle(&This->handle_table, BlockHandle - 1, DDRAW_HANDLE_STATEBLOCK);
|
|
|
|
if (!wined3d_sb)
|
2006-10-14 23:58:42 +02:00
|
|
|
{
|
2010-07-30 10:15:23 +02:00
|
|
|
WARN("Invalid stateblock handle.\n");
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-10-14 23:58:42 +02:00
|
|
|
return D3DERR_INVALIDSTATEBLOCK;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-01-28 20:05:41 +01:00
|
|
|
if ((ref = wined3d_stateblock_decref(wined3d_sb)))
|
2006-10-14 23:58:42 +02:00
|
|
|
{
|
2010-07-30 10:15:23 +02:00
|
|
|
ERR("Something is still holding stateblock %p (refcount %u).\n", wined3d_sb, ref);
|
2006-10-14 23:58:42 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DeleteStateBlock_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD BlockHandle)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_DeleteStateBlock(iface, BlockHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_DeleteStateBlock_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD BlockHandle)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_DeleteStateBlock(iface, BlockHandle);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::CreateStateBlock
|
|
|
|
*
|
|
|
|
* Creates a new state block handle.
|
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Type: The state block type
|
|
|
|
* BlockHandle: Address to write the created handle to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if BlockHandle is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
|
|
|
|
D3DSTATEBLOCKTYPE Type,
|
|
|
|
DWORD *BlockHandle)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2011-01-28 20:05:41 +01:00
|
|
|
struct wined3d_stateblock *wined3d_sb;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-07-30 10:15:23 +02:00
|
|
|
DWORD h;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, type %#x, stateblock %p.\n", iface, Type, BlockHandle);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!BlockHandle)
|
2006-10-14 23:58:42 +02:00
|
|
|
{
|
|
|
|
WARN("BlockHandle == NULL, returning DDERR_INVALIDPARAMS\n");
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-10-14 23:58:42 +02:00
|
|
|
}
|
2007-08-03 22:48:42 +02:00
|
|
|
if(Type != D3DSBT_ALL && Type != D3DSBT_PIXELSTATE &&
|
|
|
|
Type != D3DSBT_VERTEXSTATE ) {
|
|
|
|
WARN("Unexpected stateblock type, returning DDERR_INVALIDPARAMS\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2006-10-14 23:58:42 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-30 10:15:23 +02:00
|
|
|
|
|
|
|
/* The D3DSTATEBLOCKTYPE enum is fine here. */
|
2011-05-10 21:18:47 +02:00
|
|
|
hr = wined3d_stateblock_create(This->wineD3DDevice, Type, &wined3d_sb);
|
2010-07-30 10:15:23 +02:00
|
|
|
if (FAILED(hr))
|
2006-10-14 23:58:42 +02:00
|
|
|
{
|
2010-07-30 10:15:23 +02:00
|
|
|
WARN("Failed to create stateblock, hr %#x.\n", hr);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
h = ddraw_allocate_handle(&This->handle_table, wined3d_sb, DDRAW_HANDLE_STATEBLOCK);
|
|
|
|
if (h == DDRAW_INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate stateblock handle.\n");
|
2011-01-28 20:05:41 +01:00
|
|
|
wined3d_stateblock_decref(wined3d_sb);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-10-14 23:58:42 +02:00
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-07-30 10:15:23 +02:00
|
|
|
*BlockHandle = h + 1;
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2010-07-30 10:15:23 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_CreateStateBlock_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
D3DSTATEBLOCKTYPE Type,
|
|
|
|
DWORD *BlockHandle)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_CreateStateBlock(iface, Type, BlockHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_CreateStateBlock_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
D3DSTATEBLOCKTYPE Type,
|
|
|
|
DWORD *BlockHandle)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr =IDirect3DDeviceImpl_7_CreateStateBlock(iface, Type, BlockHandle);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-05-05 23:49:28 +02:00
|
|
|
/* Helper function for IDirect3DDeviceImpl_7_Load. */
|
|
|
|
static BOOL is_mip_level_subset(IDirectDrawSurfaceImpl *dest,
|
|
|
|
IDirectDrawSurfaceImpl *src)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *src_level, *dest_level;
|
|
|
|
IDirectDrawSurface7 *temp;
|
|
|
|
DDSURFACEDESC2 ddsd;
|
|
|
|
BOOL levelFound; /* at least one suitable sublevel in dest found */
|
|
|
|
|
|
|
|
/* To satisfy "destination is mip level subset of source" criteria (regular texture counts as 1 level),
|
|
|
|
* 1) there must be at least one mip level in destination that matched dimensions of some mip level in source and
|
|
|
|
* 2) there must be no destination levels that don't match any levels in source. Otherwise it's INVALIDPARAMS.
|
|
|
|
*/
|
|
|
|
levelFound = FALSE;
|
|
|
|
|
|
|
|
src_level = src;
|
|
|
|
dest_level = dest;
|
|
|
|
|
|
|
|
for (;src_level && dest_level;)
|
|
|
|
{
|
|
|
|
if (src_level->surface_desc.dwWidth == dest_level->surface_desc.dwWidth &&
|
|
|
|
src_level->surface_desc.dwHeight == dest_level->surface_desc.dwHeight)
|
|
|
|
{
|
|
|
|
levelFound = TRUE;
|
|
|
|
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
|
|
ddsd.ddsCaps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL;
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)dest_level, &ddsd.ddsCaps, &temp);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
if (dest_level != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_level);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-22 10:33:37 +01:00
|
|
|
dest_level = (IDirectDrawSurfaceImpl *)temp;
|
2008-05-05 23:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
|
|
ddsd.ddsCaps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL;
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)src_level, &ddsd.ddsCaps, &temp);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
if (src_level != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_level);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-22 10:33:37 +01:00
|
|
|
src_level = (IDirectDrawSurfaceImpl *)temp;
|
2008-05-05 23:49:28 +02:00
|
|
|
}
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
if (src_level && src_level != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_level);
|
|
|
|
if (dest_level && dest_level != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_level);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
|
|
|
return !dest_level && levelFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function for IDirect3DDeviceImpl_7_Load. */
|
|
|
|
static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
|
|
|
|
IDirectDrawSurfaceImpl *dest,
|
|
|
|
IDirectDrawSurfaceImpl *src,
|
2009-07-23 22:46:45 +02:00
|
|
|
const POINT *DestPoint,
|
|
|
|
const RECT *SrcRect)
|
2008-05-05 23:49:28 +02:00
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *src_level, *dest_level;
|
|
|
|
IDirectDrawSurface7 *temp;
|
|
|
|
DDSURFACEDESC2 ddsd;
|
|
|
|
POINT point;
|
|
|
|
RECT rect;
|
|
|
|
HRESULT hr;
|
|
|
|
IDirectDrawPalette *pal = NULL, *pal_src = NULL;
|
|
|
|
DWORD ckeyflag;
|
|
|
|
DDCOLORKEY ddckey;
|
2008-07-20 22:28:44 +02:00
|
|
|
BOOL palette_missing = FALSE;
|
|
|
|
|
|
|
|
/* Copy palette, if possible. */
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_GetPalette((IDirectDrawSurface7 *)src, &pal_src);
|
|
|
|
IDirectDrawSurface7_GetPalette((IDirectDrawSurface7 *)dest, &pal);
|
2008-07-20 22:28:44 +02:00
|
|
|
|
|
|
|
if (pal_src != NULL && pal != NULL)
|
|
|
|
{
|
|
|
|
PALETTEENTRY palent[256];
|
|
|
|
|
|
|
|
IDirectDrawPalette_GetEntries(pal_src, 0, 0, 256, palent);
|
|
|
|
IDirectDrawPalette_SetEntries(pal, 0, 0, 256, palent);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dest->surface_desc.u4.ddpfPixelFormat.dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 |
|
|
|
|
DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8 | DDPF_PALETTEINDEXEDTO8) && !pal)
|
|
|
|
{
|
|
|
|
palette_missing = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pal) IDirectDrawPalette_Release(pal);
|
|
|
|
if (pal_src) IDirectDrawPalette_Release(pal_src);
|
|
|
|
|
|
|
|
/* Copy colorkeys, if present. */
|
|
|
|
for (ckeyflag = DDCKEY_DESTBLT; ckeyflag <= DDCKEY_SRCOVERLAY; ckeyflag <<= 1)
|
|
|
|
{
|
2009-01-21 09:56:13 +01:00
|
|
|
hr = IDirectDrawSurface7_GetColorKey((IDirectDrawSurface7 *)src, ckeyflag, &ddckey);
|
2008-07-20 22:28:44 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_SetColorKey((IDirectDrawSurface7 *)dest, ckeyflag, &ddckey);
|
2008-07-20 22:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
2008-05-05 23:49:28 +02:00
|
|
|
|
|
|
|
src_level = src;
|
|
|
|
dest_level = dest;
|
|
|
|
|
|
|
|
point = *DestPoint;
|
|
|
|
rect = *SrcRect;
|
|
|
|
|
|
|
|
for (;src_level && dest_level;)
|
|
|
|
{
|
|
|
|
if (src_level->surface_desc.dwWidth == dest_level->surface_desc.dwWidth &&
|
|
|
|
src_level->surface_desc.dwHeight == dest_level->surface_desc.dwHeight)
|
|
|
|
{
|
2008-07-27 22:05:11 +02:00
|
|
|
/* Try UpdateSurface that may perform a more direct opengl loading. But skip this if destination is paletted texture and has no palette.
|
2008-07-20 22:28:44 +02:00
|
|
|
* Some games like Sacrifice set palette after Load, and it is a waste of effort to try to load texture without palette and generates
|
|
|
|
* warnings in wined3d. */
|
2010-09-08 11:24:49 +02:00
|
|
|
if (!palette_missing)
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = IWineD3DDevice_UpdateSurface(device->wineD3DDevice, src_level->wined3d_surface,
|
|
|
|
&rect, dest_level->wined3d_surface, &point);
|
2008-07-20 22:28:44 +02:00
|
|
|
|
|
|
|
if (palette_missing || FAILED(hr))
|
2008-05-05 23:49:28 +02:00
|
|
|
{
|
|
|
|
/* UpdateSurface may fail e.g. if dest is in system memory. Fall back to BltFast that is less strict. */
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_bltfast(dest_level->wined3d_surface, point.x, point.y,
|
|
|
|
src_level->wined3d_surface, &rect, 0);
|
2008-05-05 23:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
|
|
ddsd.ddsCaps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL;
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)dest_level, &ddsd.ddsCaps, &temp);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
if (dest_level != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_level);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-22 10:33:37 +01:00
|
|
|
dest_level = (IDirectDrawSurfaceImpl *)temp;
|
2008-05-05 23:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
|
|
ddsd.ddsCaps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL;
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)src_level, &ddsd.ddsCaps, &temp);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
if (src_level != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_level);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-22 10:33:37 +01:00
|
|
|
src_level = (IDirectDrawSurfaceImpl *)temp;
|
2008-05-05 23:49:28 +02:00
|
|
|
|
|
|
|
point.x /= 2;
|
|
|
|
point.y /= 2;
|
|
|
|
|
|
|
|
rect.top /= 2;
|
|
|
|
rect.left /= 2;
|
|
|
|
rect.right = (rect.right + 1) / 2;
|
|
|
|
rect.bottom = (rect.bottom + 1) / 2;
|
|
|
|
}
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
if (src_level && src_level != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_level);
|
|
|
|
if (dest_level && dest_level != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_level);
|
2008-05-05 23:49:28 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::Load
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Loads a rectangular area from the source into the destination texture.
|
2006-06-09 19:36:12 +02:00
|
|
|
* It can also copy the source to the faces of a cubic environment map
|
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DestTex: Destination texture
|
|
|
|
* DestPoint: Point in the destination where the source image should be
|
|
|
|
* written to
|
|
|
|
* SrcTex: Source texture
|
|
|
|
* SrcRect: Source rectangle
|
2008-05-05 23:49:28 +02:00
|
|
|
* Flags: Cubemap faces to load (DDSCAPS2_CUBEMAP_ALLFACES, DDSCAPS2_CUBEMAP_POSITIVEX,
|
|
|
|
* DDSCAPS2_CUBEMAP_NEGATIVEX, DDSCAPS2_CUBEMAP_POSITIVEY, DDSCAPS2_CUBEMAP_NEGATIVEY,
|
|
|
|
* DDSCAPS2_CUBEMAP_POSITIVEZ, DDSCAPS2_CUBEMAP_NEGATIVEZ)
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
2008-05-05 23:49:28 +02:00
|
|
|
* DDERR_INVALIDPARAMS if DestTex or SrcTex are NULL, broken coordinates or anything unexpected.
|
|
|
|
*
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
|
|
|
|
IDirectDrawSurface7 *DestTex,
|
|
|
|
POINT *DestPoint,
|
|
|
|
IDirectDrawSurface7 *SrcTex,
|
|
|
|
RECT *SrcRect,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirectDrawSurfaceImpl *dest = (IDirectDrawSurfaceImpl *)DestTex;
|
|
|
|
IDirectDrawSurfaceImpl *src = (IDirectDrawSurfaceImpl *)SrcTex;
|
2008-05-05 23:49:28 +02:00
|
|
|
POINT destpoint;
|
|
|
|
RECT srcrect;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, dst_texture %p, dst_pos %s, src_texture %p, src_rect %s, flags %#x.\n",
|
|
|
|
iface, DestTex, wine_dbgstr_point(DestPoint), SrcTex, wine_dbgstr_rect(SrcRect), Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if( (!src) || (!dest) )
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2008-05-05 23:49:28 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
|
|
|
|
if (SrcRect) srcrect = *SrcRect;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
srcrect.left = srcrect.top = 0;
|
|
|
|
srcrect.right = src->surface_desc.dwWidth;
|
|
|
|
srcrect.bottom = src->surface_desc.dwHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DestPoint) destpoint = *DestPoint;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
destpoint.x = destpoint.y = 0;
|
|
|
|
}
|
|
|
|
/* Check bad dimensions. DestPoint is validated against src, not dest, because
|
|
|
|
* destination can be a subset of mip levels, in which case actual coordinates used
|
|
|
|
* for it may be divided. If any dimension of dest is larger than source, it can't be
|
|
|
|
* mip level subset, so an error can be returned early.
|
|
|
|
*/
|
|
|
|
if (srcrect.left >= srcrect.right || srcrect.top >= srcrect.bottom ||
|
|
|
|
srcrect.right > src->surface_desc.dwWidth ||
|
|
|
|
srcrect.bottom > src->surface_desc.dwHeight ||
|
|
|
|
destpoint.x + srcrect.right - srcrect.left > src->surface_desc.dwWidth ||
|
|
|
|
destpoint.y + srcrect.bottom - srcrect.top > src->surface_desc.dwHeight ||
|
|
|
|
dest->surface_desc.dwWidth > src->surface_desc.dwWidth ||
|
|
|
|
dest->surface_desc.dwHeight > src->surface_desc.dwHeight)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Must be top level surfaces. */
|
|
|
|
if (src->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL ||
|
|
|
|
dest->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
|
|
|
{
|
|
|
|
DWORD src_face_flag, dest_face_flag;
|
|
|
|
IDirectDrawSurfaceImpl *src_face, *dest_face;
|
|
|
|
IDirectDrawSurface7 *temp;
|
|
|
|
DDSURFACEDESC2 ddsd;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!(dest->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Iterate through cube faces 2 times. First time is just to check INVALIDPARAMS conditions, second
|
|
|
|
* time it's actual surface loading. */
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
dest_face = dest;
|
|
|
|
src_face = src;
|
|
|
|
|
|
|
|
for (;dest_face && src_face;)
|
|
|
|
{
|
|
|
|
src_face_flag = src_face->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP_ALLFACES;
|
|
|
|
dest_face_flag = dest_face->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP_ALLFACES;
|
|
|
|
|
|
|
|
if (src_face_flag == dest_face_flag)
|
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
/* Destination mip levels must be subset of source mip levels. */
|
|
|
|
if (!is_mip_level_subset(dest_face, src_face))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Flags & dest_face_flag)
|
|
|
|
{
|
|
|
|
copy_mipmap_chain(This, dest_face, src_face, &destpoint, &srcrect);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src_face_flag < DDSCAPS2_CUBEMAP_NEGATIVEZ)
|
|
|
|
{
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
|
|
ddsd.ddsCaps.dwCaps2 = DDSCAPS2_CUBEMAP | (src_face_flag << 1);
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)src, &ddsd.ddsCaps, &temp);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
if (src_face != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_face);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-22 10:33:37 +01:00
|
|
|
src_face = (IDirectDrawSurfaceImpl *)temp;
|
2008-05-05 23:49:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-21 09:56:13 +01:00
|
|
|
if (src_face != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_face);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
|
|
|
src_face = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dest_face_flag < DDSCAPS2_CUBEMAP_NEGATIVEZ)
|
|
|
|
{
|
|
|
|
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
|
|
ddsd.ddsCaps.dwCaps2 = DDSCAPS2_CUBEMAP | (dest_face_flag << 1);
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)dest, &ddsd.ddsCaps, &temp);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
if (dest_face != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_face);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
2009-01-22 10:33:37 +01:00
|
|
|
dest_face = (IDirectDrawSurfaceImpl *)temp;
|
2008-05-05 23:49:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-21 09:56:13 +01:00
|
|
|
if (dest_face != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_face);
|
2008-05-05 23:49:28 +02:00
|
|
|
|
|
|
|
dest_face = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
/* Native returns error if src faces are not subset of dest faces. */
|
|
|
|
if (src_face)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
else if (dest->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle non cube map textures. */
|
|
|
|
|
|
|
|
/* Destination mip levels must be subset of source mip levels. */
|
|
|
|
if (!is_mip_level_subset(dest, src))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
copy_mipmap_chain(This, dest, src, &destpoint, &srcrect);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_Load_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
IDirectDrawSurface7 *DestTex,
|
|
|
|
POINT *DestPoint,
|
|
|
|
IDirectDrawSurface7 *SrcTex,
|
|
|
|
RECT *SrcRect,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_Load(iface, DestTex, DestPoint, SrcTex, SrcRect, Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_Load_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
IDirectDrawSurface7 *DestTex,
|
|
|
|
POINT *DestPoint,
|
|
|
|
IDirectDrawSurface7 *SrcTex,
|
|
|
|
RECT *SrcRect,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_Load(iface, DestTex, DestPoint, SrcTex, SrcRect, Flags);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::LightEnable
|
|
|
|
*
|
|
|
|
* Enables or disables a light
|
|
|
|
*
|
|
|
|
* Version 7, IDirect3DLight uses this method too.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* LightIndex: The index of the light to enable / disable
|
|
|
|
* Enable: Enable or disable the light
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* For more details, see IWineD3DDevice::SetLightEnable
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
BOOL Enable)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, light_idx %u, enabled %#x.\n", iface, LightIndex, Enable);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
hr = IWineD3DDevice_SetLightEnable(This->wineD3DDevice, LightIndex, Enable);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_LightEnable_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
BOOL Enable)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_LightEnable(iface, LightIndex, Enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_LightEnable_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
BOOL Enable)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_LightEnable(iface, LightIndex, Enable);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetLightEnable
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Retrieves if the light with the given index is enabled or not
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* LightIndex: Index of desired light
|
|
|
|
* Enable: Pointer to a BOOL which contains the result
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Enable is NULL
|
|
|
|
* See IWineD3DDevice::GetLightEnable for more details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
BOOL* Enable)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, light_idx %u, enabled %p.\n", iface, LightIndex, Enable);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Enable)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
hr = IWineD3DDevice_GetLightEnable(This->wineD3DDevice, LightIndex, Enable);
|
2007-06-03 18:51:50 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr_ddraw_from_wined3d(hr);
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetLightEnable_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
BOOL* Enable)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_GetLightEnable(iface, LightIndex, Enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetLightEnable_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD LightIndex,
|
|
|
|
BOOL* Enable)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetLightEnable(iface, LightIndex, Enable);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::SetClipPlane
|
|
|
|
*
|
|
|
|
* Sets custom clipping plane
|
|
|
|
*
|
|
|
|
* Version 7
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Index: The index of the clipping plane
|
|
|
|
* PlaneEquation: An equation defining the clipping plane
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if PlaneEquation is NULL
|
|
|
|
* See IWineD3DDevice::SetClipPlane for more details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Index,
|
|
|
|
D3DVALUE* PlaneEquation)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, idx %u, plane %p.\n", iface, Index, PlaneEquation);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!PlaneEquation)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DDevice_SetClipPlane(This->wineD3DDevice, Index, PlaneEquation);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetClipPlane_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Index,
|
|
|
|
D3DVALUE* PlaneEquation)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_SetClipPlane(iface, Index, PlaneEquation);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_SetClipPlane_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Index,
|
|
|
|
D3DVALUE* PlaneEquation)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_SetClipPlane(iface, Index, PlaneEquation);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetClipPlane
|
|
|
|
*
|
|
|
|
* Returns the clipping plane with a specific index
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Index: The index of the desired plane
|
|
|
|
* PlaneEquation: Address to store the plane equation to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if PlaneEquation is NULL
|
|
|
|
* See IWineD3DDevice::GetClipPlane for more details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Index,
|
|
|
|
D3DVALUE* PlaneEquation)
|
|
|
|
{
|
2009-01-22 10:33:36 +01:00
|
|
|
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
|
2007-06-03 18:51:50 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, idx %u, plane %p.\n", iface, Index, PlaneEquation);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!PlaneEquation)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-03 18:51:50 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DDevice_GetClipPlane(This->wineD3DDevice, Index, PlaneEquation);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetClipPlane_FPUSetup(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Index,
|
|
|
|
D3DVALUE* PlaneEquation)
|
|
|
|
{
|
|
|
|
return IDirect3DDeviceImpl_7_GetClipPlane(iface, Index, PlaneEquation);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetClipPlane_FPUPreserve(IDirect3DDevice7 *iface,
|
|
|
|
DWORD Index,
|
|
|
|
D3DVALUE* PlaneEquation)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WORD old_fpucw;
|
|
|
|
|
|
|
|
old_fpucw = d3d_fpu_setup();
|
|
|
|
hr = IDirect3DDeviceImpl_7_GetClipPlane(iface, Index, PlaneEquation);
|
|
|
|
set_fpu_control_word(old_fpucw);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDevice7::GetInfo
|
|
|
|
*
|
|
|
|
* Retrieves some information about the device. The DirectX sdk says that
|
2006-06-23 18:18:02 +02:00
|
|
|
* this version returns S_FALSE for all retail builds of DirectX, that's what
|
2006-06-09 19:36:12 +02:00
|
|
|
* this implementation does.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DevInfoID: Information type requested
|
|
|
|
* DevInfoStruct: Pointer to a structure to store the info to
|
|
|
|
* Size: Size of the structure
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* S_FALSE, because it's a non-debug driver
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IDirect3DDeviceImpl_7_GetInfo(IDirect3DDevice7 *iface,
|
|
|
|
DWORD DevInfoID,
|
|
|
|
void *DevInfoStruct,
|
|
|
|
DWORD Size)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, info_id %#x, info %p, info_size %u.\n",
|
|
|
|
iface, DevInfoID, DevInfoStruct, Size);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
if (TRACE_ON(ddraw))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
TRACE(" info requested : ");
|
|
|
|
switch (DevInfoID)
|
|
|
|
{
|
|
|
|
case D3DDEVINFOID_TEXTUREMANAGER: TRACE("D3DDEVINFOID_TEXTUREMANAGER\n"); break;
|
|
|
|
case D3DDEVINFOID_D3DTEXTUREMANAGER: TRACE("D3DDEVINFOID_D3DTEXTUREMANAGER\n"); break;
|
|
|
|
case D3DDEVINFOID_TEXTURING: TRACE("D3DDEVINFOID_TEXTURING\n"); break;
|
|
|
|
default: ERR(" invalid flag !!!\n"); return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_FALSE; /* According to MSDN, this is valid for a non-debug driver */
|
|
|
|
}
|
|
|
|
|
2008-06-20 01:49:46 +02:00
|
|
|
/* For performance optimization, devices created in FPUSETUP and FPUPRESERVE modes
|
|
|
|
* have separate vtables. Simple functions where this doesn't matter like GetDirect3D
|
|
|
|
* are not duplicated.
|
|
|
|
|
|
|
|
* Device created with DDSCL_FPUSETUP (d3d7 default) - device methods assume that FPU
|
|
|
|
* has already been setup for optimal d3d operation.
|
|
|
|
|
|
|
|
* Device created with DDSCL_FPUPRESERVE - resets and restores FPU mode when necessary in
|
|
|
|
* d3d calls (FPU may be in a mode non-suitable for d3d when the app calls d3d). Required
|
|
|
|
* by Sacrifice (game). */
|
2010-08-19 18:57:44 +02:00
|
|
|
static const struct IDirect3DDevice7Vtbl d3d_device7_fpu_setup_vtbl =
|
2008-06-20 01:49:46 +02:00
|
|
|
{
|
|
|
|
/*** IUnknown Methods ***/
|
|
|
|
IDirect3DDeviceImpl_7_QueryInterface,
|
|
|
|
IDirect3DDeviceImpl_7_AddRef,
|
|
|
|
IDirect3DDeviceImpl_7_Release,
|
|
|
|
/*** IDirect3DDevice7 ***/
|
|
|
|
IDirect3DDeviceImpl_7_GetCaps_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_EnumTextureFormats_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_BeginScene_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_EndScene_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetDirect3D,
|
|
|
|
IDirect3DDeviceImpl_7_SetRenderTarget_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetRenderTarget,
|
|
|
|
IDirect3DDeviceImpl_7_Clear_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_SetTransform_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetTransform_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_SetViewport_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_MultiplyTransform_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetViewport_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_SetMaterial_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetMaterial_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_SetLight_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetLight_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_SetRenderState_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetRenderState_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_BeginStateBlock_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_EndStateBlock_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_PreLoad_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitive_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitive_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_SetClipStatus,
|
|
|
|
IDirect3DDeviceImpl_7_GetClipStatus,
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitiveStrided_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitiveVB_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_ComputeSphereVisibility,
|
|
|
|
IDirect3DDeviceImpl_7_GetTexture_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_SetTexture_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetTextureStageState_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_SetTextureStageState_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_ValidateDevice_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_ApplyStateBlock_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_CaptureStateBlock_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_DeleteStateBlock_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_CreateStateBlock_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_Load_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_LightEnable_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetLightEnable_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_SetClipPlane_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetClipPlane_FPUSetup,
|
|
|
|
IDirect3DDeviceImpl_7_GetInfo
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:44 +02:00
|
|
|
static const struct IDirect3DDevice7Vtbl d3d_device7_fpu_preserve_vtbl =
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
/*** IUnknown Methods ***/
|
|
|
|
IDirect3DDeviceImpl_7_QueryInterface,
|
|
|
|
IDirect3DDeviceImpl_7_AddRef,
|
|
|
|
IDirect3DDeviceImpl_7_Release,
|
|
|
|
/*** IDirect3DDevice7 ***/
|
2008-06-20 01:49:46 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetCaps_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_EnumTextureFormats_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_BeginScene_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_EndScene_FPUPreserve,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetDirect3D,
|
2008-06-20 01:49:46 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetRenderTarget_FPUPreserve,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetRenderTarget,
|
2008-06-20 01:49:46 +02:00
|
|
|
IDirect3DDeviceImpl_7_Clear_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_SetTransform_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_GetTransform_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_SetViewport_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_MultiplyTransform_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_GetViewport_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_SetMaterial_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_GetMaterial_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_SetLight_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_GetLight_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_SetRenderState_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_GetRenderState_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_BeginStateBlock_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_EndStateBlock_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_PreLoad_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitive_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitive_FPUPreserve,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_SetClipStatus,
|
|
|
|
IDirect3DDeviceImpl_7_GetClipStatus,
|
2008-06-20 01:49:46 +02:00
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitiveStrided_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_DrawPrimitiveVB_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB_FPUPreserve,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_ComputeSphereVisibility,
|
2008-06-20 01:49:46 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetTexture_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_SetTexture_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_GetTextureStageState_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_SetTextureStageState_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_ValidateDevice_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_ApplyStateBlock_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_CaptureStateBlock_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_DeleteStateBlock_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_CreateStateBlock_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_Load_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_LightEnable_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_GetLightEnable_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_SetClipPlane_FPUPreserve,
|
|
|
|
IDirect3DDeviceImpl_7_GetClipPlane_FPUPreserve,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_7_GetInfo
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:44 +02:00
|
|
|
static const struct IDirect3DDevice3Vtbl d3d_device3_vtbl =
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
/*** IUnknown Methods ***/
|
2011-01-20 02:06:25 +01:00
|
|
|
IDirect3DDeviceImpl_3_QueryInterface,
|
|
|
|
IDirect3DDeviceImpl_3_AddRef,
|
|
|
|
IDirect3DDeviceImpl_3_Release,
|
2006-06-09 19:36:12 +02:00
|
|
|
/*** IDirect3DDevice3 ***/
|
|
|
|
IDirect3DDeviceImpl_3_GetCaps,
|
|
|
|
IDirect3DDeviceImpl_3_GetStats,
|
|
|
|
IDirect3DDeviceImpl_3_AddViewport,
|
|
|
|
IDirect3DDeviceImpl_3_DeleteViewport,
|
|
|
|
IDirect3DDeviceImpl_3_NextViewport,
|
2011-01-20 02:06:25 +01:00
|
|
|
IDirect3DDeviceImpl_3_EnumTextureFormats,
|
|
|
|
IDirect3DDeviceImpl_3_BeginScene,
|
|
|
|
IDirect3DDeviceImpl_3_EndScene,
|
2011-01-18 12:22:48 +01:00
|
|
|
IDirect3DDeviceImpl_3_GetDirect3D,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_3_SetCurrentViewport,
|
|
|
|
IDirect3DDeviceImpl_3_GetCurrentViewport,
|
2011-01-20 02:06:25 +01:00
|
|
|
IDirect3DDeviceImpl_3_SetRenderTarget,
|
|
|
|
IDirect3DDeviceImpl_3_GetRenderTarget,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_3_Begin,
|
|
|
|
IDirect3DDeviceImpl_3_BeginIndexed,
|
|
|
|
IDirect3DDeviceImpl_3_Vertex,
|
|
|
|
IDirect3DDeviceImpl_3_Index,
|
|
|
|
IDirect3DDeviceImpl_3_End,
|
2008-05-04 14:05:02 +02:00
|
|
|
IDirect3DDeviceImpl_3_GetRenderState,
|
|
|
|
IDirect3DDeviceImpl_3_SetRenderState,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_3_GetLightState,
|
|
|
|
IDirect3DDeviceImpl_3_SetLightState,
|
2011-01-20 02:06:25 +01:00
|
|
|
IDirect3DDeviceImpl_3_SetTransform,
|
|
|
|
IDirect3DDeviceImpl_3_GetTransform,
|
|
|
|
IDirect3DDeviceImpl_3_MultiplyTransform,
|
|
|
|
IDirect3DDeviceImpl_3_DrawPrimitive,
|
|
|
|
IDirect3DDeviceImpl_3_DrawIndexedPrimitive,
|
|
|
|
IDirect3DDeviceImpl_3_SetClipStatus,
|
|
|
|
IDirect3DDeviceImpl_3_GetClipStatus,
|
|
|
|
IDirect3DDeviceImpl_3_DrawPrimitiveStrided,
|
|
|
|
IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided,
|
|
|
|
IDirect3DDeviceImpl_3_DrawPrimitiveVB,
|
|
|
|
IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB,
|
|
|
|
IDirect3DDeviceImpl_3_ComputeSphereVisibility,
|
|
|
|
IDirect3DDeviceImpl_3_GetTexture,
|
2008-05-05 19:09:40 +02:00
|
|
|
IDirect3DDeviceImpl_3_SetTexture,
|
2011-01-20 02:06:25 +01:00
|
|
|
IDirect3DDeviceImpl_3_GetTextureStageState,
|
|
|
|
IDirect3DDeviceImpl_3_SetTextureStageState,
|
|
|
|
IDirect3DDeviceImpl_3_ValidateDevice
|
2006-06-09 19:36:12 +02:00
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:44 +02:00
|
|
|
static const struct IDirect3DDevice2Vtbl d3d_device2_vtbl =
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
/*** IUnknown Methods ***/
|
2011-01-20 02:05:06 +01:00
|
|
|
IDirect3DDeviceImpl_2_QueryInterface,
|
|
|
|
IDirect3DDeviceImpl_2_AddRef,
|
|
|
|
IDirect3DDeviceImpl_2_Release,
|
2006-06-09 19:36:12 +02:00
|
|
|
/*** IDirect3DDevice2 ***/
|
2011-01-20 02:05:06 +01:00
|
|
|
IDirect3DDeviceImpl_2_GetCaps,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_2_SwapTextureHandles,
|
2011-01-20 02:05:06 +01:00
|
|
|
IDirect3DDeviceImpl_2_GetStats,
|
|
|
|
IDirect3DDeviceImpl_2_AddViewport,
|
|
|
|
IDirect3DDeviceImpl_2_DeleteViewport,
|
|
|
|
IDirect3DDeviceImpl_2_NextViewport,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_2_EnumTextureFormats,
|
2011-01-20 02:05:06 +01:00
|
|
|
IDirect3DDeviceImpl_2_BeginScene,
|
|
|
|
IDirect3DDeviceImpl_2_EndScene,
|
2011-01-18 12:22:48 +01:00
|
|
|
IDirect3DDeviceImpl_2_GetDirect3D,
|
2011-01-20 02:05:06 +01:00
|
|
|
IDirect3DDeviceImpl_2_SetCurrentViewport,
|
|
|
|
IDirect3DDeviceImpl_2_GetCurrentViewport,
|
|
|
|
IDirect3DDeviceImpl_2_SetRenderTarget,
|
|
|
|
IDirect3DDeviceImpl_2_GetRenderTarget,
|
|
|
|
IDirect3DDeviceImpl_2_Begin,
|
|
|
|
IDirect3DDeviceImpl_2_BeginIndexed,
|
|
|
|
IDirect3DDeviceImpl_2_Vertex,
|
|
|
|
IDirect3DDeviceImpl_2_Index,
|
|
|
|
IDirect3DDeviceImpl_2_End,
|
|
|
|
IDirect3DDeviceImpl_2_GetRenderState,
|
|
|
|
IDirect3DDeviceImpl_2_SetRenderState,
|
|
|
|
IDirect3DDeviceImpl_2_GetLightState,
|
|
|
|
IDirect3DDeviceImpl_2_SetLightState,
|
|
|
|
IDirect3DDeviceImpl_2_SetTransform,
|
|
|
|
IDirect3DDeviceImpl_2_GetTransform,
|
|
|
|
IDirect3DDeviceImpl_2_MultiplyTransform,
|
|
|
|
IDirect3DDeviceImpl_2_DrawPrimitive,
|
|
|
|
IDirect3DDeviceImpl_2_DrawIndexedPrimitive,
|
|
|
|
IDirect3DDeviceImpl_2_SetClipStatus,
|
|
|
|
IDirect3DDeviceImpl_2_GetClipStatus
|
2006-06-09 19:36:12 +02:00
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:44 +02:00
|
|
|
static const struct IDirect3DDeviceVtbl d3d_device1_vtbl =
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
/*** IUnknown Methods ***/
|
2011-01-20 02:03:36 +01:00
|
|
|
IDirect3DDeviceImpl_1_QueryInterface,
|
|
|
|
IDirect3DDeviceImpl_1_AddRef,
|
|
|
|
IDirect3DDeviceImpl_1_Release,
|
2006-06-09 19:36:12 +02:00
|
|
|
/*** IDirect3DDevice1 ***/
|
|
|
|
IDirect3DDeviceImpl_1_Initialize,
|
2011-01-20 02:03:36 +01:00
|
|
|
IDirect3DDeviceImpl_1_GetCaps,
|
|
|
|
IDirect3DDeviceImpl_1_SwapTextureHandles,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_1_CreateExecuteBuffer,
|
2011-01-20 02:03:36 +01:00
|
|
|
IDirect3DDeviceImpl_1_GetStats,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_1_Execute,
|
2011-01-20 02:03:36 +01:00
|
|
|
IDirect3DDeviceImpl_1_AddViewport,
|
|
|
|
IDirect3DDeviceImpl_1_DeleteViewport,
|
|
|
|
IDirect3DDeviceImpl_1_NextViewport,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_1_Pick,
|
|
|
|
IDirect3DDeviceImpl_1_GetPickRecords,
|
2011-01-20 02:03:36 +01:00
|
|
|
IDirect3DDeviceImpl_1_EnumTextureFormats,
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirect3DDeviceImpl_1_CreateMatrix,
|
|
|
|
IDirect3DDeviceImpl_1_SetMatrix,
|
|
|
|
IDirect3DDeviceImpl_1_GetMatrix,
|
|
|
|
IDirect3DDeviceImpl_1_DeleteMatrix,
|
2011-01-20 02:03:36 +01:00
|
|
|
IDirect3DDeviceImpl_1_BeginScene,
|
|
|
|
IDirect3DDeviceImpl_1_EndScene,
|
2011-01-18 12:22:48 +01:00
|
|
|
IDirect3DDeviceImpl_1_GetDirect3D
|
2006-06-09 19:36:12 +02:00
|
|
|
};
|
2006-06-16 23:44:33 +02:00
|
|
|
|
2007-04-24 22:30:03 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DDeviceImpl_UpdateDepthStencil
|
|
|
|
*
|
|
|
|
* Checks the current render target for attached depth stencils and sets the
|
|
|
|
* WineD3D depth stencil accordingly.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The depth stencil state to set if creating the device
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
WINED3DZBUFFERTYPE
|
|
|
|
IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This)
|
|
|
|
{
|
|
|
|
IDirectDrawSurface7 *depthStencil = NULL;
|
|
|
|
IDirectDrawSurfaceImpl *dsi;
|
|
|
|
static DDSCAPS2 depthcaps = { DDSCAPS_ZBUFFER, 0, 0, 0 };
|
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)This->target, &depthcaps, &depthStencil);
|
2007-04-24 22:30:03 +02:00
|
|
|
if(!depthStencil)
|
|
|
|
{
|
|
|
|
TRACE("Setting wined3d depth stencil to NULL\n");
|
|
|
|
IWineD3DDevice_SetDepthStencilSurface(This->wineD3DDevice,
|
|
|
|
NULL);
|
|
|
|
return WINED3DZB_FALSE;
|
|
|
|
}
|
|
|
|
|
2009-01-22 10:33:37 +01:00
|
|
|
dsi = (IDirectDrawSurfaceImpl *)depthStencil;
|
2011-04-29 13:03:41 +02:00
|
|
|
TRACE("Setting wined3d depth stencil to %p (wined3d %p)\n", dsi, dsi->wined3d_surface);
|
|
|
|
IWineD3DDevice_SetDepthStencilSurface(This->wineD3DDevice, dsi->wined3d_surface);
|
2007-04-24 22:30:03 +02:00
|
|
|
|
|
|
|
IDirectDrawSurface7_Release(depthStencil);
|
|
|
|
return WINED3DZB_TRUE;
|
|
|
|
}
|
2010-08-19 18:57:44 +02:00
|
|
|
|
|
|
|
HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDirectDrawSurfaceImpl *target)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (ddraw->cooperative_level & DDSCL_FPUPRESERVE)
|
|
|
|
device->lpVtbl = &d3d_device7_fpu_preserve_vtbl;
|
|
|
|
else
|
|
|
|
device->lpVtbl = &d3d_device7_fpu_setup_vtbl;
|
|
|
|
|
|
|
|
device->IDirect3DDevice3_vtbl = &d3d_device3_vtbl;
|
|
|
|
device->IDirect3DDevice2_vtbl = &d3d_device2_vtbl;
|
|
|
|
device->IDirect3DDevice_vtbl = &d3d_device1_vtbl;
|
|
|
|
device->ref = 1;
|
|
|
|
device->ddraw = ddraw;
|
|
|
|
device->target = target;
|
2011-04-19 20:05:52 +02:00
|
|
|
list_init(&device->viewport_list);
|
2010-08-19 18:57:44 +02:00
|
|
|
|
|
|
|
if (!ddraw_handle_table_init(&device->handle_table, 64))
|
|
|
|
{
|
|
|
|
ERR("Failed to initialize handle table.\n");
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
device->legacyTextureBlending = FALSE;
|
|
|
|
|
|
|
|
/* Create an index buffer, it's needed for indexed drawing */
|
2011-05-10 21:18:47 +02:00
|
|
|
hr = wined3d_buffer_create_ib(ddraw->wineD3DDevice, 0x40000 /* Length. Don't know how long it should be */,
|
2011-03-03 21:49:08 +01:00
|
|
|
WINED3DUSAGE_DYNAMIC /* Usage */, WINED3DPOOL_DEFAULT, NULL,
|
2010-08-31 18:41:40 +02:00
|
|
|
&ddraw_null_wined3d_parent_ops, &device->indexbuffer);
|
2010-08-19 18:57:44 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to create an index buffer, hr %#x.\n", hr);
|
|
|
|
ddraw_handle_table_destroy(&device->handle_table);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is for convenience. */
|
|
|
|
device->wineD3DDevice = ddraw->wineD3DDevice;
|
|
|
|
IWineD3DDevice_AddRef(ddraw->wineD3DDevice);
|
|
|
|
|
2010-10-05 14:32:35 +02:00
|
|
|
/* Render to the back buffer */
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = IWineD3DDevice_SetRenderTarget(ddraw->wineD3DDevice, 0, target->wined3d_surface, TRUE);
|
2010-10-05 14:32:35 +02:00
|
|
|
if (FAILED(hr))
|
2010-08-19 18:57:44 +02:00
|
|
|
{
|
2010-10-05 14:32:35 +02:00
|
|
|
ERR("Failed to set render target, hr %#x.\n", hr);
|
2011-03-03 21:49:09 +01:00
|
|
|
wined3d_buffer_decref(device->indexbuffer);
|
2010-10-05 14:32:35 +02:00
|
|
|
ddraw_handle_table_destroy(&device->handle_table);
|
|
|
|
return hr;
|
2010-08-19 18:57:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: This is broken. The target AddRef() makes some sense, because
|
|
|
|
* we store a pointer during initialization, but then that's also where
|
|
|
|
* the AddRef() should be. We don't store ddraw->d3d_target anywhere. */
|
|
|
|
/* AddRef the render target. Also AddRef the render target from ddraw,
|
|
|
|
* because if it is released before the app releases the D3D device, the
|
|
|
|
* D3D capabilities of wined3d will be uninitialized, which has bad effects.
|
|
|
|
*
|
|
|
|
* In most cases, those surfaces are the same anyway, but this will simply
|
|
|
|
* add another ref which is released when the device is destroyed. */
|
|
|
|
IDirectDrawSurface7_AddRef((IDirectDrawSurface7 *)target);
|
|
|
|
IDirectDrawSurface7_AddRef((IDirectDrawSurface7 *)ddraw->d3d_target);
|
|
|
|
|
|
|
|
ddraw->d3ddevice = device;
|
|
|
|
|
|
|
|
IWineD3DDevice_SetRenderState(ddraw->wineD3DDevice, WINED3DRS_ZENABLE,
|
|
|
|
IDirect3DDeviceImpl_UpdateDepthStencil(device));
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|