2006-06-09 19:36:12 +02:00
|
|
|
/*
|
|
|
|
* Copyright 1997-2000 Marcus Meissner
|
|
|
|
* Copyright 1998-2000 Lionel Ulmer
|
|
|
|
* Copyright 2000-2001 TransGaming Technologies Inc.
|
2008-10-18 19:19:45 +02:00
|
|
|
* Copyright 2006 Stefan Dösinger
|
2008-03-10 17:44:38 +01:00
|
|
|
* Copyright 2008 Denver Gingerich
|
2013-06-05 10:55:40 +02:00
|
|
|
* Copyright 2007-2008, 2011, 2013 Stefan Dösinger for CodeWeavers
|
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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include "ddraw_private.h"
|
|
|
|
|
2017-01-28 23:34:03 +01:00
|
|
|
#include "wine/exception.h"
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
|
|
|
|
2012-10-16 22:43:10 +02:00
|
|
|
static const struct ddraw *exclusive_ddraw;
|
2015-12-04 11:30:15 +01:00
|
|
|
static HWND exclusive_window;
|
2012-10-16 22:43:10 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Device identifier. Don't relay it to WineD3D */
|
|
|
|
static const DDDEVICEIDENTIFIER2 deviceidentifier =
|
|
|
|
{
|
2014-02-11 05:27:33 +01:00
|
|
|
"vga.dll", /* default 2D driver */
|
2006-06-09 19:36:12 +02:00
|
|
|
"DirectDraw HAL",
|
|
|
|
{ { 0x00010001, 0x00010001 } },
|
|
|
|
0, 0, 0, 0,
|
|
|
|
/* a8373c10-7ac4-4deb-849a-009844d08b2d */
|
|
|
|
{0xa8373c10,0x7ac4,0x4deb, {0x84,0x9a,0x00,0x98,0x44,0xd0,0x8b,0x2d}},
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2011-06-01 14:12:45 +02:00
|
|
|
static struct enum_device_entry
|
|
|
|
{
|
|
|
|
char interface_name[100];
|
|
|
|
char device_name[100];
|
|
|
|
const GUID *device_guid;
|
|
|
|
} device_list7[] =
|
|
|
|
{
|
|
|
|
/* T&L HAL device */
|
|
|
|
{
|
|
|
|
"WINE Direct3D7 Hardware Transform and Lighting acceleration using WineD3D",
|
|
|
|
"Wine D3D7 T&L HAL",
|
|
|
|
&IID_IDirect3DTnLHalDevice,
|
|
|
|
},
|
|
|
|
|
|
|
|
/* HAL device */
|
|
|
|
{
|
|
|
|
"WINE Direct3D7 Hardware acceleration using WineD3D",
|
2011-10-02 15:29:20 +02:00
|
|
|
"Direct3D HAL",
|
2011-06-01 14:12:45 +02:00
|
|
|
&IID_IDirect3DHALDevice,
|
|
|
|
},
|
|
|
|
|
|
|
|
/* RGB device */
|
|
|
|
{
|
|
|
|
"WINE Direct3D7 RGB Software Emulation using WineD3D",
|
|
|
|
"Wine D3D7 RGB",
|
|
|
|
&IID_IDirect3DRGBDevice,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2009-09-16 08:37:15 +02:00
|
|
|
static void STDMETHODCALLTYPE ddraw_null_wined3d_object_destroyed(void *parent) {}
|
|
|
|
|
2009-09-17 23:03:32 +02:00
|
|
|
const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops =
|
2009-09-16 08:37:15 +02:00
|
|
|
{
|
|
|
|
ddraw_null_wined3d_object_destroyed,
|
|
|
|
};
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static inline struct ddraw *impl_from_IDirectDraw(IDirectDraw *iface)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw, IDirectDraw_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static inline struct ddraw *impl_from_IDirectDraw2(IDirectDraw2 *iface)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw, IDirectDraw2_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static inline struct ddraw *impl_from_IDirectDraw4(IDirectDraw4 *iface)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw, IDirectDraw4_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static inline struct ddraw *impl_from_IDirectDraw7(IDirectDraw7 *iface)
|
2011-01-19 01:42:43 +01:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw, IDirectDraw7_iface);
|
2011-01-19 01:42:43 +01:00
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static inline struct ddraw *impl_from_IDirect3D(IDirect3D *iface)
|
2011-01-18 12:28:15 +01:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw, IDirect3D_iface);
|
2011-01-18 12:28:15 +01:00
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static inline struct ddraw *impl_from_IDirect3D2(IDirect3D2 *iface)
|
2011-01-18 12:30:17 +01:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw, IDirect3D2_iface);
|
2011-01-18 12:30:17 +01:00
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static inline struct ddraw *impl_from_IDirect3D3(IDirect3D3 *iface)
|
2011-01-19 01:30:21 +01:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw, IDirect3D3_iface);
|
2011-01-19 01:30:21 +01:00
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static inline struct ddraw *impl_from_IDirect3D7(IDirect3D7 *iface)
|
2011-01-19 01:32:36 +01:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct ddraw, IDirect3D7_iface);
|
2011-01-19 01:32:36 +01:00
|
|
|
}
|
|
|
|
|
2013-01-08 09:53:17 +01:00
|
|
|
static HRESULT WINAPI ddraw7_QueryInterface(IDirectDraw7 *iface, REFIID riid, void **out)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2013-01-08 09:53:17 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2007-05-21 01:13:52 +02:00
|
|
|
|
2013-01-08 09:53:17 +01:00
|
|
|
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2013-01-08 09:53:17 +01:00
|
|
|
if (!riid)
|
2007-05-21 01:13:52 +02:00
|
|
|
{
|
2013-01-08 09:53:17 +01:00
|
|
|
*out = NULL;
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2007-05-21 01:13:52 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2013-01-08 09:53:17 +01:00
|
|
|
/* The refcount unit test revealed that an IDirect3D7 interface can only
|
|
|
|
* be queried from a DirectDraw object that was created as an IDirectDraw7
|
|
|
|
* interface. The older interfaces can query any IDirect3D version except
|
|
|
|
* 7, because they are all initially created as IDirectDraw. This isn't
|
|
|
|
* really crucial behavior, and messy to implement with the common
|
|
|
|
* creation function, so it has been left out here. */
|
|
|
|
if (IsEqualGUID(&IID_IDirectDraw7, riid)
|
|
|
|
|| IsEqualGUID(&IID_IUnknown, riid))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2013-01-08 09:53:17 +01:00
|
|
|
*out = &ddraw->IDirectDraw7_iface;
|
|
|
|
TRACE("Returning IDirectDraw7 interface %p.\n", *out);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2013-01-08 09:53:17 +01:00
|
|
|
else if (IsEqualGUID(&IID_IDirectDraw4, riid))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2013-01-08 09:53:17 +01:00
|
|
|
*out = &ddraw->IDirectDraw4_iface;
|
|
|
|
TRACE("Returning IDirectDraw4 interface %p.\n", *out);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2013-01-08 09:53:17 +01:00
|
|
|
else if (IsEqualGUID(&IID_IDirectDraw2, riid))
|
2006-12-14 02:14:35 +01:00
|
|
|
{
|
2013-01-08 09:53:17 +01:00
|
|
|
*out = &ddraw->IDirectDraw2_iface;
|
|
|
|
TRACE("Returning IDirectDraw2 interface %p.\n", *out);
|
2006-12-14 02:14:35 +01:00
|
|
|
}
|
2013-01-08 09:53:17 +01:00
|
|
|
else if (IsEqualGUID(&IID_IDirectDraw, riid))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2013-01-08 09:53:17 +01:00
|
|
|
*out = &ddraw->IDirectDraw_iface;
|
|
|
|
TRACE("Returning IDirectDraw interface %p.\n", *out);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2013-01-08 09:53:17 +01:00
|
|
|
else if (IsEqualGUID(&IID_IDirect3D7, riid))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2013-01-08 09:53:17 +01:00
|
|
|
ddraw->d3dversion = 7;
|
|
|
|
*out = &ddraw->IDirect3D7_iface;
|
|
|
|
TRACE("Returning Direct3D7 interface %p.\n", *out);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2013-01-08 09:53:17 +01:00
|
|
|
else if (IsEqualGUID(&IID_IDirect3D3, riid))
|
|
|
|
{
|
|
|
|
ddraw->d3dversion = 3;
|
|
|
|
*out = &ddraw->IDirect3D3_iface;
|
|
|
|
TRACE("Returning Direct3D3 interface %p.\n", *out);
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IDirect3D2, riid))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2013-01-08 09:53:17 +01:00
|
|
|
ddraw->d3dversion = 2;
|
|
|
|
*out = &ddraw->IDirect3D2_iface;
|
|
|
|
TRACE("Returning Direct3D2 interface %p.\n", *out);
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IDirect3D, riid))
|
|
|
|
{
|
|
|
|
ddraw->d3dversion = 1;
|
|
|
|
*out = &ddraw->IDirect3D_iface;
|
|
|
|
TRACE("Returning Direct3D interface %p.\n", *out);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
/* Unknown interface */
|
|
|
|
else
|
|
|
|
{
|
2013-01-08 09:53:17 +01:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
|
|
|
*out = NULL;
|
2006-06-09 19:36:12 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2013-01-08 09:53:17 +01:00
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
2006-06-09 19:36:12 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_QueryInterface(IDirectDraw4 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_QueryInterface(&ddraw->IDirectDraw7_iface, riid, object);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_QueryInterface(IDirectDraw2 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_QueryInterface(&ddraw->IDirectDraw7_iface, riid, object);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_QueryInterface(IDirectDraw *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_QueryInterface(&ddraw->IDirectDraw7_iface, riid, object);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
static HRESULT WINAPI d3d7_QueryInterface(IDirect3D7 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D7(iface);
|
2011-01-19 01:32:36 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_QueryInterface(&ddraw->IDirectDraw7_iface, riid, object);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d3_QueryInterface(IDirect3D3 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
|
2011-01-19 01:30:21 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_QueryInterface(&ddraw->IDirectDraw7_iface, riid, object);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d2_QueryInterface(IDirect3D2 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D2(iface);
|
2011-01-18 12:30:17 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_QueryInterface(&ddraw->IDirectDraw7_iface, riid, object);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d1_QueryInterface(IDirect3D *iface, REFIID riid, void **object)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D(iface);
|
2011-01-18 12:28:15 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_QueryInterface(&ddraw->IDirectDraw7_iface, riid, object);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::AddRef
|
|
|
|
*
|
2006-07-10 16:06:33 +02:00
|
|
|
* Increases the interfaces refcount, basically
|
|
|
|
*
|
|
|
|
* DDraw refcounting is a bit tricky. The different DirectDraw interface
|
|
|
|
* versions have individual refcounts, but the IDirect3D interfaces do not.
|
|
|
|
* All interfaces are from one object, that means calling QueryInterface on an
|
|
|
|
* IDirectDraw7 interface for an IDirectDraw4 interface does not create a new
|
2012-03-08 20:27:16 +01:00
|
|
|
* ddraw object.
|
2006-07-10 16:06:33 +02:00
|
|
|
*
|
|
|
|
* That means all AddRef and Release implementations of IDirectDrawX work
|
|
|
|
* with their own counter, and IDirect3DX::AddRef thunk to IDirectDraw (1),
|
|
|
|
* except of IDirect3D7 which thunks to IDirectDraw7
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Returns: The new refcount
|
2006-07-10 16:06:33 +02:00
|
|
|
*
|
2006-06-09 19:36:12 +02:00
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static ULONG WINAPI ddraw7_AddRef(IDirectDraw7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirectDraw7(iface);
|
2006-07-10 16:06:33 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref7);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", This, ref);
|
2006-07-10 16:06:33 +02:00
|
|
|
|
|
|
|
if(ref == 1) InterlockedIncrement(&This->numIfaces);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static ULONG WINAPI ddraw4_AddRef(IDirectDraw4 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref4);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:40:53 +01:00
|
|
|
TRACE("%p increasing refcount to %u.\n", This, ref);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:40:53 +01:00
|
|
|
if (ref == 1) InterlockedIncrement(&This->numIfaces);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ddraw2_AddRef(IDirectDraw2 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref2);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:36:36 +01:00
|
|
|
TRACE("%p increasing refcount to %u.\n", This, ref);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:36:36 +01:00
|
|
|
if (ref == 1) InterlockedIncrement(&This->numIfaces);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ddraw1_AddRef(IDirectDraw *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref1);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
TRACE("%p increasing refcount to %u.\n", This, ref);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
if (ref == 1) InterlockedIncrement(&This->numIfaces);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
static ULONG WINAPI d3d7_AddRef(IDirect3D7 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirect3D7(iface);
|
2011-01-19 01:32:36 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-01-19 01:42:43 +01:00
|
|
|
return ddraw7_AddRef(&This->IDirectDraw7_iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d3d3_AddRef(IDirect3D3 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirect3D3(iface);
|
2011-01-19 01:30:21 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
return ddraw1_AddRef(&This->IDirectDraw_iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d3d2_AddRef(IDirect3D2 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirect3D2(iface);
|
2011-01-18 12:30:17 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
return ddraw1_AddRef(&This->IDirectDraw_iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d3d1_AddRef(IDirect3D *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirect3D(iface);
|
2011-01-18 12:28:15 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
return ddraw1_AddRef(&This->IDirectDraw_iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
2017-03-16 15:38:31 +01:00
|
|
|
static void ddraw_destroy_swapchain(struct ddraw *ddraw)
|
2011-10-17 21:06:22 +02:00
|
|
|
{
|
|
|
|
TRACE("Destroying the swapchain.\n");
|
|
|
|
|
|
|
|
wined3d_swapchain_decref(ddraw->wined3d_swapchain);
|
|
|
|
ddraw->wined3d_swapchain = NULL;
|
|
|
|
|
2013-05-30 10:05:33 +02:00
|
|
|
if (!(ddraw->flags & DDRAW_NO3D))
|
2011-10-17 21:06:22 +02:00
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
for (i = 0; i < ddraw->numConvertedDecls; ++i)
|
|
|
|
{
|
|
|
|
wined3d_vertex_declaration_decref(ddraw->decls[i].decl);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, ddraw->decls);
|
|
|
|
ddraw->numConvertedDecls = 0;
|
|
|
|
|
|
|
|
if (FAILED(wined3d_device_uninit_3d(ddraw->wined3d_device)))
|
|
|
|
{
|
|
|
|
ERR("Failed to uninit 3D.\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Free the d3d window if one was created. */
|
|
|
|
if (ddraw->d3d_window && ddraw->d3d_window != ddraw->dest_window)
|
|
|
|
{
|
|
|
|
TRACE("Destroying the hidden render window %p.\n", ddraw->d3d_window);
|
|
|
|
DestroyWindow(ddraw->d3d_window);
|
|
|
|
ddraw->d3d_window = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-30 10:05:32 +02:00
|
|
|
ddraw->flags &= ~DDRAW_D3D_INITIALIZED;
|
2011-10-17 21:06:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wined3d_device_uninit_gdi(ddraw->wined3d_device);
|
|
|
|
}
|
|
|
|
|
2011-11-17 20:11:40 +01:00
|
|
|
ddraw_set_swapchain_window(ddraw, NULL);
|
2011-10-24 21:24:38 +02:00
|
|
|
|
2011-10-17 21:06:22 +02:00
|
|
|
TRACE("Swapchain destroyed.\n");
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
2010-07-19 18:36:19 +02:00
|
|
|
* ddraw_destroy
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
2006-07-10 16:06:33 +02:00
|
|
|
* Destroys a ddraw object if all refcounts are 0. This is to share code
|
|
|
|
* between the IDirectDrawX::Release functions
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* This: DirectDraw object to destroy
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-03-08 20:27:16 +01:00
|
|
|
static void ddraw_destroy(struct ddraw *This)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-01-19 01:42:43 +01:00
|
|
|
IDirectDraw7_SetCooperativeLevel(&This->IDirectDraw7_iface, NULL, DDSCL_NORMAL);
|
|
|
|
IDirectDraw7_RestoreDisplayMode(&This->IDirectDraw7_iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2006-07-10 16:06:33 +02:00
|
|
|
/* Destroy the device window if we created one */
|
|
|
|
if(This->devicewindow != 0)
|
|
|
|
{
|
|
|
|
TRACE(" (%p) Destroying the device window %p\n", This, This->devicewindow);
|
|
|
|
DestroyWindow(This->devicewindow);
|
|
|
|
This->devicewindow = 0;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2007-05-21 01:12:36 +02:00
|
|
|
list_remove(&This->ddraw_list_entry);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-10-17 21:06:22 +02:00
|
|
|
if (This->wined3d_swapchain)
|
|
|
|
ddraw_destroy_swapchain(This);
|
2011-05-16 23:01:22 +02:00
|
|
|
wined3d_device_decref(This->wined3d_device);
|
2011-11-28 21:30:58 +01:00
|
|
|
wined3d_decref(This->wined3d);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2015-04-29 17:27:35 +02:00
|
|
|
if (This->d3ddevice)
|
|
|
|
This->d3ddevice->ddraw = NULL;
|
|
|
|
|
2006-07-10 16:06:33 +02:00
|
|
|
/* Now free the object */
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2006-07-10 16:06:33 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::Release
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Decreases the refcount. If the refcount falls to 0, the object is destroyed
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Returns: The new refcount
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static ULONG WINAPI ddraw7_Release(IDirectDraw7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirectDraw7(iface);
|
2006-07-10 16:06:33 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref7);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
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
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
if (!ref && !InterlockedDecrement(&This->numIfaces))
|
|
|
|
ddraw_destroy(This);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ddraw4_Release(IDirectDraw4 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref4);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:40:53 +01:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", This, ref);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:40:53 +01:00
|
|
|
if (!ref && !InterlockedDecrement(&This->numIfaces))
|
|
|
|
ddraw_destroy(This);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ddraw2_Release(IDirectDraw2 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref2);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:36:36 +01:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", This, ref);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:36:36 +01:00
|
|
|
if (!ref && !InterlockedDecrement(&This->numIfaces))
|
|
|
|
ddraw_destroy(This);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ddraw1_Release(IDirectDraw *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref1);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", This, ref);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
if (!ref && !InterlockedDecrement(&This->numIfaces))
|
|
|
|
ddraw_destroy(This);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
static ULONG WINAPI d3d7_Release(IDirect3D7 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirect3D7(iface);
|
2011-01-19 01:32:36 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-01-19 01:42:43 +01:00
|
|
|
return ddraw7_Release(&This->IDirectDraw7_iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d3d3_Release(IDirect3D3 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirect3D3(iface);
|
2011-01-19 01:30:21 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
return ddraw1_Release(&This->IDirectDraw_iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d3d2_Release(IDirect3D2 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirect3D2(iface);
|
2011-01-18 12:30:17 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
return ddraw1_Release(&This->IDirectDraw_iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d3d1_Release(IDirect3D *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *This = impl_from_IDirect3D(iface);
|
2011-01-18 12:28:15 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
return ddraw1_Release(&This->IDirectDraw_iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw methods
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static HRESULT ddraw_set_focus_window(struct ddraw *ddraw, HWND window)
|
2011-08-29 18:58:59 +02:00
|
|
|
{
|
|
|
|
/* FIXME: This looks wrong, exclusive mode should imply a destination
|
|
|
|
* window. */
|
|
|
|
if ((ddraw->cooperative_level & DDSCL_EXCLUSIVE) && ddraw->dest_window)
|
|
|
|
{
|
|
|
|
TRACE("Setting DDSCL_SETFOCUSWINDOW with an already set window, returning DDERR_HWNDALREADYSET.\n");
|
|
|
|
return DDERR_HWNDALREADYSET;
|
|
|
|
}
|
|
|
|
|
|
|
|
ddraw->focuswindow = window;
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static HRESULT ddraw_attach_d3d_device(struct ddraw *ddraw,
|
2011-12-02 08:15:52 +01:00
|
|
|
struct wined3d_swapchain_desc *swapchain_desc)
|
2011-11-28 21:30:57 +01:00
|
|
|
{
|
2011-12-02 08:15:52 +01:00
|
|
|
HWND window = swapchain_desc->device_window;
|
2011-11-28 21:30:57 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("ddraw %p.\n", ddraw);
|
|
|
|
|
|
|
|
if (!window || window == GetDesktopWindow())
|
|
|
|
{
|
|
|
|
window = CreateWindowExA(0, DDRAW_WINDOW_CLASS_NAME, "Hidden D3D Window",
|
|
|
|
WS_DISABLED, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
if (!window)
|
|
|
|
{
|
|
|
|
ERR("Failed to create window, last error %#x.\n", GetLastError());
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ShowWindow(window, SW_HIDE); /* Just to be sure */
|
|
|
|
WARN("No window for the Direct3DDevice, created hidden window %p.\n", window);
|
|
|
|
|
2011-12-02 08:15:52 +01:00
|
|
|
swapchain_desc->device_window = window;
|
2011-11-28 21:30:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Using existing window %p for Direct3D rendering.\n", window);
|
|
|
|
}
|
|
|
|
ddraw->d3d_window = window;
|
|
|
|
|
|
|
|
/* Set this NOW, otherwise creating the depth stencil surface will cause a
|
|
|
|
* recursive loop until ram or emulated video memory is full. */
|
2013-05-30 10:05:32 +02:00
|
|
|
ddraw->flags |= DDRAW_D3D_INITIALIZED;
|
2011-12-02 08:15:52 +01:00
|
|
|
hr = wined3d_device_init_3d(ddraw->wined3d_device, swapchain_desc);
|
2011-11-28 21:30:57 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2013-05-30 10:05:32 +02:00
|
|
|
ddraw->flags &= ~DDRAW_D3D_INITIALIZED;
|
2011-11-28 21:30:57 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ddraw->declArraySize = 2;
|
|
|
|
ddraw->decls = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ddraw->decls) * ddraw->declArraySize);
|
|
|
|
if (!ddraw->decls)
|
|
|
|
{
|
|
|
|
ERR("Error allocating an array for the converted vertex decls.\n");
|
|
|
|
ddraw->declArraySize = 0;
|
|
|
|
hr = wined3d_device_uninit_3d(ddraw->wined3d_device);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Successfully initialized 3D.\n");
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL windowed)
|
2011-11-28 21:30:57 +01:00
|
|
|
{
|
2011-12-02 08:15:52 +01:00
|
|
|
struct wined3d_swapchain_desc swapchain_desc;
|
2011-11-28 21:30:57 +01:00
|
|
|
struct wined3d_display_mode mode;
|
|
|
|
HRESULT hr = WINED3D_OK;
|
|
|
|
|
2012-06-27 19:02:28 +02:00
|
|
|
if (FAILED(hr = wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode, NULL)))
|
2011-11-28 21:30:57 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to get display mode.\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-12-02 08:15:52 +01:00
|
|
|
memset(&swapchain_desc, 0, sizeof(swapchain_desc));
|
|
|
|
swapchain_desc.backbuffer_width = mode.width;
|
|
|
|
swapchain_desc.backbuffer_height = mode.height;
|
|
|
|
swapchain_desc.backbuffer_format = mode.format_id;
|
2012-01-06 11:20:07 +01:00
|
|
|
swapchain_desc.swap_effect = WINED3D_SWAP_EFFECT_COPY;
|
2011-12-02 08:15:52 +01:00
|
|
|
swapchain_desc.device_window = window;
|
|
|
|
swapchain_desc.windowed = windowed;
|
2016-08-03 09:41:38 +02:00
|
|
|
swapchain_desc.flags = WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH;
|
2011-11-28 21:30:57 +01:00
|
|
|
|
2013-05-30 10:05:33 +02:00
|
|
|
if (!(ddraw->flags & DDRAW_NO3D))
|
2011-12-02 08:15:52 +01:00
|
|
|
hr = ddraw_attach_d3d_device(ddraw, &swapchain_desc);
|
2011-11-28 21:30:57 +01:00
|
|
|
else
|
2011-12-02 08:15:52 +01:00
|
|
|
hr = wined3d_device_init_gdi(ddraw->wined3d_device, &swapchain_desc);
|
2011-11-28 21:30:57 +01:00
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to create swapchain, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-09-04 20:15:10 +02:00
|
|
|
if (!(ddraw->wined3d_swapchain = wined3d_device_get_swapchain(ddraw->wined3d_device, 0)))
|
2011-11-28 21:30:57 +01:00
|
|
|
{
|
2012-09-04 20:15:10 +02:00
|
|
|
ERR("Failed to get swapchain.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2011-11-28 21:30:57 +01:00
|
|
|
}
|
|
|
|
|
2012-09-04 20:15:10 +02:00
|
|
|
wined3d_swapchain_incref(ddraw->wined3d_swapchain);
|
2011-11-28 21:30:57 +01:00
|
|
|
ddraw_set_swapchain_window(ddraw, window);
|
|
|
|
|
2017-01-13 12:11:17 +01:00
|
|
|
if (ddraw->primary && ddraw->primary->palette)
|
|
|
|
wined3d_swapchain_set_palette(ddraw->wined3d_swapchain, ddraw->primary->palette->wined3d_palette);
|
|
|
|
|
2011-11-28 21:30:57 +01:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::RestoreDisplayMode
|
|
|
|
*
|
|
|
|
* Restores the display mode to what it was at creation time. Basically.
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_NOEXCLUSIVE mode if the device isn't in fullscreen mode
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI ddraw7_RestoreDisplayMode(IDirectDraw7 *iface)
|
|
|
|
{
|
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
|
|
|
|
|
|
|
if (!(ddraw->flags & DDRAW_RESTORE_MODE))
|
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (exclusive_ddraw && exclusive_ddraw != ddraw)
|
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOEXCLUSIVEMODE;
|
|
|
|
}
|
|
|
|
|
2014-11-19 20:13:53 +01:00
|
|
|
if (SUCCEEDED(hr = wined3d_set_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, NULL)))
|
2013-06-05 10:55:40 +02:00
|
|
|
ddraw->flags &= ~DDRAW_RESTORE_MODE;
|
|
|
|
|
2017-02-01 12:02:55 +01:00
|
|
|
InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_NOT_RESTORED, DDRAW_DEVICE_STATE_OK);
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw4_RestoreDisplayMode(IDirectDraw4 *iface)
|
|
|
|
{
|
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return ddraw7_RestoreDisplayMode(&ddraw->IDirectDraw7_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_RestoreDisplayMode(IDirectDraw2 *iface)
|
|
|
|
{
|
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return ddraw7_RestoreDisplayMode(&ddraw->IDirectDraw7_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_RestoreDisplayMode(IDirectDraw *iface)
|
|
|
|
{
|
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return ddraw7_RestoreDisplayMode(&ddraw->IDirectDraw7_iface);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::SetCooperativeLevel
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Sets the cooperative level for the DirectDraw object, and the window
|
2006-06-09 19:36:12 +02:00
|
|
|
* assigned to it. The cooperative level determines the general behavior
|
|
|
|
* of the DirectDraw application
|
|
|
|
*
|
|
|
|
* Warning: This is quite tricky, as it's not really documented which
|
|
|
|
* cooperative levels can be combined with each other. If a game fails
|
|
|
|
* after this function, try to check the cooperative levels passed on
|
|
|
|
* Windows, and if it returns something different.
|
|
|
|
*
|
|
|
|
* If you think that this function caused the failure because it writes a
|
|
|
|
* fixme, be sure to run again with a +ddraw trace.
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* What is known about cooperative levels (See the ddraw modes test):
|
2013-06-05 10:55:42 +02:00
|
|
|
* DDSCL_EXCLUSIVE requires DDSCL_FULLSCREEN.
|
|
|
|
* DDSCL_NORMAL is not compatible with DDSCL_EXCLUSIVE.
|
|
|
|
* Unlike what msdn claims, DDSCL_NORMAL | DDSCL_FULLSCREEN is allowed.
|
2006-06-09 19:36:12 +02:00
|
|
|
* DDSCL_SETFOCUSWINDOW can be passed only in DDSCL_NORMAL mode, but after that
|
2013-06-05 10:55:42 +02:00
|
|
|
* DDSCL_EXCLUSIVE can be activated.
|
|
|
|
* DDSCL_SETFOCUSWINDOW may only be used with DDSCL_NOWINDOWCHANGES or
|
|
|
|
* DDSCL_CREATEDEVICEWINDOW.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Handled flags: DDSCL_NORMAL, DDSCL_FULLSCREEN, DDSCL_EXCLUSIVE,
|
2013-06-05 10:55:42 +02:00
|
|
|
* DDSCL_CREATEDEVICEWINDOW, DDSCL_SETDEVICEWINDOW
|
2007-03-04 17:03:03 +01:00
|
|
|
* DDSCL_SETFOCUSWINDOW (partially),
|
|
|
|
* DDSCL_MULTITHREADED (work in progress)
|
2013-06-05 10:55:42 +02:00
|
|
|
* DDSCL_FPUPRESERVE (see device.c)
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
2013-06-05 10:55:42 +02:00
|
|
|
* Unsure about this: DDSCL_FPUSETUP
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
2008-04-02 21:26:42 +02:00
|
|
|
* These don't seem very important for wine:
|
2007-03-04 17:03:03 +01:00
|
|
|
* DDSCL_ALLOWREBOOT, DDSCL_NOWINDOWCHANGES, DDSCL_ALLOWMODEX
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK if the cooperative level was set successfully
|
|
|
|
* DDERR_INVALIDPARAMS if the passed cooperative level combination is invalid
|
2006-06-23 18:18:02 +02:00
|
|
|
* DDERR_HWNDALREADYSET if DDSCL_SETFOCUSWINDOW is passed in exclusive mode
|
|
|
|
* (Probably others too, have to investigate)
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2013-06-08 00:47:28 +02:00
|
|
|
static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window,
|
2013-06-05 10:55:40 +02:00
|
|
|
DWORD cooplevel, BOOL restore_mode_on_normal)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2014-08-22 12:32:01 +02:00
|
|
|
struct wined3d_rendertarget_view *rtv = NULL, *dsv = NULL;
|
2012-01-17 21:13:35 +01:00
|
|
|
struct wined3d_stateblock *stateblock;
|
|
|
|
BOOL restore_state = FALSE;
|
2011-08-29 18:58:59 +02:00
|
|
|
HRESULT hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
TRACE("ddraw %p, window %p, flags %#x, restore_mode_on_normal %x.\n", ddraw, window, cooplevel,
|
|
|
|
restore_mode_on_normal);
|
2006-06-09 19:36:12 +02:00
|
|
|
DDRAW_dump_cooperativelevel(cooplevel);
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2007-05-21 01:13:52 +02:00
|
|
|
|
2013-09-02 11:22:30 +02:00
|
|
|
if (ddraw->flags & DDRAW_SCL_RECURSIVE)
|
|
|
|
{
|
|
|
|
WARN("Recursive call, returning DD_OK.\n");
|
|
|
|
hr = DD_OK;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ddraw->flags |= DDRAW_SCL_RECURSIVE;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Tests suggest that we need one of them: */
|
|
|
|
if(!(cooplevel & (DDSCL_SETFOCUSWINDOW |
|
|
|
|
DDSCL_NORMAL |
|
|
|
|
DDSCL_EXCLUSIVE )))
|
|
|
|
{
|
|
|
|
TRACE("Incorrect cooplevel flags, returning DDERR_INVALIDPARAMS\n");
|
2013-09-02 11:22:30 +02:00
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
goto done;
|
2011-12-22 21:51:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((cooplevel & DDSCL_CREATEDEVICEWINDOW) && !(cooplevel & DDSCL_EXCLUSIVE))
|
|
|
|
{
|
|
|
|
WARN("DDSCL_CREATEDEVICEWINDOW requires DDSCL_EXCLUSIVE.\n");
|
2013-09-02 11:22:30 +02:00
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
goto done;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2006-06-23 18:18:02 +02:00
|
|
|
/* Handle those levels first which set various hwnds */
|
2011-12-22 21:51:21 +01:00
|
|
|
if ((cooplevel & DDSCL_SETFOCUSWINDOW) && !(cooplevel & DDSCL_CREATEDEVICEWINDOW))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
/* This isn't compatible with a lot of flags */
|
2011-12-22 21:51:21 +01:00
|
|
|
if (cooplevel & (DDSCL_MULTITHREADED
|
|
|
|
| DDSCL_FPUSETUP
|
|
|
|
| DDSCL_FPUPRESERVE
|
|
|
|
| DDSCL_ALLOWREBOOT
|
|
|
|
| DDSCL_ALLOWMODEX
|
|
|
|
| DDSCL_SETDEVICEWINDOW
|
|
|
|
| DDSCL_NORMAL
|
|
|
|
| DDSCL_EXCLUSIVE
|
|
|
|
| DDSCL_FULLSCREEN))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-12-22 21:51:21 +01:00
|
|
|
WARN("Called with incompatible flags, returning DDERR_INVALIDPARAMS.\n");
|
2013-09-02 11:22:30 +02:00
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
goto done;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2010-10-22 08:32:39 +02:00
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
hr = ddraw_set_focus_window(ddraw, window);
|
2013-09-02 11:22:30 +02:00
|
|
|
goto done;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2010-03-17 21:59:49 +01:00
|
|
|
|
2011-12-22 21:51:20 +01:00
|
|
|
if (cooplevel & DDSCL_EXCLUSIVE)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2013-01-15 08:46:55 +01:00
|
|
|
if (!(cooplevel & DDSCL_FULLSCREEN) || !(window || (cooplevel & DDSCL_CREATEDEVICEWINDOW)))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-12-22 21:51:20 +01:00
|
|
|
WARN("DDSCL_EXCLUSIVE requires DDSCL_FULLSCREEN and a window.\n");
|
2013-09-02 11:22:30 +02:00
|
|
|
hr = DDERR_INVALIDPARAMS;
|
|
|
|
goto done;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2011-12-22 21:51:20 +01:00
|
|
|
|
|
|
|
if (cooplevel & DDSCL_CREATEDEVICEWINDOW)
|
|
|
|
{
|
|
|
|
HWND device_window;
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
if (!ddraw->focuswindow && !(cooplevel & DDSCL_SETFOCUSWINDOW))
|
2011-12-22 21:51:20 +01:00
|
|
|
{
|
|
|
|
WARN("No focus window set.\n");
|
2013-09-02 11:22:30 +02:00
|
|
|
hr = DDERR_NOFOCUSWINDOW;
|
|
|
|
goto done;
|
2011-12-22 21:51:20 +01:00
|
|
|
}
|
|
|
|
|
2011-12-22 21:51:22 +01:00
|
|
|
device_window = CreateWindowExA(0, DDRAW_WINDOW_CLASS_NAME, "DirectDrawDeviceWnd",
|
2011-12-22 21:51:20 +01:00
|
|
|
WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
if (!device_window)
|
|
|
|
{
|
|
|
|
ERR("Failed to create window, last error %#x.\n", GetLastError());
|
2013-09-02 11:22:30 +02:00
|
|
|
hr = E_FAIL;
|
|
|
|
goto done;
|
2011-12-22 21:51:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ShowWindow(device_window, SW_SHOW);
|
|
|
|
TRACE("Created a device window %p.\n", device_window);
|
|
|
|
|
2011-12-22 21:51:21 +01:00
|
|
|
/* Native apparently leaks the created device window if setting the
|
|
|
|
* focus window below fails. */
|
2013-06-05 10:55:40 +02:00
|
|
|
ddraw->cooperative_level |= DDSCL_CREATEDEVICEWINDOW;
|
|
|
|
ddraw->devicewindow = device_window;
|
2011-12-22 21:51:21 +01:00
|
|
|
|
|
|
|
if (cooplevel & DDSCL_SETFOCUSWINDOW)
|
|
|
|
{
|
2013-01-15 08:46:55 +01:00
|
|
|
if (!window)
|
2011-12-22 21:51:21 +01:00
|
|
|
{
|
2013-09-02 11:22:30 +02:00
|
|
|
hr = DDERR_NOHWND;
|
|
|
|
goto done;
|
2011-12-22 21:51:21 +01:00
|
|
|
}
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
if (FAILED(hr = ddraw_set_focus_window(ddraw, window)))
|
2013-09-02 11:22:30 +02:00
|
|
|
goto done;
|
2011-12-22 21:51:21 +01:00
|
|
|
}
|
|
|
|
|
2013-01-15 08:46:55 +01:00
|
|
|
window = device_window;
|
2011-12-22 21:51:20 +01:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2011-12-22 21:51:19 +01:00
|
|
|
else
|
|
|
|
{
|
2013-06-05 10:55:40 +02:00
|
|
|
if (ddraw->cooperative_level & DDSCL_CREATEDEVICEWINDOW)
|
|
|
|
DestroyWindow(ddraw->devicewindow);
|
|
|
|
ddraw->devicewindow = NULL;
|
|
|
|
ddraw->focuswindow = NULL;
|
2011-12-22 21:51:19 +01:00
|
|
|
}
|
2010-11-10 10:53:01 +01:00
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
if ((cooplevel & DDSCL_FULLSCREEN) != (ddraw->cooperative_level & DDSCL_FULLSCREEN) || window != ddraw->dest_window)
|
2010-11-03 07:10:54 +01:00
|
|
|
{
|
2013-06-05 10:55:40 +02:00
|
|
|
if (ddraw->cooperative_level & DDSCL_FULLSCREEN)
|
2016-08-03 09:41:39 +02:00
|
|
|
wined3d_device_restore_fullscreen_window(ddraw->wined3d_device, ddraw->dest_window, NULL);
|
2011-05-16 23:01:22 +02:00
|
|
|
|
2010-11-08 11:50:33 +01:00
|
|
|
if (cooplevel & DDSCL_FULLSCREEN)
|
|
|
|
{
|
2011-11-16 20:08:06 +01:00
|
|
|
struct wined3d_display_mode display_mode;
|
2010-11-08 11:50:33 +01:00
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &display_mode, NULL);
|
|
|
|
wined3d_device_setup_fullscreen_window(ddraw->wined3d_device, window,
|
2011-11-16 20:08:06 +01:00
|
|
|
display_mode.width, display_mode.height);
|
2010-11-08 11:50:33 +01:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2015-12-04 11:30:15 +01:00
|
|
|
if ((cooplevel & DDSCL_EXCLUSIVE) && exclusive_window != window)
|
|
|
|
{
|
|
|
|
ddraw->device_state = DDRAW_DEVICE_STATE_NOT_RESTORED;
|
|
|
|
exclusive_window = window;
|
|
|
|
}
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
if (cooplevel & DDSCL_MULTITHREADED && !(ddraw->cooperative_level & DDSCL_MULTITHREADED))
|
|
|
|
wined3d_device_set_multithreaded(ddraw->wined3d_device);
|
2007-03-04 17:03:03 +01:00
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
if (ddraw->wined3d_swapchain)
|
2012-01-17 21:13:35 +01:00
|
|
|
{
|
2013-06-05 10:55:40 +02:00
|
|
|
if (!(ddraw->flags & DDRAW_NO3D))
|
2012-01-17 21:13:35 +01:00
|
|
|
{
|
|
|
|
restore_state = TRUE;
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
if (FAILED(hr = wined3d_stateblock_create(ddraw->wined3d_device, WINED3D_SBT_ALL, &stateblock)))
|
2012-01-17 21:13:35 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to create stateblock, hr %#x.\n", hr);
|
2013-09-02 11:22:30 +02:00
|
|
|
goto done;
|
2012-01-17 21:13:35 +01:00
|
|
|
}
|
|
|
|
|
2012-10-04 23:42:16 +02:00
|
|
|
wined3d_stateblock_capture(stateblock);
|
2014-08-21 09:55:55 +02:00
|
|
|
rtv = wined3d_device_get_rendertarget_view(ddraw->wined3d_device, 0);
|
|
|
|
/* Rendering to ddraw->wined3d_frontbuffer. */
|
|
|
|
if (rtv && !wined3d_rendertarget_view_get_sub_resource_parent(rtv))
|
|
|
|
rtv = NULL;
|
|
|
|
else if (rtv)
|
|
|
|
wined3d_rendertarget_view_incref(rtv);
|
2012-01-17 21:13:35 +01:00
|
|
|
|
2014-08-22 12:32:01 +02:00
|
|
|
if ((dsv = wined3d_device_get_depth_stencil_view(ddraw->wined3d_device)))
|
|
|
|
wined3d_rendertarget_view_incref(dsv);
|
2012-01-17 21:13:35 +01:00
|
|
|
}
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
ddraw_destroy_swapchain(ddraw);
|
2012-01-17 21:13:35 +01:00
|
|
|
}
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
if (FAILED(hr = ddraw_create_swapchain(ddraw, window, !(cooplevel & DDSCL_FULLSCREEN))))
|
2011-11-28 21:30:57 +01:00
|
|
|
ERR("Failed to create swapchain, hr %#x.\n", hr);
|
|
|
|
|
2012-01-17 21:13:35 +01:00
|
|
|
if (restore_state)
|
|
|
|
{
|
2014-08-22 12:32:01 +02:00
|
|
|
if (dsv)
|
2012-01-17 21:13:35 +01:00
|
|
|
{
|
2014-08-22 12:32:01 +02:00
|
|
|
wined3d_device_set_depth_stencil_view(ddraw->wined3d_device, dsv);
|
|
|
|
wined3d_rendertarget_view_decref(dsv);
|
2012-01-17 21:13:35 +01:00
|
|
|
}
|
|
|
|
|
2014-08-21 09:55:55 +02:00
|
|
|
if (rtv)
|
2012-01-17 21:13:35 +01:00
|
|
|
{
|
2014-08-21 09:55:55 +02:00
|
|
|
wined3d_device_set_rendertarget_view(ddraw->wined3d_device, 0, rtv, FALSE);
|
|
|
|
wined3d_rendertarget_view_decref(rtv);
|
2012-01-17 21:13:35 +01:00
|
|
|
}
|
|
|
|
|
2012-10-04 23:42:17 +02:00
|
|
|
wined3d_stateblock_apply(stateblock);
|
2012-01-17 21:13:35 +01:00
|
|
|
wined3d_stateblock_decref(stateblock);
|
|
|
|
}
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
if (!(cooplevel & DDSCL_EXCLUSIVE) && (ddraw->cooperative_level & DDSCL_EXCLUSIVE)
|
|
|
|
&& restore_mode_on_normal)
|
|
|
|
{
|
|
|
|
hr = ddraw7_RestoreDisplayMode(&ddraw->IDirectDraw7_iface);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("RestoreDisplayMode failed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ddraw->cooperative_level & DDSCL_EXCLUSIVE)
|
|
|
|
&& (window != ddraw->dest_window || !(cooplevel & DDSCL_EXCLUSIVE)))
|
|
|
|
wined3d_device_release_focus_window(ddraw->wined3d_device);
|
2013-06-05 10:55:39 +02:00
|
|
|
|
|
|
|
if ((cooplevel & DDSCL_EXCLUSIVE)
|
2013-06-05 10:55:40 +02:00
|
|
|
&& (window != ddraw->dest_window || !(ddraw->cooperative_level & DDSCL_EXCLUSIVE)))
|
2013-06-05 10:55:39 +02:00
|
|
|
{
|
2013-06-05 10:55:40 +02:00
|
|
|
hr = wined3d_device_acquire_focus_window(ddraw->wined3d_device, window);
|
2013-06-05 10:55:39 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to acquire focus window, hr %#x.\n", hr);
|
2013-09-02 11:22:30 +02:00
|
|
|
goto done;
|
2013-06-05 10:55:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Unhandled flags */
|
2013-06-05 10:55:40 +02:00
|
|
|
if (cooplevel & DDSCL_ALLOWREBOOT)
|
|
|
|
WARN("Unhandled flag DDSCL_ALLOWREBOOT, harmless\n");
|
|
|
|
if (cooplevel & DDSCL_ALLOWMODEX)
|
|
|
|
WARN("Unhandled flag DDSCL_ALLOWMODEX, harmless\n");
|
|
|
|
if (cooplevel & DDSCL_FPUSETUP)
|
|
|
|
WARN("Unhandled flag DDSCL_FPUSETUP, harmless\n");
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-10-16 22:43:10 +02:00
|
|
|
if (cooplevel & DDSCL_EXCLUSIVE)
|
2013-06-05 10:55:40 +02:00
|
|
|
exclusive_ddraw = ddraw;
|
|
|
|
else if (exclusive_ddraw == ddraw)
|
2012-10-16 22:43:10 +02:00
|
|
|
exclusive_ddraw = NULL;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Store the cooperative_level */
|
2013-06-05 10:55:40 +02:00
|
|
|
ddraw->cooperative_level = cooplevel;
|
|
|
|
ddraw->dest_window = window;
|
|
|
|
|
2015-11-26 23:23:09 +01:00
|
|
|
TRACE("SetCooperativeLevel returning DD_OK\n");
|
2013-09-02 11:22:30 +02:00
|
|
|
hr = DD_OK;
|
|
|
|
done:
|
|
|
|
ddraw->flags &= ~DDRAW_SCL_RECURSIVE;
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2013-09-02 11:22:30 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND window, DWORD flags)
|
|
|
|
{
|
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
|
|
|
|
|
|
|
|
return ddraw_set_cooperative_level(ddraw, window, flags, !(ddraw->flags & DDRAW_SCL_DDRAW1));
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_SetCooperativeLevel(IDirectDraw4 *iface, HWND window, DWORD flags)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
return ddraw_set_cooperative_level(ddraw, window, flags, !(ddraw->flags & DDRAW_SCL_DDRAW1));
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_SetCooperativeLevel(IDirectDraw2 *iface, HWND window, DWORD flags)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
return ddraw_set_cooperative_level(ddraw, window, flags, !(ddraw->flags & DDRAW_SCL_DDRAW1));
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_SetCooperativeLevel(IDirectDraw *iface, HWND window, DWORD flags)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2013-06-05 10:55:40 +02:00
|
|
|
HRESULT hr;
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
|
|
|
|
|
2013-06-05 10:55:40 +02:00
|
|
|
hr = ddraw_set_cooperative_level(ddraw, window, flags, FALSE);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
ddraw->flags |= DDRAW_SCL_DDRAW1;
|
|
|
|
return hr;
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2008-03-10 17:44:38 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::SetDisplayMode
|
|
|
|
*
|
|
|
|
* Sets the display screen resolution, color depth and refresh frequency
|
|
|
|
* when in fullscreen mode (in theory).
|
|
|
|
* Possible return values listed in the SDK suggest that this method fails
|
|
|
|
* when not in fullscreen mode, but this is wrong. Windows 2000 happily sets
|
|
|
|
* the display mode in DDSCL_NORMAL mode without an hwnd specified.
|
|
|
|
* It seems to be valid to pass 0 for With and Height, this has to be tested
|
|
|
|
* It could mean that the current video mode should be left as-is. (But why
|
|
|
|
* call it then?)
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Height, Width: Screen dimension
|
|
|
|
* BPP: Color depth in Bits per pixel
|
|
|
|
* Refreshrate: Screen refresh rate
|
|
|
|
* Flags: Other stuff
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* DD_OK on success
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-10-15 22:26:21 +02:00
|
|
|
static HRESULT WINAPI ddraw7_SetDisplayMode(IDirectDraw7 *iface, DWORD width, DWORD height,
|
|
|
|
DWORD bpp, DWORD refresh_rate, DWORD flags)
|
2008-03-10 17:44:38 +01:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2012-10-15 22:26:21 +02:00
|
|
|
struct wined3d_display_mode mode;
|
|
|
|
enum wined3d_format_id format;
|
|
|
|
HRESULT hr;
|
2011-01-18 12:24:26 +01:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
|
2012-10-15 22:26:21 +02:00
|
|
|
iface, width, height, bpp, refresh_rate, flags);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2008-03-10 17:44:38 +01:00
|
|
|
if (force_refresh_rate != 0)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("ForceRefreshRate overriding passed-in refresh rate (%u Hz) to %u Hz\n",
|
2012-10-15 22:26:21 +02:00
|
|
|
refresh_rate, force_refresh_rate);
|
|
|
|
refresh_rate = force_refresh_rate;
|
2008-03-10 17:44:38 +01:00
|
|
|
}
|
|
|
|
|
2012-10-15 22:26:21 +02:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
|
2012-10-16 22:43:10 +02:00
|
|
|
if (exclusive_ddraw && exclusive_ddraw != ddraw)
|
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOEXCLUSIVEMODE;
|
|
|
|
}
|
|
|
|
|
2012-10-15 22:26:21 +02:00
|
|
|
if (!width || !height)
|
|
|
|
{
|
|
|
|
/* It looks like Need for Speed Porsche Unleashed expects DD_OK here. */
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (bpp)
|
|
|
|
{
|
|
|
|
case 8: format = WINED3DFMT_P8_UINT; break;
|
|
|
|
case 15: format = WINED3DFMT_B5G5R5X1_UNORM; break;
|
|
|
|
case 16: format = WINED3DFMT_B5G6R5_UNORM; break;
|
|
|
|
case 24: format = WINED3DFMT_B8G8R8_UNORM; break;
|
|
|
|
case 32: format = WINED3DFMT_B8G8R8X8_UNORM; break;
|
|
|
|
default: format = WINED3DFMT_UNKNOWN; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mode.width = width;
|
|
|
|
mode.height = height;
|
|
|
|
mode.refresh_rate = refresh_rate;
|
|
|
|
mode.format_id = format;
|
|
|
|
mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
|
|
|
|
|
|
|
|
/* TODO: The possible return values from msdn suggest that the screen mode
|
|
|
|
* can't be changed if a surface is locked or some drawing is in progress. */
|
2012-10-16 22:43:11 +02:00
|
|
|
if (SUCCEEDED(hr = wined3d_set_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode)))
|
2017-02-01 12:02:58 +01:00
|
|
|
{
|
|
|
|
if (ddraw->primary)
|
|
|
|
{
|
|
|
|
DDSURFACEDESC2 *surface_desc = &ddraw->primary->surface_desc;
|
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_swapchain_resize_buffers(ddraw->wined3d_swapchain, 0,
|
|
|
|
surface_desc->dwWidth, surface_desc->dwHeight, mode.format_id, WINED3D_MULTISAMPLE_NONE, 0)))
|
|
|
|
ERR("Failed to resize buffers, hr %#x.\n", hr);
|
|
|
|
else
|
|
|
|
ddrawformat_from_wined3dformat(&ddraw->primary->surface_desc.u4.ddpfPixelFormat, mode.format_id);
|
|
|
|
}
|
2013-05-30 10:05:32 +02:00
|
|
|
ddraw->flags |= DDRAW_RESTORE_MODE;
|
2017-02-01 12:02:58 +01:00
|
|
|
}
|
2012-10-15 22:26:21 +02:00
|
|
|
|
2017-02-01 12:02:55 +01:00
|
|
|
InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_NOT_RESTORED, DDRAW_DEVICE_STATE_OK);
|
|
|
|
|
2012-10-15 22:26:21 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
switch (hr)
|
|
|
|
{
|
|
|
|
case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2011-01-19 01:40:53 +01:00
|
|
|
static HRESULT WINAPI ddraw4_SetDisplayMode(IDirectDraw4 *iface, DWORD width, DWORD height,
|
|
|
|
DWORD bpp, DWORD refresh_rate, DWORD flags)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
|
|
|
|
iface, width, height, bpp, refresh_rate, flags);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_SetDisplayMode(&ddraw->IDirectDraw7_iface, width, height, bpp, refresh_rate, flags);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_SetDisplayMode(IDirectDraw2 *iface,
|
|
|
|
DWORD width, DWORD height, DWORD bpp, DWORD refresh_rate, DWORD flags)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
|
|
|
|
iface, width, height, bpp, refresh_rate, flags);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_SetDisplayMode(&ddraw->IDirectDraw7_iface, width, height, bpp, refresh_rate, flags);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_SetDisplayMode(IDirectDraw *iface, DWORD width, DWORD height, DWORD bpp)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, width %u, height %u, bpp %u.\n", iface, width, height, bpp);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_SetDisplayMode(&ddraw->IDirectDraw7_iface, width, height, bpp, 0, 0);
|
2008-03-10 17:44:38 +01:00
|
|
|
}
|
|
|
|
|
2013-09-06 09:57:41 +02:00
|
|
|
void ddraw_d3dcaps1_from_7(D3DDEVICEDESC *caps1, D3DDEVICEDESC7 *caps7)
|
|
|
|
{
|
|
|
|
memset(caps1, 0, sizeof(*caps1));
|
|
|
|
caps1->dwSize = sizeof(*caps1);
|
|
|
|
caps1->dwFlags = D3DDD_COLORMODEL
|
|
|
|
| D3DDD_DEVCAPS
|
|
|
|
| D3DDD_TRANSFORMCAPS
|
|
|
|
| D3DDD_BCLIPPING
|
|
|
|
| D3DDD_LIGHTINGCAPS
|
|
|
|
| D3DDD_LINECAPS
|
|
|
|
| D3DDD_TRICAPS
|
|
|
|
| D3DDD_DEVICERENDERBITDEPTH
|
|
|
|
| D3DDD_DEVICEZBUFFERBITDEPTH
|
|
|
|
| D3DDD_MAXBUFFERSIZE
|
|
|
|
| D3DDD_MAXVERTEXCOUNT;
|
|
|
|
caps1->dcmColorModel = D3DCOLOR_RGB;
|
|
|
|
caps1->dwDevCaps = caps7->dwDevCaps;
|
|
|
|
caps1->dtcTransformCaps.dwSize = sizeof(caps1->dtcTransformCaps);
|
|
|
|
caps1->dtcTransformCaps.dwCaps = D3DTRANSFORMCAPS_CLIP;
|
|
|
|
caps1->bClipping = TRUE;
|
|
|
|
caps1->dlcLightingCaps.dwSize = sizeof(caps1->dlcLightingCaps);
|
|
|
|
caps1->dlcLightingCaps.dwCaps = D3DLIGHTCAPS_DIRECTIONAL
|
|
|
|
| D3DLIGHTCAPS_PARALLELPOINT
|
|
|
|
| D3DLIGHTCAPS_POINT
|
|
|
|
| D3DLIGHTCAPS_SPOT;
|
|
|
|
caps1->dlcLightingCaps.dwLightingModel = D3DLIGHTINGMODEL_RGB;
|
|
|
|
caps1->dlcLightingCaps.dwNumLights = caps7->dwMaxActiveLights;
|
|
|
|
caps1->dpcLineCaps = caps7->dpcLineCaps;
|
|
|
|
caps1->dpcTriCaps = caps7->dpcTriCaps;
|
|
|
|
caps1->dwDeviceRenderBitDepth = caps7->dwDeviceRenderBitDepth;
|
|
|
|
caps1->dwDeviceZBufferBitDepth = caps7->dwDeviceZBufferBitDepth;
|
|
|
|
caps1->dwMaxBufferSize = 0;
|
|
|
|
caps1->dwMaxVertexCount = 65536;
|
|
|
|
caps1->dwMinTextureWidth = caps7->dwMinTextureWidth;
|
|
|
|
caps1->dwMinTextureHeight = caps7->dwMinTextureHeight;
|
|
|
|
caps1->dwMaxTextureWidth = caps7->dwMaxTextureWidth;
|
|
|
|
caps1->dwMaxTextureHeight = caps7->dwMaxTextureHeight;
|
|
|
|
caps1->dwMinStippleWidth = 1;
|
|
|
|
caps1->dwMinStippleHeight = 1;
|
|
|
|
caps1->dwMaxStippleWidth = 32;
|
|
|
|
caps1->dwMaxStippleHeight = 32;
|
|
|
|
caps1->dwMaxTextureRepeat = caps7->dwMaxTextureRepeat;
|
|
|
|
caps1->dwMaxTextureAspectRatio = caps7->dwMaxTextureAspectRatio;
|
|
|
|
caps1->dwMaxAnisotropy = caps7->dwMaxAnisotropy;
|
|
|
|
caps1->dvGuardBandLeft = caps7->dvGuardBandLeft;
|
|
|
|
caps1->dvGuardBandTop = caps7->dvGuardBandTop;
|
|
|
|
caps1->dvGuardBandRight = caps7->dvGuardBandRight;
|
|
|
|
caps1->dvGuardBandBottom = caps7->dvGuardBandBottom;
|
|
|
|
caps1->dvExtentsAdjust = caps7->dvExtentsAdjust;
|
|
|
|
caps1->dwStencilCaps = caps7->dwStencilCaps;
|
|
|
|
caps1->dwFVFCaps = caps7->dwFVFCaps;
|
|
|
|
caps1->dwTextureOpCaps = caps7->dwTextureOpCaps;
|
|
|
|
caps1->wMaxTextureBlendStages = caps7->wMaxTextureBlendStages;
|
|
|
|
caps1->wMaxSimultaneousTextures = caps7->wMaxSimultaneousTextures;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT ddraw_get_d3dcaps(const struct ddraw *ddraw, D3DDEVICEDESC7 *caps)
|
|
|
|
{
|
|
|
|
WINED3DCAPS wined3d_caps;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("ddraw %p, caps %p.\n", ddraw, caps);
|
|
|
|
|
|
|
|
memset(&wined3d_caps, 0, sizeof(wined3d_caps));
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
|
|
|
hr = wined3d_get_device_caps(ddraw->wined3d, 0, WINED3D_DEVICE_TYPE_HAL, &wined3d_caps);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to get device caps, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
caps->dwDevCaps = wined3d_caps.DevCaps;
|
|
|
|
caps->dpcLineCaps.dwMiscCaps = wined3d_caps.PrimitiveMiscCaps;
|
|
|
|
caps->dpcLineCaps.dwRasterCaps = wined3d_caps.RasterCaps;
|
|
|
|
caps->dpcLineCaps.dwZCmpCaps = wined3d_caps.ZCmpCaps;
|
|
|
|
caps->dpcLineCaps.dwSrcBlendCaps = wined3d_caps.SrcBlendCaps;
|
|
|
|
caps->dpcLineCaps.dwDestBlendCaps = wined3d_caps.DestBlendCaps;
|
|
|
|
caps->dpcLineCaps.dwAlphaCmpCaps = wined3d_caps.AlphaCmpCaps;
|
|
|
|
caps->dpcLineCaps.dwShadeCaps = wined3d_caps.ShadeCaps;
|
|
|
|
caps->dpcLineCaps.dwTextureCaps = wined3d_caps.TextureCaps;
|
|
|
|
caps->dpcLineCaps.dwTextureFilterCaps = wined3d_caps.TextureFilterCaps;
|
|
|
|
caps->dpcLineCaps.dwTextureAddressCaps = wined3d_caps.TextureAddressCaps;
|
|
|
|
|
|
|
|
caps->dwMaxTextureWidth = wined3d_caps.MaxTextureWidth;
|
|
|
|
caps->dwMaxTextureHeight = wined3d_caps.MaxTextureHeight;
|
|
|
|
|
|
|
|
caps->dwMaxTextureRepeat = wined3d_caps.MaxTextureRepeat;
|
|
|
|
caps->dwMaxTextureAspectRatio = wined3d_caps.MaxTextureAspectRatio;
|
|
|
|
caps->dwMaxAnisotropy = wined3d_caps.MaxAnisotropy;
|
|
|
|
caps->dvMaxVertexW = wined3d_caps.MaxVertexW;
|
|
|
|
|
|
|
|
caps->dvGuardBandLeft = wined3d_caps.GuardBandLeft;
|
|
|
|
caps->dvGuardBandTop = wined3d_caps.GuardBandTop;
|
|
|
|
caps->dvGuardBandRight = wined3d_caps.GuardBandRight;
|
|
|
|
caps->dvGuardBandBottom = wined3d_caps.GuardBandBottom;
|
|
|
|
|
|
|
|
caps->dvExtentsAdjust = wined3d_caps.ExtentsAdjust;
|
|
|
|
caps->dwStencilCaps = wined3d_caps.StencilCaps;
|
|
|
|
|
|
|
|
caps->dwFVFCaps = wined3d_caps.FVFCaps;
|
|
|
|
caps->dwTextureOpCaps = wined3d_caps.TextureOpCaps;
|
|
|
|
|
|
|
|
caps->dwVertexProcessingCaps = wined3d_caps.VertexProcessingCaps;
|
|
|
|
caps->dwMaxActiveLights = wined3d_caps.MaxActiveLights;
|
|
|
|
|
|
|
|
/* Remove all non-d3d7 caps */
|
|
|
|
caps->dwDevCaps &= (
|
|
|
|
D3DDEVCAPS_FLOATTLVERTEX | D3DDEVCAPS_SORTINCREASINGZ | D3DDEVCAPS_SORTDECREASINGZ |
|
|
|
|
D3DDEVCAPS_SORTEXACT | D3DDEVCAPS_EXECUTESYSTEMMEMORY | D3DDEVCAPS_EXECUTEVIDEOMEMORY |
|
|
|
|
D3DDEVCAPS_TLVERTEXSYSTEMMEMORY | D3DDEVCAPS_TLVERTEXVIDEOMEMORY | D3DDEVCAPS_TEXTURESYSTEMMEMORY |
|
|
|
|
D3DDEVCAPS_TEXTUREVIDEOMEMORY | D3DDEVCAPS_DRAWPRIMTLVERTEX | D3DDEVCAPS_CANRENDERAFTERFLIP |
|
|
|
|
D3DDEVCAPS_TEXTURENONLOCALVIDMEM | D3DDEVCAPS_DRAWPRIMITIVES2 | D3DDEVCAPS_SEPARATETEXTUREMEMORIES |
|
|
|
|
D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_CANBLTSYSTONONLOCAL |
|
|
|
|
D3DDEVCAPS_HWRASTERIZATION);
|
|
|
|
|
|
|
|
caps->dwStencilCaps &= (
|
|
|
|
D3DSTENCILCAPS_KEEP | D3DSTENCILCAPS_ZERO | D3DSTENCILCAPS_REPLACE |
|
|
|
|
D3DSTENCILCAPS_INCRSAT | D3DSTENCILCAPS_DECRSAT | D3DSTENCILCAPS_INVERT |
|
|
|
|
D3DSTENCILCAPS_INCR | D3DSTENCILCAPS_DECR);
|
|
|
|
|
|
|
|
/* FVF caps ?*/
|
|
|
|
|
|
|
|
caps->dwTextureOpCaps &= (
|
|
|
|
D3DTEXOPCAPS_DISABLE | D3DTEXOPCAPS_SELECTARG1 | D3DTEXOPCAPS_SELECTARG2 |
|
|
|
|
D3DTEXOPCAPS_MODULATE | D3DTEXOPCAPS_MODULATE2X | D3DTEXOPCAPS_MODULATE4X |
|
|
|
|
D3DTEXOPCAPS_ADD | D3DTEXOPCAPS_ADDSIGNED | D3DTEXOPCAPS_ADDSIGNED2X |
|
|
|
|
D3DTEXOPCAPS_SUBTRACT | D3DTEXOPCAPS_ADDSMOOTH | D3DTEXOPCAPS_BLENDTEXTUREALPHA |
|
|
|
|
D3DTEXOPCAPS_BLENDFACTORALPHA | D3DTEXOPCAPS_BLENDTEXTUREALPHAPM | D3DTEXOPCAPS_BLENDCURRENTALPHA |
|
|
|
|
D3DTEXOPCAPS_PREMODULATE | D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR | D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
|
|
|
|
D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR | D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA | D3DTEXOPCAPS_BUMPENVMAP |
|
|
|
|
D3DTEXOPCAPS_BUMPENVMAPLUMINANCE | D3DTEXOPCAPS_DOTPRODUCT3);
|
|
|
|
|
|
|
|
caps->dwVertexProcessingCaps &= (
|
|
|
|
D3DVTXPCAPS_TEXGEN | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_VERTEXFOG |
|
|
|
|
D3DVTXPCAPS_DIRECTIONALLIGHTS | D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_LOCALVIEWER);
|
|
|
|
|
|
|
|
caps->dpcLineCaps.dwMiscCaps &= (
|
|
|
|
D3DPMISCCAPS_MASKPLANES | D3DPMISCCAPS_MASKZ | D3DPMISCCAPS_LINEPATTERNREP |
|
|
|
|
D3DPMISCCAPS_CONFORMANT | D3DPMISCCAPS_CULLNONE | D3DPMISCCAPS_CULLCW |
|
|
|
|
D3DPMISCCAPS_CULLCCW);
|
|
|
|
|
|
|
|
caps->dpcLineCaps.dwRasterCaps &= (
|
|
|
|
D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_ROP2 | D3DPRASTERCAPS_XOR |
|
|
|
|
D3DPRASTERCAPS_PAT | D3DPRASTERCAPS_ZTEST | D3DPRASTERCAPS_SUBPIXEL |
|
|
|
|
D3DPRASTERCAPS_SUBPIXELX | D3DPRASTERCAPS_FOGVERTEX | D3DPRASTERCAPS_FOGTABLE |
|
|
|
|
D3DPRASTERCAPS_STIPPLE | D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT | D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT |
|
|
|
|
D3DPRASTERCAPS_ANTIALIASEDGES | D3DPRASTERCAPS_MIPMAPLODBIAS | D3DPRASTERCAPS_ZBIAS |
|
|
|
|
D3DPRASTERCAPS_ZBUFFERLESSHSR | D3DPRASTERCAPS_FOGRANGE | D3DPRASTERCAPS_ANISOTROPY |
|
|
|
|
D3DPRASTERCAPS_WBUFFER | D3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT | D3DPRASTERCAPS_WFOG |
|
|
|
|
D3DPRASTERCAPS_ZFOG);
|
|
|
|
|
|
|
|
caps->dpcLineCaps.dwZCmpCaps &= (
|
|
|
|
D3DPCMPCAPS_NEVER | D3DPCMPCAPS_LESS | D3DPCMPCAPS_EQUAL |
|
|
|
|
D3DPCMPCAPS_LESSEQUAL | D3DPCMPCAPS_GREATER | D3DPCMPCAPS_NOTEQUAL |
|
|
|
|
D3DPCMPCAPS_GREATEREQUAL | D3DPCMPCAPS_ALWAYS);
|
|
|
|
|
|
|
|
caps->dpcLineCaps.dwSrcBlendCaps &= (
|
|
|
|
D3DPBLENDCAPS_ZERO | D3DPBLENDCAPS_ONE | D3DPBLENDCAPS_SRCCOLOR |
|
|
|
|
D3DPBLENDCAPS_INVSRCCOLOR | D3DPBLENDCAPS_SRCALPHA | D3DPBLENDCAPS_INVSRCALPHA |
|
|
|
|
D3DPBLENDCAPS_DESTALPHA | D3DPBLENDCAPS_INVDESTALPHA | D3DPBLENDCAPS_DESTCOLOR |
|
|
|
|
D3DPBLENDCAPS_INVDESTCOLOR | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA |
|
|
|
|
D3DPBLENDCAPS_BOTHINVSRCALPHA);
|
|
|
|
|
|
|
|
caps->dpcLineCaps.dwDestBlendCaps &= (
|
|
|
|
D3DPBLENDCAPS_ZERO | D3DPBLENDCAPS_ONE | D3DPBLENDCAPS_SRCCOLOR |
|
|
|
|
D3DPBLENDCAPS_INVSRCCOLOR | D3DPBLENDCAPS_SRCALPHA | D3DPBLENDCAPS_INVSRCALPHA |
|
|
|
|
D3DPBLENDCAPS_DESTALPHA | D3DPBLENDCAPS_INVDESTALPHA | D3DPBLENDCAPS_DESTCOLOR |
|
|
|
|
D3DPBLENDCAPS_INVDESTCOLOR | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA |
|
|
|
|
D3DPBLENDCAPS_BOTHINVSRCALPHA);
|
|
|
|
|
|
|
|
caps->dpcLineCaps.dwAlphaCmpCaps &= (
|
|
|
|
D3DPCMPCAPS_NEVER | D3DPCMPCAPS_LESS | D3DPCMPCAPS_EQUAL |
|
|
|
|
D3DPCMPCAPS_LESSEQUAL | D3DPCMPCAPS_GREATER | D3DPCMPCAPS_NOTEQUAL |
|
|
|
|
D3DPCMPCAPS_GREATEREQUAL | D3DPCMPCAPS_ALWAYS);
|
|
|
|
|
|
|
|
caps->dpcLineCaps.dwShadeCaps &= (
|
|
|
|
D3DPSHADECAPS_COLORFLATMONO | D3DPSHADECAPS_COLORFLATRGB | D3DPSHADECAPS_COLORGOURAUDMONO |
|
|
|
|
D3DPSHADECAPS_COLORGOURAUDRGB | D3DPSHADECAPS_COLORPHONGMONO | D3DPSHADECAPS_COLORPHONGRGB |
|
|
|
|
D3DPSHADECAPS_SPECULARFLATMONO | D3DPSHADECAPS_SPECULARFLATRGB | D3DPSHADECAPS_SPECULARGOURAUDMONO |
|
|
|
|
D3DPSHADECAPS_SPECULARGOURAUDRGB | D3DPSHADECAPS_SPECULARPHONGMONO | D3DPSHADECAPS_SPECULARPHONGRGB |
|
|
|
|
D3DPSHADECAPS_ALPHAFLATBLEND | D3DPSHADECAPS_ALPHAFLATSTIPPLED | D3DPSHADECAPS_ALPHAGOURAUDBLEND |
|
|
|
|
D3DPSHADECAPS_ALPHAGOURAUDSTIPPLED | D3DPSHADECAPS_ALPHAPHONGBLEND | D3DPSHADECAPS_ALPHAPHONGSTIPPLED |
|
|
|
|
D3DPSHADECAPS_FOGFLAT | D3DPSHADECAPS_FOGGOURAUD | D3DPSHADECAPS_FOGPHONG);
|
|
|
|
|
|
|
|
caps->dpcLineCaps.dwTextureCaps &= (
|
|
|
|
D3DPTEXTURECAPS_PERSPECTIVE | D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_ALPHA |
|
|
|
|
D3DPTEXTURECAPS_TRANSPARENCY | D3DPTEXTURECAPS_BORDER | D3DPTEXTURECAPS_SQUAREONLY |
|
|
|
|
D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE | D3DPTEXTURECAPS_ALPHAPALETTE| D3DPTEXTURECAPS_NONPOW2CONDITIONAL |
|
|
|
|
D3DPTEXTURECAPS_PROJECTED | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_COLORKEYBLEND);
|
|
|
|
|
|
|
|
caps->dpcLineCaps.dwTextureFilterCaps &= (
|
|
|
|
D3DPTFILTERCAPS_NEAREST | D3DPTFILTERCAPS_LINEAR | D3DPTFILTERCAPS_MIPNEAREST |
|
|
|
|
D3DPTFILTERCAPS_MIPLINEAR | D3DPTFILTERCAPS_LINEARMIPNEAREST | D3DPTFILTERCAPS_LINEARMIPLINEAR |
|
|
|
|
D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR | D3DPTFILTERCAPS_MINFANISOTROPIC |
|
|
|
|
D3DPTFILTERCAPS_MIPFPOINT | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT |
|
|
|
|
D3DPTFILTERCAPS_MAGFLINEAR | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFAFLATCUBIC |
|
|
|
|
D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC);
|
|
|
|
|
|
|
|
caps->dpcLineCaps.dwTextureAddressCaps &= (
|
|
|
|
D3DPTADDRESSCAPS_WRAP | D3DPTADDRESSCAPS_MIRROR | D3DPTADDRESSCAPS_CLAMP |
|
|
|
|
D3DPTADDRESSCAPS_BORDER | D3DPTADDRESSCAPS_INDEPENDENTUV);
|
|
|
|
|
|
|
|
if (!(caps->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2))
|
|
|
|
{
|
|
|
|
/* DirectX7 always has the np2 flag set, no matter what the card
|
|
|
|
* supports. Some old games (Rollcage) check the caps incorrectly.
|
|
|
|
* If wined3d supports nonpow2 textures it also has np2 conditional
|
|
|
|
* support. */
|
|
|
|
caps->dpcLineCaps.dwTextureCaps |= D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill the missing members, and do some fixup */
|
|
|
|
caps->dpcLineCaps.dwSize = sizeof(caps->dpcLineCaps);
|
|
|
|
caps->dpcLineCaps.dwTextureBlendCaps = D3DPTBLENDCAPS_ADD
|
|
|
|
| D3DPTBLENDCAPS_MODULATEMASK
|
|
|
|
| D3DPTBLENDCAPS_COPY
|
|
|
|
| D3DPTBLENDCAPS_DECAL
|
|
|
|
| D3DPTBLENDCAPS_DECALALPHA
|
|
|
|
| D3DPTBLENDCAPS_DECALMASK
|
|
|
|
| D3DPTBLENDCAPS_MODULATE
|
|
|
|
| D3DPTBLENDCAPS_MODULATEALPHA;
|
|
|
|
caps->dpcLineCaps.dwStippleWidth = 32;
|
|
|
|
caps->dpcLineCaps.dwStippleHeight = 32;
|
|
|
|
/* Use the same for the TriCaps */
|
|
|
|
caps->dpcTriCaps = caps->dpcLineCaps;
|
|
|
|
|
|
|
|
caps->dwDeviceRenderBitDepth = DDBD_16 | DDBD_24 | DDBD_32;
|
|
|
|
caps->dwDeviceZBufferBitDepth = DDBD_16 | DDBD_24;
|
|
|
|
caps->dwMinTextureWidth = 1;
|
|
|
|
caps->dwMinTextureHeight = 1;
|
|
|
|
|
|
|
|
/* Convert DWORDs safely to WORDs */
|
|
|
|
if (wined3d_caps.MaxTextureBlendStages > 0xffff)
|
|
|
|
caps->wMaxTextureBlendStages = 0xffff;
|
|
|
|
else
|
|
|
|
caps->wMaxTextureBlendStages = (WORD)wined3d_caps.MaxTextureBlendStages;
|
|
|
|
if (wined3d_caps.MaxSimultaneousTextures > 0xffff)
|
|
|
|
caps->wMaxSimultaneousTextures = 0xffff;
|
|
|
|
else
|
|
|
|
caps->wMaxSimultaneousTextures = (WORD)wined3d_caps.MaxSimultaneousTextures;
|
|
|
|
|
|
|
|
if (wined3d_caps.MaxUserClipPlanes > 0xffff)
|
|
|
|
caps->wMaxUserClipPlanes = 0xffff;
|
|
|
|
else
|
|
|
|
caps->wMaxUserClipPlanes = (WORD)wined3d_caps.MaxUserClipPlanes;
|
|
|
|
if (wined3d_caps.MaxVertexBlendMatrices > 0xffff)
|
|
|
|
caps->wMaxVertexBlendMatrices = 0xffff;
|
|
|
|
else
|
|
|
|
caps->wMaxVertexBlendMatrices = (WORD)wined3d_caps.MaxVertexBlendMatrices;
|
|
|
|
|
|
|
|
caps->deviceGUID = IID_IDirect3DTnLHalDevice;
|
|
|
|
|
|
|
|
caps->dwReserved1 = 0;
|
|
|
|
caps->dwReserved2 = 0;
|
|
|
|
caps->dwReserved3 = 0;
|
|
|
|
caps->dwReserved4 = 0;
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::GetCaps
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Returns the drives capabilities
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Used for version 1, 2, 4 and 7
|
|
|
|
*
|
|
|
|
* Params:
|
2006-06-23 18:18:02 +02:00
|
|
|
* DriverCaps: Structure to write the Hardware accelerated caps to
|
2006-06-09 19:36:12 +02:00
|
|
|
* HelCaps: Structure to write the emulation caps to
|
|
|
|
*
|
|
|
|
* Returns
|
2006-06-23 18:18:02 +02:00
|
|
|
* This implementation returns DD_OK only
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DDCAPS *HELCaps)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2008-07-29 18:03:59 +02:00
|
|
|
DDCAPS caps;
|
|
|
|
WINED3DCAPS winecaps;
|
|
|
|
HRESULT hr;
|
2015-02-28 09:22:59 +01:00
|
|
|
DDSCAPS2 ddscaps = {0, 0, 0, {0}};
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, driver_caps %p, hel_caps %p.\n", iface, DriverCaps, HELCaps);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* One structure must be != NULL */
|
2012-03-08 20:27:16 +01:00
|
|
|
if (!DriverCaps && !HELCaps)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
WARN("Invalid parameters.\n");
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2008-07-29 18:03:59 +02:00
|
|
|
memset(&caps, 0, sizeof(caps));
|
|
|
|
memset(&winecaps, 0, sizeof(winecaps));
|
|
|
|
caps.dwSize = sizeof(caps);
|
2011-11-13 19:52:24 +01:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = wined3d_device_get_device_caps(ddraw->wined3d_device, &winecaps);
|
2011-05-16 23:01:22 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2017-02-25 07:10:15 +01:00
|
|
|
WARN("Failed to get device caps, %#x.\n", hr);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2008-07-29 18:03:59 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirectDraw7_GetAvailableVidMem(iface, &ddscaps, &caps.dwVidMemTotal, &caps.dwVidMemFree);
|
2013-11-14 19:39:05 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2008-07-29 18:03:59 +02:00
|
|
|
WARN("IDirectDraw7::GetAvailableVidMem failed\n");
|
2013-11-14 19:39:05 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirectDraw7_GetFourCCCodes(iface, &caps.dwNumFourCCCodes, NULL);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("IDirectDraw7::GetFourCCCodes failed\n");
|
2008-07-29 18:03:59 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-12-12 20:53:58 +01:00
|
|
|
caps.dwCaps = winecaps.ddraw_caps.caps;
|
|
|
|
caps.dwCaps2 = winecaps.ddraw_caps.caps2;
|
|
|
|
caps.dwCKeyCaps = winecaps.ddraw_caps.color_key_caps;
|
|
|
|
caps.dwFXCaps = winecaps.ddraw_caps.fx_caps;
|
2013-12-13 09:07:47 +01:00
|
|
|
caps.dwPalCaps = DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE;
|
2011-12-12 20:53:58 +01:00
|
|
|
caps.ddsCaps.dwCaps = winecaps.ddraw_caps.dds_caps;
|
|
|
|
caps.dwSVBCaps = winecaps.ddraw_caps.svb_caps;
|
|
|
|
caps.dwSVBCKeyCaps = winecaps.ddraw_caps.svb_color_key_caps;
|
|
|
|
caps.dwSVBFXCaps = winecaps.ddraw_caps.svb_fx_caps;
|
|
|
|
caps.dwVSBCaps = winecaps.ddraw_caps.vsb_caps;
|
|
|
|
caps.dwVSBCKeyCaps = winecaps.ddraw_caps.vsb_color_key_caps;
|
|
|
|
caps.dwVSBFXCaps = winecaps.ddraw_caps.vsb_fx_caps;
|
|
|
|
caps.dwSSBCaps = winecaps.ddraw_caps.ssb_caps;
|
|
|
|
caps.dwSSBCKeyCaps = winecaps.ddraw_caps.ssb_color_key_caps;
|
|
|
|
caps.dwSSBFXCaps = winecaps.ddraw_caps.ssb_fx_caps;
|
2008-07-29 18:03:59 +02:00
|
|
|
|
2013-08-29 10:26:24 +02:00
|
|
|
caps.dwCaps |= DDCAPS_ALIGNSTRIDE;
|
|
|
|
caps.dwAlignStrideAlign = DDRAW_STRIDE_ALIGNMENT;
|
2008-07-29 18:03:59 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
if(DriverCaps)
|
|
|
|
{
|
2008-07-29 18:03:59 +02:00
|
|
|
DD_STRUCT_COPY_BYSIZE(DriverCaps, &caps);
|
2006-06-09 19:36:12 +02:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
|
|
|
TRACE("Driver Caps :\n");
|
|
|
|
DDRAW_dump_DDCAPS(DriverCaps);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if(HELCaps)
|
|
|
|
{
|
2008-07-29 18:03:59 +02:00
|
|
|
DD_STRUCT_COPY_BYSIZE(HELCaps, &caps);
|
2006-06-09 19:36:12 +02:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
|
|
|
TRACE("HEL Caps :\n");
|
|
|
|
DDRAW_dump_DDCAPS(HELCaps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_GetCaps(IDirectDraw4 *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetCaps(&ddraw->IDirectDraw7_iface, driver_caps, hel_caps);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_GetCaps(IDirectDraw2 *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetCaps(&ddraw->IDirectDraw7_iface, driver_caps, hel_caps);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_GetCaps(IDirectDraw *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetCaps(&ddraw->IDirectDraw7_iface, driver_caps, hel_caps);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::Compact
|
|
|
|
*
|
|
|
|
* No idea what it does, MSDN says it's not implemented.
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* DD_OK, but this is unchecked
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_Compact(IDirectDraw7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_Compact(IDirectDraw4 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_Compact(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_Compact(IDirectDraw2 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_Compact(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_Compact(IDirectDraw *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_Compact(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::GetDisplayMode
|
|
|
|
*
|
|
|
|
* Returns information about the current display mode
|
|
|
|
*
|
2016-04-20 08:56:24 +02:00
|
|
|
* Exists in versions 1, 2, 4 and 7
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DDSD: Address of a surface description structure to write the info to
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* DD_OK
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_GetDisplayMode(IDirectDraw7 *iface, DDSURFACEDESC2 *DDSD)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2011-11-16 20:08:06 +01:00
|
|
|
struct wined3d_display_mode mode;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
|
|
|
DWORD Size;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, DDSD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2006-06-09 19:36:12 +02:00
|
|
|
/* This seems sane */
|
2009-09-01 09:09:37 +02:00
|
|
|
if (!DDSD)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2012-06-27 19:02:28 +02:00
|
|
|
if (FAILED(hr = wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode, NULL)))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
ERR("Failed to get display mode, hr %#x.\n", hr);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
Size = DDSD->dwSize;
|
|
|
|
memset(DDSD, 0, Size);
|
|
|
|
|
|
|
|
DDSD->dwSize = Size;
|
|
|
|
DDSD->dwFlags |= DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_PITCH | DDSD_REFRESHRATE;
|
2011-11-16 20:08:06 +01:00
|
|
|
DDSD->dwWidth = mode.width;
|
|
|
|
DDSD->dwHeight = mode.height;
|
2006-06-09 19:36:12 +02:00
|
|
|
DDSD->u2.dwRefreshRate = 60;
|
|
|
|
DDSD->ddsCaps.dwCaps = 0;
|
|
|
|
DDSD->u4.ddpfPixelFormat.dwSize = sizeof(DDSD->u4.ddpfPixelFormat);
|
2013-06-07 10:17:55 +02:00
|
|
|
ddrawformat_from_wined3dformat(&DDSD->u4.ddpfPixelFormat, mode.format_id);
|
2011-11-16 20:08:06 +01:00
|
|
|
DDSD->u1.lPitch = mode.width * DDSD->u4.ddpfPixelFormat.u1.dwRGBBitCount / 8;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(TRACE_ON(ddraw))
|
|
|
|
{
|
|
|
|
TRACE("Returning surface desc :\n");
|
|
|
|
DDRAW_dump_surface_desc(DDSD);
|
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_GetDisplayMode(IDirectDraw4 *iface, DDSURFACEDESC2 *surface_desc)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetDisplayMode(&ddraw->IDirectDraw7_iface, surface_desc);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_GetDisplayMode(IDirectDraw2 *iface, DDSURFACEDESC *surface_desc)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
|
|
|
|
|
2011-08-28 15:00:59 +02:00
|
|
|
/* FIXME: Test sizes, properly convert surface_desc */
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetDisplayMode(&ddraw->IDirectDraw7_iface, (DDSURFACEDESC2 *)surface_desc);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_GetDisplayMode(IDirectDraw *iface, DDSURFACEDESC *surface_desc)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
|
|
|
|
|
2011-08-28 15:00:59 +02:00
|
|
|
/* FIXME: Test sizes, properly convert surface_desc */
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetDisplayMode(&ddraw->IDirectDraw7_iface, (DDSURFACEDESC2 *)surface_desc);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::GetFourCCCodes
|
|
|
|
*
|
|
|
|
* Returns an array of supported FourCC codes.
|
|
|
|
*
|
2016-04-20 08:56:24 +02:00
|
|
|
* Exists in versions 1, 2, 4 and 7
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* NumCodes: Contains the number of Codes that Codes can carry. Returns the number
|
|
|
|
* of enumerated codes
|
2006-06-23 18:18:02 +02:00
|
|
|
* Codes: Pointer to an array of DWORDs where the supported codes are written
|
2006-06-09 19:36:12 +02:00
|
|
|
* to
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* Always returns DD_OK, as it's a stub for now
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_GetFourCCCodes(IDirectDraw7 *iface, DWORD *NumCodes, DWORD *Codes)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2010-08-23 18:28:10 +02:00
|
|
|
static const enum wined3d_format_id formats[] =
|
2010-08-22 23:35:37 +02:00
|
|
|
{
|
2008-08-25 16:25:24 +02:00
|
|
|
WINED3DFMT_YUY2, WINED3DFMT_UYVY, WINED3DFMT_YV12,
|
2008-07-30 22:55:20 +02:00
|
|
|
WINED3DFMT_DXT1, WINED3DFMT_DXT2, WINED3DFMT_DXT3, WINED3DFMT_DXT4, WINED3DFMT_DXT5,
|
2008-08-25 16:25:24 +02:00
|
|
|
WINED3DFMT_ATI2N, WINED3DFMT_NVHU, WINED3DFMT_NVHS
|
2008-07-30 22:55:20 +02:00
|
|
|
};
|
2011-11-16 20:08:06 +01:00
|
|
|
struct wined3d_display_mode mode;
|
2008-07-30 22:55:20 +02:00
|
|
|
DWORD count = 0, i, outsize;
|
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, codes_count %p, codes %p.\n", iface, NumCodes, Codes);
|
2008-07-30 22:55:20 +02:00
|
|
|
|
2012-06-27 19:02:28 +02:00
|
|
|
if (FAILED(hr = wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode, NULL)))
|
2012-06-20 17:45:17 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to get display mode, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
2008-07-30 22:55:20 +02:00
|
|
|
|
|
|
|
outsize = NumCodes && Codes ? *NumCodes : 0;
|
|
|
|
|
2011-02-01 19:39:53 +01:00
|
|
|
for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); ++i)
|
|
|
|
{
|
2013-01-17 10:24:28 +01:00
|
|
|
if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL,
|
2016-04-18 19:06:31 +02:00
|
|
|
mode.format_id, 0, WINED3D_RTYPE_TEXTURE_2D, formats[i])))
|
2011-02-01 19:39:53 +01:00
|
|
|
{
|
|
|
|
if (count < outsize)
|
2008-07-30 22:55:20 +02:00
|
|
|
Codes[count] = formats[i];
|
2011-02-01 19:39:53 +01:00
|
|
|
++count;
|
2008-07-30 22:55:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(NumCodes) {
|
|
|
|
TRACE("Returning %u FourCC codes\n", count);
|
|
|
|
*NumCodes = count;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_GetFourCCCodes(IDirectDraw4 *iface, DWORD *codes_count, DWORD *codes)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetFourCCCodes(&ddraw->IDirectDraw7_iface, codes_count, codes);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_GetFourCCCodes(IDirectDraw2 *iface, DWORD *codes_count, DWORD *codes)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetFourCCCodes(&ddraw->IDirectDraw7_iface, codes_count, codes);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_GetFourCCCodes(IDirectDraw *iface, DWORD *codes_count, DWORD *codes)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetFourCCCodes(&ddraw->IDirectDraw7_iface, codes_count, codes);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 23:21:29 +02:00
|
|
|
static HRESULT WINAPI ddraw7_GetMonitorFrequency(IDirectDraw7 *iface, DWORD *frequency)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-07-24 23:21:29 +02:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
|
|
|
struct wined3d_display_mode mode;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, frequency %p.\n", iface, frequency);
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
|
|
|
hr = wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode, NULL);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to get display mode, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*frequency = mode.refresh_rate;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_GetMonitorFrequency(IDirectDraw4 *iface, DWORD *frequency)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, frequency %p.\n", iface, frequency);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetMonitorFrequency(&ddraw->IDirectDraw7_iface, frequency);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_GetMonitorFrequency(IDirectDraw2 *iface, DWORD *frequency)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, frequency %p.\n", iface, frequency);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetMonitorFrequency(&ddraw->IDirectDraw7_iface, frequency);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_GetMonitorFrequency(IDirectDraw *iface, DWORD *frequency)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, frequency %p.\n", iface, frequency);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetMonitorFrequency(&ddraw->IDirectDraw7_iface, frequency);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw7_GetVerticalBlankStatus(IDirectDraw7 *iface, BOOL *status)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-07-18 21:32:31 +02:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
|
|
|
struct wined3d_raster_status raster_status;
|
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, status %p.\n", iface, status);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-21 01:13:52 +02:00
|
|
|
if(!status)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-07-18 21:32:31 +02:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
hr = wined3d_get_adapter_raster_status(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &raster_status);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to get raster status, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*status = raster_status.in_vblank;
|
2011-09-13 20:02:24 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_GetVerticalBlankStatus(IDirectDraw4 *iface, BOOL *status)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, status %p.\n", iface, status);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetVerticalBlankStatus(&ddraw->IDirectDraw7_iface, status);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_GetVerticalBlankStatus(IDirectDraw2 *iface, BOOL *status)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, status %p.\n", iface, status);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetVerticalBlankStatus(&ddraw->IDirectDraw7_iface, status);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_GetVerticalBlankStatus(IDirectDraw *iface, BOOL *status)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, status %p.\n", iface, status);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetVerticalBlankStatus(&ddraw->IDirectDraw7_iface, status);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::GetAvailableVidMem
|
|
|
|
*
|
|
|
|
* Returns the total and free video memory
|
|
|
|
*
|
|
|
|
* Params:
|
2017-01-02 10:44:39 +01:00
|
|
|
* caps: Specifies the memory type asked for
|
2006-06-09 19:36:12 +02:00
|
|
|
* total: Pointer to a DWORD to be filled with the total memory
|
|
|
|
* free: Pointer to a DWORD to be filled with the free memory
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* DD_OK on success
|
2014-06-19 23:30:35 +02:00
|
|
|
* DDERR_INVALIDPARAMS if free and total are NULL
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2017-01-02 10:44:39 +01:00
|
|
|
static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *caps, DWORD *total,
|
2011-01-19 01:42:43 +01:00
|
|
|
DWORD *free)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2017-01-02 10:44:38 +01:00
|
|
|
unsigned int framebuffer_size, total_vidmem, free_vidmem;
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2017-01-02 10:44:38 +01:00
|
|
|
struct wined3d_display_mode mode;
|
2011-09-11 22:25:40 +02:00
|
|
|
HRESULT hr = DD_OK;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2017-01-02 10:44:39 +01:00
|
|
|
TRACE("iface %p, caps %p, total %p, free %p.\n", iface, caps, total, free);
|
|
|
|
|
|
|
|
if (!total && !free)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
if (TRACE_ON(ddraw))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
TRACE("Asked for memory with description: ");
|
2017-01-02 10:44:39 +01:00
|
|
|
DDRAW_dump_DDSCAPS2(caps);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Todo: System memory vs local video memory vs non-local video memory
|
2006-06-23 18:18:02 +02:00
|
|
|
* The MSDN also mentions differences between texture memory and other
|
2006-06-09 19:36:12 +02:00
|
|
|
* resources, but that's not important
|
|
|
|
*/
|
|
|
|
|
2017-01-02 10:44:38 +01:00
|
|
|
/* Some applications (e.g. 3DMark 2000) assume that the reported amount of
|
|
|
|
* video memory doesn't include the memory used by the default framebuffer.
|
|
|
|
*/
|
|
|
|
if (FAILED(hr = wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode, NULL)))
|
|
|
|
{
|
|
|
|
WARN("Failed to get display mode, hr %#x.\n", hr);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
framebuffer_size = wined3d_calculate_format_pitch(ddraw->wined3d, WINED3DADAPTER_DEFAULT,
|
|
|
|
mode.format_id, mode.width);
|
|
|
|
framebuffer_size *= mode.height;
|
|
|
|
|
2011-05-16 23:01:22 +02:00
|
|
|
if (free)
|
2017-01-02 10:44:38 +01:00
|
|
|
{
|
|
|
|
free_vidmem = wined3d_device_get_available_texture_mem(ddraw->wined3d_device);
|
|
|
|
*free = framebuffer_size > free_vidmem ? 0 : free_vidmem - framebuffer_size;
|
|
|
|
TRACE("Free video memory %#x.\n", *free);
|
|
|
|
}
|
|
|
|
|
2011-09-11 22:25:40 +02:00
|
|
|
if (total)
|
|
|
|
{
|
2011-11-23 21:14:57 +01:00
|
|
|
struct wined3d_adapter_identifier desc = {0};
|
2011-09-11 22:25:40 +02:00
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = wined3d_get_adapter_identifier(ddraw->wined3d, WINED3DADAPTER_DEFAULT, 0, &desc);
|
2017-01-02 10:44:38 +01:00
|
|
|
total_vidmem = min(UINT_MAX, desc.video_memory);
|
|
|
|
*total = framebuffer_size > total_vidmem ? 0 : total_vidmem - framebuffer_size;
|
|
|
|
TRACE("Total video memory %#x.\n", *total);
|
2011-09-11 22:25:40 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2011-09-11 22:25:40 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_GetAvailableVidMem(IDirectDraw4 *iface,
|
|
|
|
DDSCAPS2 *caps, DWORD *total, DWORD *free)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, caps %p, total %p, free %p.\n", iface, caps, total, free);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetAvailableVidMem(&ddraw->IDirectDraw7_iface, caps, total, free);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_GetAvailableVidMem(IDirectDraw2 *iface,
|
|
|
|
DDSCAPS *caps, DWORD *total, DWORD *free)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
DDSCAPS2 caps2;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p, total %p, free %p.\n", iface, caps, total, free);
|
|
|
|
|
|
|
|
DDRAW_Convert_DDSCAPS_1_To_2(caps, &caps2);
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetAvailableVidMem(&ddraw->IDirectDraw7_iface, &caps2, total, free);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::Initialize
|
|
|
|
*
|
|
|
|
* Initializes a DirectDraw interface.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* GUID: Interface identifier. Well, don't know what this is really good
|
|
|
|
* for
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* Returns DD_OK on the first call,
|
|
|
|
* DDERR_ALREADYINITIALIZED on repeated calls
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-09-18 21:05:28 +02:00
|
|
|
static HRESULT WINAPI ddraw7_Initialize(IDirectDraw7 *iface, GUID *guid)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-09-18 21:05:28 +02:00
|
|
|
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
|
|
|
|
|
2013-05-30 10:05:32 +02:00
|
|
|
if (ddraw->flags & DDRAW_INITIALIZED)
|
2011-09-18 21:05:28 +02:00
|
|
|
return DDERR_ALREADYINITIALIZED;
|
|
|
|
|
|
|
|
/* FIXME: To properly take the GUID into account we should call
|
|
|
|
* ddraw_init() here instead of in DDRAW_Create(). */
|
|
|
|
if (guid)
|
|
|
|
FIXME("Ignoring guid %s.\n", debugstr_guid(guid));
|
|
|
|
|
2013-05-30 10:05:32 +02:00
|
|
|
ddraw->flags |= DDRAW_INITIALIZED;
|
2011-09-18 21:05:28 +02:00
|
|
|
return DD_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_Initialize(IDirectDraw4 *iface, GUID *guid)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_Initialize(&ddraw->IDirectDraw7_iface, guid);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_Initialize(IDirectDraw2 *iface, GUID *guid)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_Initialize(&ddraw->IDirectDraw7_iface, guid);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_Initialize(IDirectDraw *iface, GUID *guid)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_Initialize(&ddraw->IDirectDraw7_iface, guid);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
static HRESULT WINAPI d3d1_Initialize(IDirect3D *iface, REFIID riid)
|
|
|
|
{
|
|
|
|
TRACE("iface %p, riid %s.\n", iface, debugstr_guid(riid));
|
|
|
|
|
2011-09-18 21:05:28 +02:00
|
|
|
return DDERR_ALREADYINITIALIZED;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::FlipToGDISurface
|
|
|
|
*
|
|
|
|
* "Makes the surface that the GDI writes to the primary surface"
|
|
|
|
* Looks like some windows specific thing we don't have to care about.
|
|
|
|
* According to MSDN it permits GDI dialog boxes in FULLSCREEN mode. Good to
|
|
|
|
* show error boxes ;)
|
|
|
|
* Well, just return DD_OK.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Always returns DD_OK
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_FlipToGDISurface(IDirectDraw7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_FlipToGDISurface(IDirectDraw4 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_FlipToGDISurface(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_FlipToGDISurface(IDirectDraw2 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_FlipToGDISurface(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_FlipToGDISurface(IDirectDraw *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_FlipToGDISurface(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::WaitForVerticalBlank
|
|
|
|
*
|
|
|
|
* This method allows applications to get in sync with the vertical blank
|
|
|
|
* interval.
|
|
|
|
* The wormhole demo in the DirectX 7 sdk uses this call, and it doesn't
|
|
|
|
* redraw the screen, most likely because of this stub
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* Flags: one of DDWAITVB_BLOCKBEGIN, DDWAITVB_BLOCKBEGINEVENT
|
|
|
|
* or DDWAITVB_BLOCKEND
|
|
|
|
* h: Not used, according to MSDN
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Always returns DD_OK
|
|
|
|
*
|
2009-09-01 09:09:37 +02:00
|
|
|
*****************************************************************************/
|
2010-08-19 18:57:50 +02:00
|
|
|
static HRESULT WINAPI ddraw7_WaitForVerticalBlank(IDirectDraw7 *iface, DWORD Flags, HANDLE event)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
static BOOL hide;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, event %p.\n", iface, Flags, event);
|
2008-12-31 13:15:05 +01:00
|
|
|
|
|
|
|
/* This function is called often, so print the fixme only once */
|
|
|
|
if(!hide)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, flags %#x, event %p stub!\n", iface, Flags, event);
|
2008-12-31 13:15:05 +01:00
|
|
|
hide = TRUE;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* MSDN says DDWAITVB_BLOCKBEGINEVENT is not supported */
|
|
|
|
if(Flags & DDWAITVB_BLOCKBEGINEVENT)
|
|
|
|
return DDERR_UNSUPPORTED; /* unchecked */
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_WaitForVerticalBlank(IDirectDraw4 *iface, DWORD flags, HANDLE event)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_WaitForVerticalBlank(&ddraw->IDirectDraw7_iface, flags, event);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_WaitForVerticalBlank(IDirectDraw2 *iface, DWORD flags, HANDLE event)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_WaitForVerticalBlank(&ddraw->IDirectDraw7_iface, flags, event);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_WaitForVerticalBlank(IDirectDraw *iface, DWORD flags, HANDLE event)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_WaitForVerticalBlank(&ddraw->IDirectDraw7_iface, flags, event);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw7_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2012-07-18 21:32:30 +02:00
|
|
|
struct wined3d_raster_status raster_status;
|
2012-06-21 19:35:31 +02:00
|
|
|
HRESULT hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, line %p.\n", iface, Scanline);
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2012-07-18 21:32:30 +02:00
|
|
|
hr = wined3d_get_adapter_raster_status(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &raster_status);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2012-06-21 19:35:31 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2012-07-18 21:32:30 +02:00
|
|
|
WARN("Failed to get raster status, hr %#x.\n", hr);
|
2012-06-21 19:35:31 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-07-18 21:32:30 +02:00
|
|
|
*Scanline = raster_status.scan_line;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-07-18 21:32:30 +02:00
|
|
|
if (raster_status.in_vblank)
|
2012-04-06 14:49:54 +02:00
|
|
|
return DDERR_VERTICALBLANKINPROGRESS;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_GetScanLine(IDirectDraw4 *iface, DWORD *line)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, line %p.\n", iface, line);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetScanLine(&ddraw->IDirectDraw7_iface, line);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_GetScanLine(IDirectDraw2 *iface, DWORD *line)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, line %p.\n", iface, line);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetScanLine(&ddraw->IDirectDraw7_iface, line);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_GetScanLine(IDirectDraw *iface, DWORD *line)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, line %p.\n", iface, line);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_GetScanLine(&ddraw->IDirectDraw7_iface, line);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw7_TestCooperativeLevel(IDirectDraw7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2014-06-30 11:17:03 +02:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
|
|
|
|
2009-11-18 10:45:54 +01:00
|
|
|
TRACE("iface %p.\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2015-12-04 11:30:14 +01:00
|
|
|
return ddraw->device_state == DDRAW_DEVICE_STATE_LOST ? DDERR_NOEXCLUSIVEMODE : DD_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_TestCooperativeLevel(IDirectDraw4 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_TestCooperativeLevel(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::GetGDISurface
|
|
|
|
*
|
|
|
|
* Returns the surface that GDI is treating as the primary surface.
|
|
|
|
* For Wine this is the front buffer
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* GDISurface: Address to write the surface pointer to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK if the surface was found
|
|
|
|
* DDERR_NOTFOUND if the GDI surface wasn't found
|
|
|
|
*
|
2009-09-01 09:09:37 +02:00
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_GetGDISurface(IDirectDraw7 *iface, IDirectDrawSurface7 **GDISurface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, surface %p.\n", iface, GDISurface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2011-09-15 20:01:49 +02:00
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
if (!(*GDISurface = &ddraw->primary->IDirectDrawSurface7_iface))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-09-15 20:01:49 +02:00
|
|
|
WARN("Primary not created yet.\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_NOTFOUND;
|
|
|
|
}
|
2011-09-15 20:01:49 +02:00
|
|
|
IDirectDrawSurface7_AddRef(*GDISurface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2011-09-15 20:01:49 +02:00
|
|
|
return DD_OK;
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw4_GetGDISurface(IDirectDraw4 *iface, IDirectDrawSurface4 **surface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface_impl;
|
2011-06-06 13:03:38 +02:00
|
|
|
IDirectDrawSurface7 *surface7;
|
|
|
|
HRESULT hr;
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, surface %p.\n", iface, surface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = ddraw7_GetGDISurface(&ddraw->IDirectDraw7_iface, &surface7);
|
2011-06-06 13:03:38 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*surface = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
surface_impl = impl_from_IDirectDrawSurface7(surface7);
|
2011-06-06 13:39:04 +02:00
|
|
|
*surface = &surface_impl->IDirectDrawSurface4_iface;
|
2011-06-28 01:34:23 +02:00
|
|
|
IDirectDrawSurface4_AddRef(*surface);
|
|
|
|
IDirectDrawSurface7_Release(surface7);
|
2011-06-06 13:03:38 +02:00
|
|
|
|
|
|
|
return hr;
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_GetGDISurface(IDirectDraw2 *iface, IDirectDrawSurface **surface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface_impl;
|
2010-07-19 18:36:19 +02:00
|
|
|
IDirectDrawSurface7 *surface7;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, surface %p.\n", iface, surface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = ddraw7_GetGDISurface(&ddraw->IDirectDraw7_iface, &surface7);
|
2011-06-06 12:08:56 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*surface = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
2011-06-06 12:57:55 +02:00
|
|
|
surface_impl = impl_from_IDirectDrawSurface7(surface7);
|
2011-06-09 17:29:36 +02:00
|
|
|
*surface = &surface_impl->IDirectDrawSurface_iface;
|
2011-06-20 23:15:55 +02:00
|
|
|
IDirectDrawSurface_AddRef(*surface);
|
|
|
|
IDirectDrawSurface7_Release(surface7);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_GetGDISurface(IDirectDraw *iface, IDirectDrawSurface **surface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface_impl;
|
2010-07-19 18:36:19 +02:00
|
|
|
IDirectDrawSurface7 *surface7;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, surface %p.\n", iface, surface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = ddraw7_GetGDISurface(&ddraw->IDirectDraw7_iface, &surface7);
|
2011-06-06 12:08:56 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*surface = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
2011-06-06 12:57:55 +02:00
|
|
|
surface_impl = impl_from_IDirectDrawSurface7(surface7);
|
2011-06-09 17:29:36 +02:00
|
|
|
*surface = &surface_impl->IDirectDrawSurface_iface;
|
2011-06-20 23:15:55 +02:00
|
|
|
IDirectDrawSurface_AddRef(*surface);
|
|
|
|
IDirectDrawSurface7_Release(surface7);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct displaymodescallback_context
|
|
|
|
{
|
|
|
|
LPDDENUMMODESCALLBACK func;
|
|
|
|
void *context;
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT CALLBACK EnumDisplayModesCallbackThunk(DDSURFACEDESC2 *surface_desc, void *context)
|
|
|
|
{
|
|
|
|
struct displaymodescallback_context *cbcontext = context;
|
|
|
|
DDSURFACEDESC desc;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-08-28 15:00:59 +02:00
|
|
|
DDSD2_to_DDSD(surface_desc, &desc);
|
2010-07-19 18:36:19 +02:00
|
|
|
return cbcontext->func(&desc, cbcontext->context);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::EnumDisplayModes
|
|
|
|
*
|
|
|
|
* Enumerates the supported Display modes. The modes can be filtered with
|
2006-06-23 18:18:02 +02:00
|
|
|
* the DDSD parameter.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
2011-05-08 16:54:54 +02:00
|
|
|
* Flags: can be DDEDM_REFRESHRATES and DDEDM_STANDARDVGAMODES. For old ddraw
|
|
|
|
* versions (3 and older?) this is reserved and must be 0.
|
2006-06-09 19:36:12 +02:00
|
|
|
* DDSD: Surface description to filter the modes
|
|
|
|
* Context: Pointer passed back to the callback function
|
|
|
|
* cb: Application-provided callback function
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if the callback wasn't set
|
|
|
|
*
|
2009-09-01 09:09:37 +02:00
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
|
|
|
|
DDSURFACEDESC2 *DDSD, void *Context, LPDDENUMMODESCALLBACK2 cb)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2011-11-16 20:08:06 +01:00
|
|
|
struct wined3d_display_mode *enum_modes = NULL;
|
|
|
|
struct wined3d_display_mode mode;
|
2007-04-13 16:38:10 +02:00
|
|
|
unsigned int modenum, fmt;
|
2007-02-19 15:24:00 +01:00
|
|
|
DDSURFACEDESC2 callback_sd;
|
2013-04-09 21:27:57 +02:00
|
|
|
unsigned enum_mode_count = 0, enum_mode_array_size = 16;
|
2011-05-08 16:54:54 +02:00
|
|
|
DDPIXELFORMAT pixelformat;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-23 18:28:10 +02:00
|
|
|
static const enum wined3d_format_id checkFormatList[] =
|
2007-04-13 16:38:10 +02:00
|
|
|
{
|
2009-09-25 13:31:49 +02:00
|
|
|
WINED3DFMT_B8G8R8X8_UNORM,
|
|
|
|
WINED3DFMT_B5G6R5_UNORM,
|
|
|
|
WINED3DFMT_P8_UINT,
|
2007-04-13 16:38:10 +02:00
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
|
|
|
|
iface, Flags, DDSD, Context, cb);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
if (!cb)
|
2007-05-21 01:13:52 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2013-04-09 21:27:57 +02:00
|
|
|
enum_modes = HeapAlloc(GetProcessHeap(), 0, sizeof(*enum_modes) * enum_mode_array_size);
|
|
|
|
if (!enum_modes) return DDERR_OUTOFMEMORY;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2008-05-29 00:13:00 +02:00
|
|
|
|
2011-05-08 16:54:54 +02:00
|
|
|
pixelformat.dwSize = sizeof(pixelformat);
|
2007-04-13 16:38:10 +02:00
|
|
|
for(fmt = 0; fmt < (sizeof(checkFormatList) / sizeof(checkFormatList[0])); fmt++)
|
|
|
|
{
|
|
|
|
modenum = 0;
|
2012-07-02 14:45:56 +02:00
|
|
|
while (wined3d_enum_adapter_modes(ddraw->wined3d, WINED3DADAPTER_DEFAULT, checkFormatList[fmt],
|
|
|
|
WINED3D_SCANLINE_ORDERING_UNKNOWN, modenum++, &mode) == WINED3D_OK)
|
2007-02-19 15:24:00 +01:00
|
|
|
{
|
2013-04-09 21:27:57 +02:00
|
|
|
BOOL found = FALSE;
|
|
|
|
unsigned i;
|
|
|
|
|
2013-06-07 10:17:55 +02:00
|
|
|
ddrawformat_from_wined3dformat(&pixelformat, mode.format_id);
|
2011-11-16 20:08:06 +01:00
|
|
|
if (DDSD)
|
2007-04-13 16:38:10 +02:00
|
|
|
{
|
2011-11-16 20:08:06 +01:00
|
|
|
if (DDSD->dwFlags & DDSD_WIDTH && mode.width != DDSD->dwWidth)
|
|
|
|
continue;
|
|
|
|
if (DDSD->dwFlags & DDSD_HEIGHT && mode.height != DDSD->dwHeight)
|
|
|
|
continue;
|
|
|
|
if (DDSD->dwFlags & DDSD_REFRESHRATE && mode.refresh_rate != DDSD->u2.dwRefreshRate)
|
|
|
|
continue;
|
|
|
|
if (DDSD->dwFlags & DDSD_PIXELFORMAT
|
|
|
|
&& pixelformat.u1.dwRGBBitCount != DDSD->u4.ddpfPixelFormat.u1.dwRGBBitCount)
|
|
|
|
continue;
|
2007-04-13 16:38:10 +02:00
|
|
|
}
|
|
|
|
|
2013-04-09 21:27:57 +02:00
|
|
|
/* DX docs state EnumDisplayMode should return only unique modes */
|
|
|
|
for (i = 0; i < enum_mode_count; i++)
|
2008-05-29 00:13:00 +02:00
|
|
|
{
|
2013-04-09 21:27:57 +02:00
|
|
|
if (enum_modes[i].width == mode.width && enum_modes[i].height == mode.height
|
|
|
|
&& enum_modes[i].format_id == mode.format_id
|
|
|
|
&& (enum_modes[i].refresh_rate == mode.refresh_rate || !(Flags & DDEDM_REFRESHRATES)))
|
2008-05-29 00:13:00 +02:00
|
|
|
{
|
2013-04-09 21:27:57 +02:00
|
|
|
found = TRUE;
|
|
|
|
break;
|
2008-05-29 00:13:00 +02:00
|
|
|
}
|
|
|
|
}
|
2013-04-09 21:27:57 +02:00
|
|
|
if(found) continue;
|
2008-05-29 00:13:00 +02:00
|
|
|
|
2007-04-13 16:38:10 +02:00
|
|
|
memset(&callback_sd, 0, sizeof(callback_sd));
|
|
|
|
callback_sd.dwSize = sizeof(callback_sd);
|
|
|
|
callback_sd.u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
|
2007-02-19 15:24:00 +01:00
|
|
|
|
2011-05-08 16:54:54 +02:00
|
|
|
callback_sd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH|DDSD_REFRESHRATE;
|
2011-11-16 20:08:06 +01:00
|
|
|
if (Flags & DDEDM_REFRESHRATES)
|
|
|
|
callback_sd.u2.dwRefreshRate = mode.refresh_rate;
|
2007-02-19 15:24:00 +01:00
|
|
|
|
2011-11-16 20:08:06 +01:00
|
|
|
callback_sd.dwWidth = mode.width;
|
|
|
|
callback_sd.dwHeight = mode.height;
|
2007-02-19 15:24:00 +01:00
|
|
|
|
2011-05-08 16:54:54 +02:00
|
|
|
callback_sd.u4.ddpfPixelFormat=pixelformat;
|
2007-02-19 15:24:00 +01:00
|
|
|
|
2008-01-01 21:33:32 +01:00
|
|
|
/* Calc pitch and DWORD align like MSDN says */
|
2011-11-16 20:08:06 +01:00
|
|
|
callback_sd.u1.lPitch = (callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount / 8) * mode.width;
|
2008-01-01 21:33:32 +01:00
|
|
|
callback_sd.u1.lPitch = (callback_sd.u1.lPitch + 3) & ~3;
|
|
|
|
|
|
|
|
TRACE("Enumerating %dx%dx%d @%d\n", callback_sd.dwWidth, callback_sd.dwHeight, callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount,
|
|
|
|
callback_sd.u2.dwRefreshRate);
|
2007-04-13 16:38:10 +02:00
|
|
|
|
|
|
|
if(cb(&callback_sd, Context) == DDENUMRET_CANCEL)
|
|
|
|
{
|
|
|
|
TRACE("Application asked to terminate the enumeration\n");
|
2008-05-29 00:13:00 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, enum_modes);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2007-04-13 16:38:10 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
2008-05-29 00:13:00 +02:00
|
|
|
|
2013-04-09 21:27:57 +02:00
|
|
|
if (enum_mode_count == enum_mode_array_size)
|
2008-05-29 00:13:00 +02:00
|
|
|
{
|
2013-04-09 21:27:57 +02:00
|
|
|
struct wined3d_display_mode *new_enum_modes;
|
|
|
|
|
|
|
|
enum_mode_array_size *= 2;
|
|
|
|
new_enum_modes = HeapReAlloc(GetProcessHeap(), 0, enum_modes,
|
|
|
|
sizeof(*new_enum_modes) * enum_mode_array_size);
|
|
|
|
if (!new_enum_modes)
|
2008-05-29 00:13:00 +02:00
|
|
|
{
|
2013-04-09 21:27:57 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, enum_modes);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_OUTOFMEMORY;
|
2008-05-29 00:13:00 +02:00
|
|
|
}
|
|
|
|
|
2013-04-09 21:27:57 +02:00
|
|
|
enum_modes = new_enum_modes;
|
2008-05-29 00:13:00 +02:00
|
|
|
}
|
2013-04-09 21:27:57 +02:00
|
|
|
enum_modes[enum_mode_count++] = mode;
|
2007-02-19 15:24:00 +01:00
|
|
|
}
|
|
|
|
}
|
2007-04-13 16:38:10 +02:00
|
|
|
|
2007-02-19 15:24:00 +01:00
|
|
|
TRACE("End of enumeration\n");
|
2008-05-29 00:13:00 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, enum_modes);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-02-19 15:24:00 +01:00
|
|
|
return DD_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_EnumDisplayModes(IDirectDraw4 *iface, DWORD flags,
|
|
|
|
DDSURFACEDESC2 *surface_desc, void *context, LPDDENUMMODESCALLBACK2 callback)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
|
|
|
|
iface, flags, surface_desc, context, callback);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_EnumDisplayModes(&ddraw->IDirectDraw7_iface, flags, surface_desc, context, callback);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_EnumDisplayModes(IDirectDraw2 *iface, DWORD flags,
|
|
|
|
DDSURFACEDESC *surface_desc, void *context, LPDDENUMMODESCALLBACK callback)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
struct displaymodescallback_context cbcontext;
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
|
|
|
|
iface, flags, surface_desc, context, callback);
|
|
|
|
|
|
|
|
cbcontext.func = callback;
|
|
|
|
cbcontext.context = context;
|
|
|
|
|
2011-09-03 21:06:11 +02:00
|
|
|
if (surface_desc) DDSD_to_DDSD2(surface_desc, &surface_desc2);
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_EnumDisplayModes(&ddraw->IDirectDraw7_iface, flags,
|
2011-09-03 21:06:11 +02:00
|
|
|
surface_desc ? &surface_desc2 : NULL, &cbcontext, EnumDisplayModesCallbackThunk);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_EnumDisplayModes(IDirectDraw *iface, DWORD flags,
|
|
|
|
DDSURFACEDESC *surface_desc, void *context, LPDDENUMMODESCALLBACK callback)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
struct displaymodescallback_context cbcontext;
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
|
|
|
|
iface, flags, surface_desc, context, callback);
|
|
|
|
|
|
|
|
cbcontext.func = callback;
|
|
|
|
cbcontext.context = context;
|
|
|
|
|
2011-09-03 21:06:11 +02:00
|
|
|
if (surface_desc) DDSD_to_DDSD2(surface_desc, &surface_desc2);
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_EnumDisplayModes(&ddraw->IDirectDraw7_iface, flags,
|
2011-09-03 21:06:11 +02:00
|
|
|
surface_desc ? &surface_desc2 : NULL, &cbcontext, EnumDisplayModesCallbackThunk);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::EvaluateMode
|
|
|
|
*
|
|
|
|
* Used with IDirectDraw7::StartModeTest to test video modes.
|
|
|
|
* EvaluateMode is used to pass or fail a mode, and continue with the next
|
|
|
|
* mode
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: DDEM_MODEPASSED or DDEM_MODEFAILED
|
2006-06-23 18:18:02 +02:00
|
|
|
* Timeout: Returns the amount of seconds left before the mode would have
|
2006-06-09 19:36:12 +02:00
|
|
|
* been failed automatically
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* This implementation always DD_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_EvaluateMode(IDirectDraw7 *iface, DWORD Flags, DWORD *Timeout)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, flags %#x, timeout %p stub!\n", iface, Flags, Timeout);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* When implementing this, implement it in WineD3D */
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::GetDeviceIdentifier
|
|
|
|
*
|
|
|
|
* Returns the device identifier, which gives information about the driver
|
|
|
|
* Our device identifier is defined at the beginning of this file.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DDDI: Address for the returned structure
|
|
|
|
* Flags: Can be DDGDI_GETHOSTIDENTIFIER
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* On success it returns DD_OK
|
2006-06-23 18:18:02 +02:00
|
|
|
* DDERR_INVALIDPARAMS if DDDI is NULL
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_GetDeviceIdentifier(IDirectDraw7 *iface,
|
|
|
|
DDDEVICEIDENTIFIER2 *DDDI, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2014-02-11 17:21:53 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
|
|
|
struct wined3d_adapter_identifier adapter_id;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, device_identifier %p, flags %#x.\n", iface, DDDI, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2014-02-11 17:21:53 +01:00
|
|
|
if (!DDDI)
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2014-02-11 17:21:53 +01:00
|
|
|
if (Flags & DDGDI_GETHOSTIDENTIFIER)
|
|
|
|
{
|
|
|
|
/* The DDGDI_GETHOSTIDENTIFIER returns the information about the 2D
|
|
|
|
* host adapter, if there's a secondary 3D adapter. This doesn't apply
|
|
|
|
* to any modern hardware, nor is it interesting for Wine, so ignore it.
|
|
|
|
* Size of DDDEVICEIDENTIFIER2 may be aligned to 8 bytes and thus 4
|
|
|
|
* bytes too long. So only copy the relevant part of the structure
|
|
|
|
*/
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2014-02-11 17:21:53 +01:00
|
|
|
memcpy(DDDI, &deviceidentifier, FIELD_OFFSET(DDDEVICEIDENTIFIER2, dwWHQLLevel) + sizeof(DWORD));
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Drakan: Order of the Flame expects accurate D3D device information from ddraw */
|
|
|
|
adapter_id.driver = DDDI->szDriver;
|
|
|
|
adapter_id.driver_size = sizeof(DDDI->szDriver);
|
|
|
|
adapter_id.description = DDDI->szDescription;
|
|
|
|
adapter_id.description_size = sizeof(DDDI->szDescription);
|
|
|
|
adapter_id.device_name_size = 0;
|
|
|
|
wined3d_mutex_lock();
|
|
|
|
hr = wined3d_get_adapter_identifier(ddraw->wined3d, WINED3DADAPTER_DEFAULT, 0x0, &adapter_id);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
DDDI->liDriverVersion = adapter_id.driver_version;
|
|
|
|
DDDI->dwVendorId = adapter_id.vendor_id;
|
|
|
|
DDDI->dwDeviceId = adapter_id.device_id;
|
|
|
|
DDDI->dwSubSysId = adapter_id.subsystem_id;
|
|
|
|
DDDI->dwRevision = adapter_id.revision;
|
|
|
|
DDDI->guidDeviceIdentifier = adapter_id.device_identifier;
|
|
|
|
DDDI->dwWHQLLevel = adapter_id.whql_level;
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_GetDeviceIdentifier(IDirectDraw4 *iface,
|
|
|
|
DDDEVICEIDENTIFIER *identifier, DWORD flags)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
DDDEVICEIDENTIFIER2 identifier2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, identifier %p, flags %#x.\n", iface, identifier, flags);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = ddraw7_GetDeviceIdentifier(&ddraw->IDirectDraw7_iface, &identifier2, flags);
|
2010-07-19 18:36:19 +02:00
|
|
|
DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(&identifier2, identifier);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::GetSurfaceFromDC
|
|
|
|
*
|
|
|
|
* Returns the Surface for a GDI device context handle.
|
|
|
|
* Is this related to IDirectDrawSurface::GetDC ???
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* hdc: hdc to return the surface for
|
|
|
|
* Surface: Address to write the surface pointer to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Always returns DD_OK because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2016-02-08 18:32:06 +01:00
|
|
|
static HRESULT WINAPI ddraw7_GetSurfaceFromDC(IDirectDraw7 *iface,
|
|
|
|
HDC dc, IDirectDrawSurface7 **surface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2012-04-09 20:43:38 +02:00
|
|
|
struct ddraw_surface *surface_impl;
|
2010-03-16 19:02:21 +01:00
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
TRACE("iface %p, dc %p, surface %p.\n", iface, dc, surface);
|
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
return E_INVALIDARG;
|
2010-03-16 19:02:21 +01:00
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
if (!dc)
|
|
|
|
goto done;
|
2010-03-16 19:02:21 +01:00
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
LIST_FOR_EACH_ENTRY(surface_impl, &ddraw->surface_list, struct ddraw_surface, surface_list_entry)
|
2010-03-16 19:02:21 +01:00
|
|
|
{
|
2016-02-08 18:32:06 +01:00
|
|
|
if (surface_impl->dc != dc)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
TRACE("Found surface %p for dc %p.\n", surface_impl, dc);
|
|
|
|
*surface = &surface_impl->IDirectDrawSurface7_iface;
|
|
|
|
IDirectDrawSurface7_AddRef(*surface);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DD_OK;
|
2010-03-16 19:02:21 +01:00
|
|
|
}
|
2016-02-08 18:32:06 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2016-02-08 18:32:06 +01:00
|
|
|
done:
|
|
|
|
TRACE("No surface found for dc %p.\n", dc);
|
|
|
|
*surface = NULL;
|
|
|
|
return DDERR_NOTFOUND;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-19 01:40:53 +01:00
|
|
|
static HRESULT WINAPI ddraw4_GetSurfaceFromDC(IDirectDraw4 *iface, HDC dc,
|
|
|
|
IDirectDrawSurface4 **surface)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface_impl;
|
2010-07-19 18:36:19 +02:00
|
|
|
IDirectDrawSurface7 *surface7;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, dc %p, surface %p.\n", iface, dc, surface);
|
|
|
|
|
|
|
|
if (!surface) return E_INVALIDARG;
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = ddraw7_GetSurfaceFromDC(&ddraw->IDirectDraw7_iface, dc, &surface7);
|
2011-06-06 12:08:56 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*surface = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
2011-06-06 12:57:55 +02:00
|
|
|
surface_impl = impl_from_IDirectDrawSurface7(surface7);
|
2011-06-06 12:08:56 +02:00
|
|
|
/* Tests say this is true */
|
2011-06-09 17:29:36 +02:00
|
|
|
*surface = (IDirectDrawSurface4 *)&surface_impl->IDirectDrawSurface_iface;
|
2011-06-20 23:15:55 +02:00
|
|
|
IDirectDrawSurface_AddRef(&surface_impl->IDirectDrawSurface_iface);
|
|
|
|
IDirectDrawSurface7_Release(surface7);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-06-30 11:17:04 +02:00
|
|
|
static HRESULT CALLBACK restore_callback(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *desc, void *context)
|
|
|
|
{
|
|
|
|
IDirectDrawSurface_Restore(surface);
|
|
|
|
IDirectDrawSurface_Release(surface);
|
|
|
|
|
|
|
|
return DDENUMRET_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_RestoreAllSurfaces(IDirectDraw7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2014-06-30 11:17:04 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2014-06-30 11:17:04 +02:00
|
|
|
return IDirectDraw7_EnumSurfaces(iface, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
|
|
|
|
NULL, NULL, restore_callback);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_RestoreAllSurfaces(IDirectDraw4 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_RestoreAllSurfaces(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::StartModeTest
|
|
|
|
*
|
|
|
|
* Tests the specified video modes to update the system registry with
|
|
|
|
* refresh rate information. StartModeTest starts the mode test,
|
|
|
|
* EvaluateMode is used to fail or pass a mode. If EvaluateMode
|
2006-06-23 18:18:02 +02:00
|
|
|
* isn't called within 15 seconds, the mode is failed automatically
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* As refresh rates are handled by the X server, I don't think this
|
2006-06-23 18:18:02 +02:00
|
|
|
* Method is important
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Modes: An array of mode specifications
|
|
|
|
* NumModes: The number of modes in Modes
|
|
|
|
* Flags: Some flags...
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* Returns DDERR_TESTFINISHED if flags contains DDSMT_ISTESTREQUIRED,
|
|
|
|
* if no modes are passed, DDERR_INVALIDPARAMS is returned,
|
2006-06-23 18:18:02 +02:00
|
|
|
* otherwise DD_OK
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_StartModeTest(IDirectDraw7 *iface, SIZE *Modes, DWORD NumModes, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, modes %p, mode_count %u, flags %#x partial stub!\n",
|
|
|
|
iface, Modes, NumModes, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* This looks sane */
|
|
|
|
if( (!Modes) || (NumModes == 0) ) return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
/* DDSMT_ISTESTREQUIRED asks if a mode test is necessary.
|
|
|
|
* As it is not, DDERR_TESTFINISHED is returned
|
|
|
|
* (hopefully that's correct
|
|
|
|
*
|
|
|
|
if(Flags & DDSMT_ISTESTREQUIRED) return DDERR_TESTFINISHED;
|
|
|
|
* well, that value doesn't (yet) exist in the wine headers, so ignore it
|
|
|
|
*/
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-19 01:42:43 +01:00
|
|
|
static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface, DDSURFACEDESC2 *surface_desc,
|
|
|
|
IDirectDrawSurface7 **surface, IUnknown *outer_unknown)
|
2010-09-15 21:33:02 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *impl;
|
2011-06-04 14:33:23 +02:00
|
|
|
HRESULT hr;
|
2011-01-18 12:25:50 +01:00
|
|
|
|
2010-09-15 21:33:02 +02:00
|
|
|
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
|
|
|
|
iface, surface_desc, surface, outer_unknown);
|
|
|
|
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
if (!(ddraw->cooperative_level & (DDSCL_NORMAL | DDSCL_EXCLUSIVE)))
|
2011-11-23 21:14:54 +01:00
|
|
|
{
|
|
|
|
WARN("Cooperative level not set.\n");
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOCOOPERATIVELEVELSET;
|
|
|
|
}
|
|
|
|
|
2010-09-17 07:31:26 +02:00
|
|
|
if(surface_desc == NULL || surface_desc->dwSize != sizeof(DDSURFACEDESC2))
|
|
|
|
{
|
|
|
|
WARN("Application supplied invalid surface descriptor\n");
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-09-17 07:31:26 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2017-02-16 15:12:15 +01:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
*surface = NULL;
|
|
|
|
}
|
|
|
|
__EXCEPT_PAGE_FAULT
|
|
|
|
{
|
|
|
|
WARN("Surface pointer %p is invalid.\n", surface);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
__ENDTRY;
|
|
|
|
|
2010-09-15 21:33:02 +02:00
|
|
|
if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
|
|
|
|
{
|
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
|
|
|
TRACE(" (%p) Requesting surface desc :\n", iface);
|
|
|
|
DDRAW_dump_surface_desc(surface_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Application tried to create an explicit front or back buffer\n");
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-09-15 21:33:02 +02:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
|
2013-11-28 09:55:42 +01:00
|
|
|
hr = ddraw_surface_create(ddraw, surface_desc, &impl, outer_unknown, 7);
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2017-02-16 15:12:15 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2017-01-28 23:34:06 +01:00
|
|
|
|
2017-02-16 15:12:15 +01:00
|
|
|
*surface = &impl->IDirectDrawSurface7_iface;
|
|
|
|
IDirectDraw7_AddRef(iface);
|
|
|
|
impl->ifaceToRelease = (IUnknown *)iface;
|
2011-06-04 14:33:23 +02:00
|
|
|
|
|
|
|
return hr;
|
2010-09-15 21:33:02 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
|
|
|
|
DDSURFACEDESC2 *surface_desc, IDirectDrawSurface4 **surface, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *impl;
|
2010-07-19 18:36:19 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
|
|
|
|
iface, surface_desc, surface, outer_unknown);
|
|
|
|
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
if (!(ddraw->cooperative_level & (DDSCL_NORMAL | DDSCL_EXCLUSIVE)))
|
2011-11-23 21:14:54 +01:00
|
|
|
{
|
|
|
|
WARN("Cooperative level not set.\n");
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOCOOPERATIVELEVELSET;
|
|
|
|
}
|
|
|
|
|
2010-09-17 07:31:26 +02:00
|
|
|
if(surface_desc == NULL || surface_desc->dwSize != sizeof(DDSURFACEDESC2))
|
|
|
|
{
|
|
|
|
WARN("Application supplied invalid surface descriptor\n");
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-09-17 07:31:26 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2017-02-16 15:12:15 +01:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
*surface = NULL;
|
|
|
|
}
|
|
|
|
__EXCEPT_PAGE_FAULT
|
|
|
|
{
|
|
|
|
WARN("Surface pointer %p is invalid.\n", surface);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
__ENDTRY;
|
|
|
|
|
2010-09-15 21:33:02 +02:00
|
|
|
if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
|
|
|
|
{
|
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
|
|
|
TRACE(" (%p) Requesting surface desc :\n", iface);
|
|
|
|
DDRAW_dump_surface_desc(surface_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Application tried to create an explicit front or back buffer\n");
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-09-15 21:33:02 +02:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
|
2013-11-28 09:55:42 +01:00
|
|
|
hr = ddraw_surface_create(ddraw, surface_desc, &impl, outer_unknown, 4);
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2017-02-16 15:12:15 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2017-01-28 23:34:05 +01:00
|
|
|
|
2017-02-16 15:12:15 +01:00
|
|
|
*surface = &impl->IDirectDrawSurface4_iface;
|
|
|
|
IDirectDraw4_AddRef(iface);
|
|
|
|
impl->ifaceToRelease = (IUnknown *)iface;
|
2011-06-04 14:33:23 +02:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
|
|
|
|
DDSURFACEDESC *surface_desc, IDirectDrawSurface **surface, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *impl;
|
2010-07-19 18:36:19 +02:00
|
|
|
HRESULT hr;
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
|
|
|
|
iface, surface_desc, surface, outer_unknown);
|
|
|
|
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
if (!(ddraw->cooperative_level & (DDSCL_NORMAL | DDSCL_EXCLUSIVE)))
|
2011-11-23 21:14:54 +01:00
|
|
|
{
|
|
|
|
WARN("Cooperative level not set.\n");
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOCOOPERATIVELEVELSET;
|
|
|
|
}
|
|
|
|
|
2010-09-17 07:31:26 +02:00
|
|
|
if(surface_desc == NULL || surface_desc->dwSize != sizeof(DDSURFACEDESC))
|
|
|
|
{
|
|
|
|
WARN("Application supplied invalid surface descriptor\n");
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-09-17 07:31:26 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2017-02-16 15:12:15 +01:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
*surface = NULL;
|
|
|
|
}
|
|
|
|
__EXCEPT_PAGE_FAULT
|
|
|
|
{
|
|
|
|
WARN("Surface pointer %p is invalid.\n", surface);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
__ENDTRY;
|
|
|
|
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSD_to_DDSD2(surface_desc, &surface_desc2);
|
2010-09-15 21:33:02 +02:00
|
|
|
if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
|
|
|
|
{
|
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
|
|
|
TRACE(" (%p) Requesting surface desc :\n", iface);
|
2012-12-07 00:07:06 +01:00
|
|
|
DDRAW_dump_surface_desc((DDSURFACEDESC2 *)surface_desc);
|
2010-09-15 21:33:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Application tried to create an explicit front or back buffer\n");
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-09-15 21:33:02 +02:00
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
|
2013-11-28 09:55:42 +01:00
|
|
|
hr = ddraw_surface_create(ddraw, &surface_desc2, &impl, outer_unknown, 2);
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2017-02-16 15:12:15 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2017-01-28 23:34:04 +01:00
|
|
|
|
2017-02-16 15:12:15 +01:00
|
|
|
*surface = &impl->IDirectDrawSurface_iface;
|
|
|
|
impl->ifaceToRelease = NULL;
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
|
|
|
|
DDSURFACEDESC *surface_desc, IDirectDrawSurface **surface, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *impl;
|
2010-07-19 18:36:19 +02:00
|
|
|
HRESULT hr;
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
|
|
|
|
iface, surface_desc, surface, outer_unknown);
|
|
|
|
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
if (!(ddraw->cooperative_level & (DDSCL_NORMAL | DDSCL_EXCLUSIVE)))
|
2011-11-23 21:14:54 +01:00
|
|
|
{
|
|
|
|
WARN("Cooperative level not set.\n");
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_NOCOOPERATIVELEVELSET;
|
|
|
|
}
|
|
|
|
|
2010-09-17 07:31:26 +02:00
|
|
|
if(surface_desc == NULL || surface_desc->dwSize != sizeof(DDSURFACEDESC))
|
|
|
|
{
|
|
|
|
WARN("Application supplied invalid surface descriptor\n");
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-09-17 07:31:26 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2017-02-16 15:12:15 +01:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
*surface = NULL;
|
|
|
|
}
|
|
|
|
__EXCEPT_PAGE_FAULT
|
|
|
|
{
|
|
|
|
WARN("Surface pointer %p is invalid.\n", surface);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
__ENDTRY;
|
|
|
|
|
2013-12-02 12:07:36 +01:00
|
|
|
if ((surface_desc->ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER))
|
2013-12-04 09:49:36 +01:00
|
|
|
== (DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER)
|
|
|
|
|| (surface_desc->ddsCaps.dwCaps & (DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER))
|
|
|
|
== ((DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER)))
|
2013-12-02 12:07:36 +01:00
|
|
|
{
|
|
|
|
WARN("Application tried to create an explicit front or back buffer.\n");
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DDERR_INVALIDCAPS;
|
|
|
|
}
|
|
|
|
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSD_to_DDSD2(surface_desc, &surface_desc2);
|
2013-11-28 09:55:42 +01:00
|
|
|
hr = ddraw_surface_create(ddraw, &surface_desc2, &impl, outer_unknown, 1);
|
2011-11-23 21:14:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
2017-02-16 15:12:15 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2017-01-28 23:34:03 +01:00
|
|
|
|
2017-02-16 15:12:15 +01:00
|
|
|
*surface = &impl->IDirectDrawSurface_iface;
|
|
|
|
impl->ifaceToRelease = NULL;
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
static BOOL
|
|
|
|
Main_DirectDraw_DDPIXELFORMAT_Match(const DDPIXELFORMAT *requested,
|
|
|
|
const DDPIXELFORMAT *provided)
|
|
|
|
{
|
|
|
|
/* Some flags must be present in both or neither for a match. */
|
|
|
|
static const DWORD must_match = DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2
|
|
|
|
| DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8 | DDPF_FOURCC
|
|
|
|
| DDPF_ZBUFFER | DDPF_STENCILBUFFER;
|
|
|
|
|
|
|
|
if ((requested->dwFlags & provided->dwFlags) != requested->dwFlags)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((requested->dwFlags & must_match) != (provided->dwFlags & must_match))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (requested->dwFlags & DDPF_FOURCC)
|
|
|
|
if (requested->dwFourCC != provided->dwFourCC)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_ZBUFFER|DDPF_ALPHA
|
|
|
|
|DDPF_LUMINANCE|DDPF_BUMPDUDV))
|
|
|
|
if (requested->u1.dwRGBBitCount != provided->u1.dwRGBBitCount)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_STENCILBUFFER
|
|
|
|
|DDPF_LUMINANCE|DDPF_BUMPDUDV))
|
|
|
|
if (requested->u2.dwRBitMask != provided->u2.dwRBitMask)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_ZBUFFER|DDPF_BUMPDUDV))
|
|
|
|
if (requested->u3.dwGBitMask != provided->u3.dwGBitMask)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* I could be wrong about the bumpmapping. MSDN docs are vague. */
|
|
|
|
if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_STENCILBUFFER
|
|
|
|
|DDPF_BUMPDUDV))
|
|
|
|
if (requested->u4.dwBBitMask != provided->u4.dwBBitMask)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (requested->dwFlags & (DDPF_ALPHAPIXELS|DDPF_ZPIXELS))
|
|
|
|
if (requested->u5.dwRGBAlphaBitMask != provided->u5.dwRGBAlphaBitMask)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static BOOL ddraw_match_surface_desc(const DDSURFACEDESC2 *requested, const DDSURFACEDESC2 *provided)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
struct compare_info
|
|
|
|
{
|
|
|
|
DWORD flag;
|
|
|
|
ptrdiff_t offset;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define CMP(FLAG, FIELD) \
|
|
|
|
{ DDSD_##FLAG, offsetof(DDSURFACEDESC2, FIELD), \
|
|
|
|
sizeof(((DDSURFACEDESC2 *)(NULL))->FIELD) }
|
|
|
|
|
|
|
|
static const struct compare_info compare[] =
|
|
|
|
{
|
|
|
|
CMP(ALPHABITDEPTH, dwAlphaBitDepth),
|
2015-02-28 09:22:59 +01:00
|
|
|
CMP(BACKBUFFERCOUNT, u5.dwBackBufferCount),
|
2006-06-09 19:36:12 +02:00
|
|
|
CMP(CAPS, ddsCaps),
|
|
|
|
CMP(CKDESTBLT, ddckCKDestBlt),
|
|
|
|
CMP(CKDESTOVERLAY, u3 /* ddckCKDestOverlay */),
|
|
|
|
CMP(CKSRCBLT, ddckCKSrcBlt),
|
|
|
|
CMP(CKSRCOVERLAY, ddckCKSrcOverlay),
|
|
|
|
CMP(HEIGHT, dwHeight),
|
|
|
|
CMP(LINEARSIZE, u1 /* dwLinearSize */),
|
|
|
|
CMP(LPSURFACE, lpSurface),
|
|
|
|
CMP(MIPMAPCOUNT, u2 /* dwMipMapCount */),
|
|
|
|
CMP(PITCH, u1 /* lPitch */),
|
|
|
|
/* PIXELFORMAT: manual */
|
|
|
|
CMP(REFRESHRATE, u2 /* dwRefreshRate */),
|
|
|
|
CMP(TEXTURESTAGE, dwTextureStage),
|
|
|
|
CMP(WIDTH, dwWidth),
|
|
|
|
/* ZBUFFERBITDEPTH: "obsolete" */
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef CMP
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if ((requested->dwFlags & provided->dwFlags) != requested->dwFlags)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (i=0; i < sizeof(compare)/sizeof(compare[0]); i++)
|
|
|
|
{
|
|
|
|
if (requested->dwFlags & compare[i].flag
|
|
|
|
&& memcmp((const char *)provided + compare[i].offset,
|
|
|
|
(const char *)requested + compare[i].offset,
|
|
|
|
compare[i].size) != 0)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (requested->dwFlags & DDSD_PIXELFORMAT)
|
|
|
|
{
|
|
|
|
if (!Main_DirectDraw_DDPIXELFORMAT_Match(&requested->u4.ddpfPixelFormat,
|
|
|
|
&provided->u4.ddpfPixelFormat))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-06-12 12:38:32 +02:00
|
|
|
struct surfacescallback2_context
|
|
|
|
{
|
|
|
|
LPDDENUMSURFACESCALLBACK2 func;
|
|
|
|
void *context;
|
|
|
|
};
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
struct surfacescallback_context
|
|
|
|
{
|
|
|
|
LPDDENUMSURFACESCALLBACK func;
|
|
|
|
void *context;
|
|
|
|
};
|
|
|
|
|
2011-06-12 12:38:32 +02:00
|
|
|
static HRESULT CALLBACK EnumSurfacesCallback2Thunk(IDirectDrawSurface7 *surface,
|
|
|
|
DDSURFACEDESC2 *surface_desc, void *context)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface_impl = impl_from_IDirectDrawSurface7(surface);
|
2011-06-12 12:38:32 +02:00
|
|
|
struct surfacescallback2_context *cbcontext = context;
|
|
|
|
|
2011-06-28 01:34:23 +02:00
|
|
|
IDirectDrawSurface4_AddRef(&surface_impl->IDirectDrawSurface4_iface);
|
|
|
|
IDirectDrawSurface7_Release(surface);
|
|
|
|
|
2011-06-12 12:38:32 +02:00
|
|
|
return cbcontext->func(&surface_impl->IDirectDrawSurface4_iface,
|
|
|
|
surface_desc, cbcontext->context);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT CALLBACK EnumSurfacesCallbackThunk(IDirectDrawSurface7 *surface,
|
|
|
|
DDSURFACEDESC2 *surface_desc, void *context)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface_impl = impl_from_IDirectDrawSurface7(surface);
|
2010-07-19 18:36:19 +02:00
|
|
|
struct surfacescallback_context *cbcontext = context;
|
|
|
|
|
2011-06-20 23:15:55 +02:00
|
|
|
IDirectDrawSurface_AddRef(&surface_impl->IDirectDrawSurface_iface);
|
|
|
|
IDirectDrawSurface7_Release(surface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
return cbcontext->func(&surface_impl->IDirectDrawSurface_iface,
|
2010-07-19 18:36:19 +02:00
|
|
|
(DDSURFACEDESC *)surface_desc, cbcontext->context);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::EnumSurfaces
|
|
|
|
*
|
|
|
|
* Loops through all surfaces attached to this device and calls the
|
|
|
|
* application callback. This can't be relayed to WineD3DDevice,
|
|
|
|
* because some WineD3DSurfaces' parents are IParent objects
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: Some filtering flags. See IDirectDrawImpl_EnumSurfacesCallback
|
|
|
|
* DDSD: Description to filter for
|
|
|
|
* Context: Application-provided pointer, it's passed unmodified to the
|
|
|
|
* Callback function
|
|
|
|
* Callback: Address to call for each surface
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_INVALIDPARAMS if the callback is NULL
|
|
|
|
* DD_OK on success
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags,
|
|
|
|
DDSURFACEDESC2 *DDSD, void *Context, LPDDENUMSURFACESCALLBACK7 Callback)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surf;
|
2006-06-09 19:36:12 +02:00
|
|
|
BOOL all, nomatch;
|
|
|
|
DDSURFACEDESC2 desc;
|
2006-10-14 21:57:09 +02:00
|
|
|
struct list *entry, *entry2;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
|
|
|
|
iface, Flags, DDSD, Context, Callback);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
all = Flags & DDENUMSURFACES_ALL;
|
|
|
|
nomatch = Flags & DDENUMSURFACES_NOMATCH;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
if (!Callback)
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2011-11-13 19:52:24 +01:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2006-10-14 21:57:09 +02:00
|
|
|
/* Use the _SAFE enumeration, the app may destroy enumerated surfaces */
|
2012-03-08 20:27:16 +01:00
|
|
|
LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry);
|
2011-12-05 22:06:55 +01:00
|
|
|
|
|
|
|
if (!surf->iface_count)
|
|
|
|
{
|
|
|
|
WARN("Not enumerating surface %p because it doesn't have any references.\n", surf);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc)))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-08-29 18:58:57 +02:00
|
|
|
TRACE("Enumerating surface %p.\n", surf);
|
2006-06-09 19:36:12 +02:00
|
|
|
desc = surf->surface_desc;
|
2011-06-05 18:55:04 +02:00
|
|
|
IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface);
|
|
|
|
if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) != DDENUMRET_OK)
|
2007-05-21 01:13:52 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
2007-05-21 01:13:52 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw4_EnumSurfaces(IDirectDraw4 *iface, DWORD flags,
|
|
|
|
DDSURFACEDESC2 *surface_desc, void *context, LPDDENUMSURFACESCALLBACK2 callback)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-06-12 12:38:32 +02:00
|
|
|
struct surfacescallback2_context cbcontext;
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
|
|
|
|
iface, flags, surface_desc, context, callback);
|
|
|
|
|
2011-06-12 12:38:32 +02:00
|
|
|
cbcontext.func = callback;
|
|
|
|
cbcontext.context = context;
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_EnumSurfaces(&ddraw->IDirectDraw7_iface, flags, surface_desc,
|
2011-06-12 12:38:32 +02:00
|
|
|
&cbcontext, EnumSurfacesCallback2Thunk);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_EnumSurfaces(IDirectDraw2 *iface, DWORD flags,
|
|
|
|
DDSURFACEDESC *surface_desc, void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
struct surfacescallback_context cbcontext;
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
|
|
|
|
iface, flags, surface_desc, context, callback);
|
|
|
|
|
|
|
|
cbcontext.func = callback;
|
|
|
|
cbcontext.context = context;
|
|
|
|
|
2011-09-03 21:06:11 +02:00
|
|
|
if (surface_desc) DDSD_to_DDSD2(surface_desc, &surface_desc2);
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_EnumSurfaces(&ddraw->IDirectDraw7_iface, flags,
|
2011-09-03 21:06:11 +02:00
|
|
|
surface_desc ? &surface_desc2 : NULL, &cbcontext, EnumSurfacesCallbackThunk);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_EnumSurfaces(IDirectDraw *iface, DWORD flags,
|
|
|
|
DDSURFACEDESC *surface_desc, void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
struct surfacescallback_context cbcontext;
|
2011-08-26 14:22:40 +02:00
|
|
|
DDSURFACEDESC2 surface_desc2;
|
2010-07-19 18:36:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
|
|
|
|
iface, flags, surface_desc, context, callback);
|
|
|
|
|
|
|
|
cbcontext.func = callback;
|
|
|
|
cbcontext.context = context;
|
|
|
|
|
2011-09-03 21:06:11 +02:00
|
|
|
if (surface_desc) DDSD_to_DDSD2(surface_desc, &surface_desc2);
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_EnumSurfaces(&ddraw->IDirectDraw7_iface, flags,
|
2011-09-03 21:06:11 +02:00
|
|
|
surface_desc ? &surface_desc2 : NULL, &cbcontext, EnumSurfacesCallbackThunk);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* DirectDrawCreateClipper (DDRAW.@)
|
|
|
|
*
|
|
|
|
* Creates a new IDirectDrawClipper object.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Clipper: Address to write the interface pointer to
|
|
|
|
* UnkOuter: For aggregation support, which ddraw doesn't have. Has to be
|
|
|
|
* NULL
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* CLASS_E_NOAGGREGATION if UnkOuter != NULL
|
|
|
|
* E_OUTOFMEMORY if allocating the object failed
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-12-12 20:53:55 +01:00
|
|
|
HRESULT WINAPI DirectDrawCreateClipper(DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-12-12 20:53:55 +01:00
|
|
|
struct ddraw_clipper *object;
|
2010-08-18 19:26:25 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("flags %#x, clipper %p, outer_unknown %p.\n",
|
2011-12-12 20:53:55 +01:00
|
|
|
flags, clipper, outer_unknown);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-12-12 20:53:55 +01:00
|
|
|
if (outer_unknown)
|
2007-05-21 01:13:52 +02:00
|
|
|
return CLASS_E_NOAGGREGATION;
|
2011-11-13 19:52:24 +01:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-12-12 20:53:55 +01:00
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
2007-05-21 01:13:52 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2007-05-21 01:13:52 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-18 19:26:25 +02:00
|
|
|
hr = ddraw_clipper_init(object);
|
|
|
|
if (FAILED(hr))
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2010-08-18 19:26:25 +02:00
|
|
|
WARN("Failed to initialize clipper, hr %#x.\n", hr);
|
2007-04-28 17:59:37 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-18 19:26:25 +02:00
|
|
|
return hr;
|
2007-04-28 17:59:37 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-18 19:26:25 +02:00
|
|
|
TRACE("Created clipper %p.\n", object);
|
2011-12-12 20:53:55 +01:00
|
|
|
*clipper = &object->IDirectDrawClipper_iface;
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::CreateClipper
|
|
|
|
*
|
|
|
|
* Creates a DDraw clipper. See DirectDrawCreateClipper for details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_CreateClipper(IDirectDraw7 *iface, DWORD Flags,
|
|
|
|
IDirectDrawClipper **Clipper, IUnknown *UnkOuter)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
|
|
|
|
iface, Flags, Clipper, UnkOuter);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DirectDrawCreateClipper(Flags, Clipper, UnkOuter);
|
|
|
|
}
|
|
|
|
|
2011-01-19 01:40:53 +01:00
|
|
|
static HRESULT WINAPI ddraw4_CreateClipper(IDirectDraw4 *iface, DWORD flags,
|
|
|
|
IDirectDrawClipper **clipper, IUnknown *outer_unknown)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
|
|
|
|
iface, flags, clipper, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_CreateClipper(&ddraw->IDirectDraw7_iface, flags, clipper, outer_unknown);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_CreateClipper(IDirectDraw2 *iface,
|
|
|
|
DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2011-01-19 01:36:36 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
|
|
|
|
iface, flags, clipper, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_CreateClipper(&ddraw->IDirectDraw7_iface, flags, clipper, outer_unknown);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_CreateClipper(IDirectDraw *iface,
|
|
|
|
DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2011-01-19 01:33:42 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
|
|
|
|
iface, flags, clipper, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return ddraw7_CreateClipper(&ddraw->IDirectDraw7_iface, flags, clipper, outer_unknown);
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::CreatePalette
|
|
|
|
*
|
|
|
|
* Creates a new IDirectDrawPalette object
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: The flags for the new clipper
|
|
|
|
* ColorTable: Color table to assign to the new clipper
|
|
|
|
* Palette: Address to write the interface pointer to
|
|
|
|
* UnkOuter: For aggregation support, which ddraw doesn't have. Has to be
|
|
|
|
* NULL
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* CLASS_E_NOAGGREGATION if UnkOuter != NULL
|
|
|
|
* E_OUTOFMEMORY if allocating the object failed
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
|
|
|
|
PALETTEENTRY *ColorTable, IDirectDrawPalette **Palette, IUnknown *pUnkOuter)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
2012-03-12 19:56:10 +01:00
|
|
|
struct ddraw_palette *object;
|
2010-08-19 18:57:46 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_table %p, palette %p, outer_unknown %p.\n",
|
|
|
|
iface, Flags, ColorTable, Palette, pUnkOuter);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
if (pUnkOuter)
|
2006-06-17 15:47:52 +02:00
|
|
|
return CLASS_E_NOAGGREGATION;
|
2011-11-13 19:52:24 +01:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2006-06-17 15:47:52 +02:00
|
|
|
|
|
|
|
/* The refcount test shows that a cooplevel is required for this */
|
2012-03-08 20:27:16 +01:00
|
|
|
if (!ddraw->cooperative_level)
|
2006-06-17 15:47:52 +02:00
|
|
|
{
|
|
|
|
WARN("No cooperative level set, returning DDERR_NOCOOPERATIVELEVELSET\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-17 15:47:52 +02:00
|
|
|
return DDERR_NOCOOPERATIVELEVELSET;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-03-12 19:56:10 +01:00
|
|
|
object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
|
|
|
|
if (!object)
|
2006-06-17 15:47:52 +02:00
|
|
|
{
|
|
|
|
ERR("Out of memory when allocating memory for a palette implementation\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-17 15:47:52 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = ddraw_palette_init(object, ddraw, Flags, ColorTable);
|
2010-08-19 18:57:46 +02:00
|
|
|
if (FAILED(hr))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:46 +02:00
|
|
|
WARN("Failed to initialize palette, hr %#x.\n", hr);
|
2006-06-09 19:36:12 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-08-19 18:57:46 +02:00
|
|
|
TRACE("Created palette %p.\n", object);
|
2011-10-04 00:14:27 +02:00
|
|
|
*Palette = &object->IDirectDrawPalette_iface;
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-19 01:40:53 +01:00
|
|
|
static HRESULT WINAPI ddraw4_CreatePalette(IDirectDraw4 *iface, DWORD flags, PALETTEENTRY *entries,
|
|
|
|
IDirectDrawPalette **palette, IUnknown *outer_unknown)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
|
|
|
|
iface, flags, entries, palette, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = ddraw7_CreatePalette(&ddraw->IDirectDraw7_iface, flags, entries, palette, outer_unknown);
|
2010-07-19 18:36:19 +02:00
|
|
|
if (SUCCEEDED(hr) && *palette)
|
|
|
|
{
|
2012-03-12 19:56:10 +01:00
|
|
|
struct ddraw_palette *impl = impl_from_IDirectDrawPalette(*palette);
|
2012-03-08 20:27:16 +01:00
|
|
|
IDirectDraw7_Release(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
IDirectDraw4_AddRef(iface);
|
|
|
|
impl->ifaceToRelease = (IUnknown *)iface;
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_CreatePalette(IDirectDraw2 *iface, DWORD flags,
|
|
|
|
PALETTEENTRY *entries, IDirectDrawPalette **palette, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
|
|
|
|
iface, flags, entries, palette, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = ddraw7_CreatePalette(&ddraw->IDirectDraw7_iface, flags, entries, palette, outer_unknown);
|
2010-07-19 18:36:19 +02:00
|
|
|
if (SUCCEEDED(hr) && *palette)
|
|
|
|
{
|
2012-03-12 19:56:10 +01:00
|
|
|
struct ddraw_palette *impl = impl_from_IDirectDrawPalette(*palette);
|
2012-03-08 20:27:16 +01:00
|
|
|
IDirectDraw7_Release(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
impl->ifaceToRelease = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw1_CreatePalette(IDirectDraw *iface, DWORD flags,
|
|
|
|
PALETTEENTRY *entries, IDirectDrawPalette **palette, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
|
|
|
|
iface, flags, entries, palette, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = ddraw7_CreatePalette(&ddraw->IDirectDraw7_iface, flags, entries, palette, outer_unknown);
|
2010-07-19 18:36:19 +02:00
|
|
|
if (SUCCEEDED(hr) && *palette)
|
|
|
|
{
|
2012-03-12 19:56:10 +01:00
|
|
|
struct ddraw_palette *impl = impl_from_IDirectDrawPalette(*palette);
|
2012-03-08 20:27:16 +01:00
|
|
|
IDirectDraw7_Release(&ddraw->IDirectDraw7_iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
impl->ifaceToRelease = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7::DuplicateSurface
|
|
|
|
*
|
|
|
|
* Duplicates a surface. The surface memory points to the same memory as
|
2006-06-23 18:18:02 +02:00
|
|
|
* the original surface, and it's released when the last surface referencing
|
|
|
|
* it is released. I guess that's beyond Wine's surface management right now
|
2006-06-09 19:36:12 +02:00
|
|
|
* (Idea: create a new DDraw surface with the same WineD3DSurface. I need a
|
|
|
|
* test application to implement this)
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Src: Address of the source surface
|
|
|
|
* Dest: Address to write the new surface pointer to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* See IDirectDraw7::CreateSurface
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:19 +02:00
|
|
|
static HRESULT WINAPI ddraw7_DuplicateSurface(IDirectDraw7 *iface,
|
|
|
|
IDirectDrawSurface7 *Src, IDirectDrawSurface7 **Dest)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *src_surface = unsafe_impl_from_IDirectDrawSurface7(Src);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, src %p, dst %p partial stub!\n", iface, Src, Dest);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* For now, simply create a new, independent surface */
|
2012-03-11 22:03:12 +01:00
|
|
|
return IDirectDraw7_CreateSurface(iface, &src_surface->surface_desc, Dest, NULL);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-01-19 01:40:53 +01:00
|
|
|
static HRESULT WINAPI ddraw4_DuplicateSurface(IDirectDraw4 *iface, IDirectDrawSurface4 *src,
|
|
|
|
IDirectDrawSurface4 **dst)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface4(src);
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw4(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst_impl;
|
2011-06-06 13:03:38 +02:00
|
|
|
IDirectDrawSurface7 *dst7;
|
|
|
|
HRESULT hr;
|
2011-01-19 01:40:53 +01:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
TRACE("iface %p, src %p, dst %p.\n", iface, src, dst);
|
2012-03-08 20:27:16 +01:00
|
|
|
|
|
|
|
hr = ddraw7_DuplicateSurface(&ddraw->IDirectDraw7_iface,
|
2011-06-05 18:55:04 +02:00
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, &dst7);
|
2011-06-06 13:03:38 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*dst = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
dst_impl = impl_from_IDirectDrawSurface7(dst7);
|
2011-06-06 13:39:04 +02:00
|
|
|
*dst = &dst_impl->IDirectDrawSurface4_iface;
|
2011-06-28 01:34:23 +02:00
|
|
|
IDirectDrawSurface4_AddRef(*dst);
|
|
|
|
IDirectDrawSurface7_Release(dst7);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2011-06-06 13:03:38 +02:00
|
|
|
return hr;
|
2010-07-19 18:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ddraw2_DuplicateSurface(IDirectDraw2 *iface,
|
|
|
|
IDirectDrawSurface *src, IDirectDrawSurface **dst)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface(src);
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw2(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst_impl;
|
2011-05-31 14:49:37 +02:00
|
|
|
IDirectDrawSurface7 *dst7;
|
2010-07-19 18:36:19 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, src %p, dst %p.\n", iface, src, dst);
|
2012-03-08 20:27:16 +01:00
|
|
|
|
|
|
|
hr = ddraw7_DuplicateSurface(&ddraw->IDirectDraw7_iface,
|
2011-06-05 18:55:04 +02:00
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, &dst7);
|
2010-08-15 22:27:14 +02:00
|
|
|
if (FAILED(hr))
|
2010-07-25 20:13:02 +02:00
|
|
|
return hr;
|
2011-06-06 12:57:55 +02:00
|
|
|
dst_impl = impl_from_IDirectDrawSurface7(dst7);
|
2011-06-09 17:29:36 +02:00
|
|
|
*dst = &dst_impl->IDirectDrawSurface_iface;
|
2011-06-20 23:15:55 +02:00
|
|
|
IDirectDrawSurface_AddRef(*dst);
|
|
|
|
IDirectDrawSurface7_Release(dst7);
|
2011-06-05 18:55:04 +02:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-01-19 01:33:42 +01:00
|
|
|
static HRESULT WINAPI ddraw1_DuplicateSurface(IDirectDraw *iface, IDirectDrawSurface *src,
|
|
|
|
IDirectDrawSurface **dst)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface(src);
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirectDraw(iface);
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *dst_impl;
|
2011-05-31 14:49:37 +02:00
|
|
|
IDirectDrawSurface7 *dst7;
|
2010-07-19 18:36:19 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, src %p, dst %p.\n", iface, src, dst);
|
2012-03-08 20:27:16 +01:00
|
|
|
|
|
|
|
hr = ddraw7_DuplicateSurface(&ddraw->IDirectDraw7_iface,
|
2011-06-05 18:55:04 +02:00
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, &dst7);
|
2010-08-15 22:27:14 +02:00
|
|
|
if (FAILED(hr))
|
2010-07-25 20:13:02 +02:00
|
|
|
return hr;
|
2011-06-06 12:57:55 +02:00
|
|
|
dst_impl = impl_from_IDirectDrawSurface7(dst7);
|
2011-06-09 17:29:36 +02:00
|
|
|
*dst = &dst_impl->IDirectDrawSurface_iface;
|
2011-06-20 23:15:55 +02:00
|
|
|
IDirectDrawSurface_AddRef(*dst);
|
|
|
|
IDirectDrawSurface7_Release(dst7);
|
2011-06-05 18:55:04 +02:00
|
|
|
|
2010-07-19 18:36:19 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
2010-08-17 19:03:22 +02:00
|
|
|
* IDirect3D7::EnumDevices
|
|
|
|
*
|
|
|
|
* The EnumDevices method for IDirect3D7. It enumerates all supported
|
|
|
|
* D3D7 devices. Currently the T&L, HAL and RGB devices are enumerated.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* callback: Function to call for each enumerated device
|
|
|
|
* context: Pointer to pass back to the app
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK, or the return value of the GetCaps call
|
|
|
|
*
|
2006-06-09 19:36:12 +02:00
|
|
|
*****************************************************************************/
|
2010-08-17 19:03:22 +02:00
|
|
|
static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBACK7 callback, void *context)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D7(iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
D3DDEVICEDESC7 device_desc7;
|
|
|
|
HRESULT hr;
|
2011-06-01 14:12:45 +02:00
|
|
|
size_t i;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, callback %p, context %p.\n", iface, callback, context);
|
|
|
|
|
2011-05-31 12:49:57 +02:00
|
|
|
if (!callback)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2013-09-06 09:57:41 +02:00
|
|
|
if (FAILED(hr = ddraw_get_d3dcaps(ddraw, &device_desc7)))
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-17 19:03:22 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-01 14:12:45 +02:00
|
|
|
for (i = 0; i < sizeof(device_list7)/sizeof(device_list7[0]); i++)
|
|
|
|
{
|
2011-06-01 14:13:03 +02:00
|
|
|
HRESULT ret;
|
|
|
|
|
2011-06-01 14:12:45 +02:00
|
|
|
device_desc7.deviceGUID = *device_list7[i].device_guid;
|
2011-06-01 14:13:03 +02:00
|
|
|
ret = callback(device_list7[i].interface_name, device_list7[i].device_name, &device_desc7, context);
|
|
|
|
if (ret != DDENUMRET_OK)
|
|
|
|
{
|
|
|
|
TRACE("Application cancelled the enumeration.\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2011-06-01 14:13:03 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
2011-06-01 14:12:45 +02:00
|
|
|
}
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
TRACE("End of enumeration.\n");
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3D3::EnumDevices
|
|
|
|
*
|
|
|
|
* Enumerates all supported Direct3DDevice interfaces. This is the
|
|
|
|
* implementation for Direct3D 1 to Direc3D 3, Version 7 has its own.
|
|
|
|
*
|
2016-04-20 08:56:24 +02:00
|
|
|
* Versions 1, 2 and 3
|
2010-08-17 19:03:22 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* callback: Application-provided routine to call for each enumerated device
|
|
|
|
* Context: Pointer to pass to the callback
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success,
|
|
|
|
* The result of IDirect3DImpl_GetCaps if it failed
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBACK callback, void *context)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-17 19:03:22 +02:00
|
|
|
static CHAR wined3d_description[] = "Wine D3DDevice using WineD3D and OpenGL";
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
D3DDEVICEDESC device_desc1, hal_desc, hel_desc;
|
|
|
|
D3DDEVICEDESC7 device_desc7;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* Some games (Motoracer 2 demo) have the bad idea to modify the device
|
|
|
|
* name string. Let's put the string in a sufficiently sized array in
|
|
|
|
* writable memory. */
|
|
|
|
char device_name[50];
|
|
|
|
strcpy(device_name,"Direct3D HEL");
|
|
|
|
|
|
|
|
TRACE("iface %p, callback %p, context %p.\n", iface, callback, context);
|
|
|
|
|
2011-05-31 12:49:57 +02:00
|
|
|
if (!callback)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2013-09-06 09:57:41 +02:00
|
|
|
if (FAILED(hr = ddraw_get_d3dcaps(ddraw, &device_desc7)))
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-17 19:03:22 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2013-09-06 09:57:41 +02:00
|
|
|
ddraw_d3dcaps1_from_7(&device_desc1, &device_desc7);
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
/* Do I have to enumerate the reference id? Note from old d3d7:
|
|
|
|
* "It seems that enumerating the reference IID on Direct3D 1 games
|
|
|
|
* (AvP / Motoracer2) breaks them". So do not enumerate this iid in V1
|
|
|
|
*
|
|
|
|
* There's a registry key HKLM\Software\Microsoft\Direct3D\Drivers,
|
|
|
|
* EnumReference which enables / disables enumerating the reference
|
|
|
|
* rasterizer. It's a DWORD, 0 means disabled, 2 means enabled. The
|
|
|
|
* enablerefrast.reg and disablerefrast.reg files in the DirectX 7.0 sdk
|
|
|
|
* demo directory suggest this.
|
|
|
|
*
|
|
|
|
* Some games(GTA 2) seem to use the second enumerated device, so I have
|
|
|
|
* to enumerate at least 2 devices. So enumerate the reference device to
|
|
|
|
* have 2 devices.
|
|
|
|
*
|
|
|
|
* Other games (Rollcage) tell emulation and hal device apart by certain
|
|
|
|
* flags. Rollcage expects D3DPTEXTURECAPS_POW2 to be set (yeah, it is a
|
|
|
|
* limitation flag), and it refuses all devices that have the perspective
|
|
|
|
* flag set. This way it refuses the emulation device, and HAL devices
|
|
|
|
* never have POW2 unset in d3d7 on windows. */
|
2012-03-08 20:27:16 +01:00
|
|
|
if (ddraw->d3dversion != 1)
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
|
|
|
static CHAR reference_description[] = "RGB Direct3D emulation";
|
|
|
|
|
|
|
|
TRACE("Enumerating WineD3D D3DDevice interface.\n");
|
|
|
|
hal_desc = device_desc1;
|
|
|
|
hel_desc = device_desc1;
|
|
|
|
/* The rgb device has the pow2 flag set in the hel caps, but not in the hal caps. */
|
|
|
|
hal_desc.dpcLineCaps.dwTextureCaps &= ~(D3DPTEXTURECAPS_POW2
|
|
|
|
| D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE);
|
|
|
|
hal_desc.dpcTriCaps.dwTextureCaps &= ~(D3DPTEXTURECAPS_POW2
|
|
|
|
| D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE);
|
2011-10-17 22:14:54 +02:00
|
|
|
/* RGB, RAMP and MMX devices have a HAL dcmColorModel of 0 */
|
|
|
|
hal_desc.dcmColorModel = 0;
|
2014-02-16 22:14:42 +01:00
|
|
|
/* RGB, RAMP and MMX devices cannot report HAL hardware flags */
|
|
|
|
hal_desc.dwFlags = 0;
|
2011-10-17 22:14:54 +02:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
hr = callback((GUID *)&IID_IDirect3DRGBDevice, reference_description,
|
|
|
|
device_name, &hal_desc, &hel_desc, context);
|
|
|
|
if (hr != D3DENUMRET_OK)
|
|
|
|
{
|
|
|
|
TRACE("Application cancelled the enumeration.\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-17 19:03:22 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(device_name,"Direct3D HAL");
|
|
|
|
|
|
|
|
TRACE("Enumerating HAL Direct3D device.\n");
|
|
|
|
hal_desc = device_desc1;
|
|
|
|
hel_desc = device_desc1;
|
2011-10-17 22:14:54 +02:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
/* The hal device does not have the pow2 flag set in hel, but in hal. */
|
|
|
|
hel_desc.dpcLineCaps.dwTextureCaps &= ~(D3DPTEXTURECAPS_POW2
|
|
|
|
| D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE);
|
|
|
|
hel_desc.dpcTriCaps.dwTextureCaps &= ~(D3DPTEXTURECAPS_POW2
|
|
|
|
| D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE);
|
2011-10-17 22:14:54 +02:00
|
|
|
/* HAL devices have a HEL dcmColorModel of 0 */
|
|
|
|
hel_desc.dcmColorModel = 0;
|
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
hr = callback((GUID *)&IID_IDirect3DHALDevice, wined3d_description,
|
|
|
|
device_name, &hal_desc, &hel_desc, context);
|
|
|
|
if (hr != D3DENUMRET_OK)
|
|
|
|
{
|
|
|
|
TRACE("Application cancelled the enumeration.\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-17 19:03:22 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("End of enumeration.\n");
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d2_EnumDevices(IDirect3D2 *iface, LPD3DENUMDEVICESCALLBACK callback, void *context)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D2(iface);
|
2011-01-18 12:30:17 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, callback %p, context %p.\n", iface, callback, context);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return d3d3_EnumDevices(&ddraw->IDirect3D3_iface, callback, context);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d1_EnumDevices(IDirect3D *iface, LPD3DENUMDEVICESCALLBACK callback, void *context)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D(iface);
|
2011-01-18 12:28:15 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, callback %p, context %p.\n", iface, callback, context);
|
2010-07-19 18:36:19 +02:00
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return d3d3_EnumDevices(&ddraw->IDirect3D3_iface, callback, context);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3D3::CreateLight
|
|
|
|
*
|
|
|
|
* Creates an IDirect3DLight interface. This interface is used in
|
|
|
|
* Direct3D3 or earlier for lighting. In Direct3D7 it has been replaced
|
|
|
|
* by the DIRECT3DLIGHT7 structure. Wine's Direct3DLight implementation
|
|
|
|
* uses the IDirect3DDevice7 interface with D3D7 lights.
|
|
|
|
*
|
2016-04-20 08:56:24 +02:00
|
|
|
* Versions 1, 2 and 3
|
2010-08-17 19:03:22 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* light: Address to store the new interface pointer
|
|
|
|
* outer_unknown: Basically for aggregation, but ddraw doesn't support it.
|
|
|
|
* Must be NULL
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_OUTOFMEMORY if memory allocation failed
|
|
|
|
* CLASS_E_NOAGGREGATION if outer_unknown != NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-01-19 01:30:21 +01:00
|
|
|
static HRESULT WINAPI d3d3_CreateLight(IDirect3D3 *iface, IDirect3DLight **light,
|
|
|
|
IUnknown *outer_unknown)
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
|
2012-03-13 20:31:37 +01:00
|
|
|
struct d3d_light *object;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, light %p, outer_unknown %p.\n", iface, light, outer_unknown);
|
|
|
|
|
|
|
|
if (outer_unknown) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate light memory.\n");
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
d3d_light_init(object, ddraw);
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
TRACE("Created light %p.\n", object);
|
2011-06-09 11:53:52 +02:00
|
|
|
*light = &object->IDirect3DLight_iface;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d2_CreateLight(IDirect3D2 *iface, IDirect3DLight **light, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D2(iface);
|
2011-01-18 12:30:17 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, light %p, outer_unknown %p.\n", iface, light, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return d3d3_CreateLight(&ddraw->IDirect3D3_iface, light, outer_unknown);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d1_CreateLight(IDirect3D *iface, IDirect3DLight **light, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D(iface);
|
2011-01-18 12:28:15 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, light %p, outer_unknown %p.\n", iface, light, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return d3d3_CreateLight(&ddraw->IDirect3D3_iface, light, outer_unknown);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3D3::CreateMaterial
|
|
|
|
*
|
|
|
|
* Creates an IDirect3DMaterial interface. This interface is used by Direct3D3
|
|
|
|
* and older versions. The IDirect3DMaterial implementation wraps its
|
|
|
|
* functionality to IDirect3DDevice7::SetMaterial and friends.
|
|
|
|
*
|
2016-04-20 08:56:24 +02:00
|
|
|
* Versions 1, 2 and 3
|
2010-08-17 19:03:22 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* material: Address to store the new interface's pointer to
|
|
|
|
* outer_unknown: Basically for aggregation, but ddraw doesn't support it.
|
|
|
|
* Must be NULL
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_OUTOFMEMORY if memory allocation failed
|
|
|
|
* CLASS_E_NOAGGREGATION if outer_unknown != NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-01-19 01:30:21 +01:00
|
|
|
static HRESULT WINAPI d3d3_CreateMaterial(IDirect3D3 *iface, IDirect3DMaterial3 **material,
|
|
|
|
IUnknown *outer_unknown)
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
|
2012-03-15 21:49:58 +01:00
|
|
|
struct d3d_material *object;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, material %p, outer_unknown %p.\n", iface, material, outer_unknown);
|
|
|
|
|
|
|
|
if (outer_unknown) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
object = d3d_material_create(ddraw);
|
2010-08-17 19:03:22 +02:00
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate material memory.\n");
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created material %p.\n", object);
|
2011-06-08 17:38:16 +02:00
|
|
|
*material = &object->IDirect3DMaterial3_iface;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-08 17:33:26 +02:00
|
|
|
static HRESULT WINAPI d3d2_CreateMaterial(IDirect3D2 *iface, IDirect3DMaterial2 **material,
|
|
|
|
IUnknown *outer_unknown)
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D2(iface);
|
2012-03-15 21:49:58 +01:00
|
|
|
struct d3d_material *object;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, material %p, outer_unknown %p.\n", iface, material, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
object = d3d_material_create(ddraw);
|
2011-06-08 17:33:26 +02:00
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate material memory.\n");
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2011-06-08 17:33:26 +02:00
|
|
|
TRACE("Created material %p.\n", object);
|
|
|
|
*material = &object->IDirect3DMaterial2_iface;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2011-06-08 17:33:26 +02:00
|
|
|
return D3D_OK;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
2011-06-08 17:33:26 +02:00
|
|
|
static HRESULT WINAPI d3d1_CreateMaterial(IDirect3D *iface, IDirect3DMaterial **material,
|
|
|
|
IUnknown *outer_unknown)
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D(iface);
|
2012-03-15 21:49:58 +01:00
|
|
|
struct d3d_material *object;
|
2011-01-18 12:28:15 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, material %p, outer_unknown %p.\n", iface, material, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
object = d3d_material_create(ddraw);
|
2011-06-08 17:33:26 +02:00
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate material memory.\n");
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2011-06-08 17:33:26 +02:00
|
|
|
TRACE("Created material %p.\n", object);
|
|
|
|
*material = &object->IDirect3DMaterial_iface;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2011-06-08 17:33:26 +02:00
|
|
|
return D3D_OK;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3D3::CreateViewport
|
|
|
|
*
|
|
|
|
* Creates an IDirect3DViewport interface. This interface is used
|
|
|
|
* by Direct3D and earlier versions for Viewport management. In Direct3D7
|
|
|
|
* it has been replaced by a viewport structure and
|
|
|
|
* IDirect3DDevice7::*Viewport. Wine's IDirect3DViewport implementation
|
|
|
|
* uses the IDirect3DDevice7 methods for its functionality
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Viewport: Address to store the new interface pointer
|
|
|
|
* outer_unknown: Basically for aggregation, but ddraw doesn't support it.
|
|
|
|
* Must be NULL
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_OUTOFMEMORY if memory allocation failed
|
|
|
|
* CLASS_E_NOAGGREGATION if outer_unknown != NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-01-19 01:30:21 +01:00
|
|
|
static HRESULT WINAPI d3d3_CreateViewport(IDirect3D3 *iface, IDirect3DViewport3 **viewport,
|
|
|
|
IUnknown *outer_unknown)
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
|
2012-03-14 22:04:32 +01:00
|
|
|
struct d3d_viewport *object;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, viewport %p, outer_unknown %p.\n", iface, viewport, outer_unknown);
|
|
|
|
|
|
|
|
if (outer_unknown) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate viewport memory.\n");
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
d3d_viewport_init(object, ddraw);
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
TRACE("Created viewport %p.\n", object);
|
2011-10-04 00:14:51 +02:00
|
|
|
*viewport = &object->IDirect3DViewport3_iface;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d2_CreateViewport(IDirect3D2 *iface, IDirect3DViewport2 **viewport, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D2(iface);
|
2011-01-18 12:30:17 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, viewport %p, outer_unknown %p.\n", iface, viewport, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return d3d3_CreateViewport(&ddraw->IDirect3D3_iface, (IDirect3DViewport3 **)viewport,
|
2011-01-19 01:30:21 +01:00
|
|
|
outer_unknown);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d1_CreateViewport(IDirect3D *iface, IDirect3DViewport **viewport, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D(iface);
|
2011-01-18 12:28:15 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, viewport %p, outer_unknown %p.\n", iface, viewport, outer_unknown);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return d3d3_CreateViewport(&ddraw->IDirect3D3_iface, (IDirect3DViewport3 **)viewport,
|
2011-01-19 01:30:21 +01:00
|
|
|
outer_unknown);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3D3::FindDevice
|
|
|
|
*
|
|
|
|
* This method finds a device with the requested properties and returns a
|
|
|
|
* device description
|
|
|
|
*
|
2016-04-20 08:56:24 +02:00
|
|
|
* Versions 1, 2 and 3
|
2010-08-17 19:03:22 +02:00
|
|
|
* Params:
|
|
|
|
* fds: Describes the requested device characteristics
|
|
|
|
* fdr: Returns the device description
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if no device was found
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
D3DDEVICEDESC7 desc7;
|
|
|
|
D3DDEVICEDESC desc1;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
|
|
|
|
|
|
|
|
if (!fds || !fdr) return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
if (fds->dwSize != sizeof(D3DFINDDEVICESEARCH)
|
|
|
|
|| fdr->dwSize != sizeof(D3DFINDDEVICERESULT))
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
if ((fds->dwFlags & D3DFDS_COLORMODEL)
|
|
|
|
&& fds->dcmColorModel != D3DCOLOR_RGB)
|
|
|
|
{
|
|
|
|
WARN("Trying to request a non-RGB D3D color model. Not supported.\n");
|
|
|
|
return DDERR_INVALIDPARAMS; /* No real idea what to return here :-) */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fds->dwFlags & D3DFDS_GUID)
|
|
|
|
{
|
|
|
|
TRACE("Trying to match guid %s.\n", debugstr_guid(&(fds->guid)));
|
|
|
|
if (!IsEqualGUID(&IID_D3DDEVICE_WineD3D, &fds->guid)
|
|
|
|
&& !IsEqualGUID(&IID_IDirect3DHALDevice, &fds->guid)
|
|
|
|
&& !IsEqualGUID(&IID_IDirect3DRGBDevice, &fds->guid))
|
|
|
|
{
|
|
|
|
WARN("No match for this GUID.\n");
|
|
|
|
return DDERR_NOTFOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the caps */
|
2013-09-06 09:57:41 +02:00
|
|
|
if (FAILED(hr = ddraw_get_d3dcaps(ddraw, &desc7)))
|
|
|
|
return hr;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
/* Now return our own GUID */
|
2013-09-06 09:57:41 +02:00
|
|
|
ddraw_d3dcaps1_from_7(&desc1, &desc7);
|
2010-08-17 19:03:22 +02:00
|
|
|
fdr->guid = IID_D3DDEVICE_WineD3D;
|
|
|
|
fdr->ddHwDesc = desc1;
|
|
|
|
fdr->ddSwDesc = desc1;
|
|
|
|
|
|
|
|
TRACE("Returning Wine's wined3d device with (undumped) capabilities.\n");
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d2_FindDevice(IDirect3D2 *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D2(iface);
|
2011-01-18 12:30:17 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return d3d3_FindDevice(&ddraw->IDirect3D3_iface, fds, fdr);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d1_FindDevice(IDirect3D *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D(iface);
|
2011-01-18 12:28:15 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return d3d3_FindDevice(&ddraw->IDirect3D3_iface, fds, fdr);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3D7::CreateDevice
|
|
|
|
*
|
|
|
|
* Creates an IDirect3DDevice7 interface.
|
|
|
|
*
|
2016-04-20 08:56:24 +02:00
|
|
|
* Versions 2, 3 and 7. IDirect3DDevice 1 interfaces are interfaces to
|
2010-08-17 19:03:22 +02:00
|
|
|
* DirectDraw surfaces and are created with
|
|
|
|
* IDirectDrawSurface::QueryInterface. This method uses CreateDevice to
|
|
|
|
* create the device object and QueryInterfaces for IDirect3DDevice
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* refiid: IID of the device to create
|
|
|
|
* Surface: Initial rendertarget
|
|
|
|
* Device: Address to return the interface pointer
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_OUTOFMEMORY if memory allocation failed
|
|
|
|
* DDERR_INVALIDPARAMS if a device exists already
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
|
|
|
|
IDirectDrawSurface7 *surface, IDirect3DDevice7 **device)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *target = unsafe_impl_from_IDirectDrawSurface7(surface);
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D7(iface);
|
2012-04-09 20:43:40 +02:00
|
|
|
struct d3d_device *object;
|
2010-08-17 19:03:22 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, surface %p, device %p.\n", iface, debugstr_guid(riid), surface, device);
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2013-09-17 09:22:36 +02:00
|
|
|
if (SUCCEEDED(hr = d3d_device_create(ddraw, target, (IUnknown *)surface, 7, &object, NULL)))
|
|
|
|
{
|
2012-04-03 21:15:12 +02:00
|
|
|
*device = &object->IDirect3DDevice7_iface;
|
2013-09-17 09:22:36 +02:00
|
|
|
}
|
2012-04-03 21:15:12 +02:00
|
|
|
else
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
2012-04-03 21:15:12 +02:00
|
|
|
WARN("Failed to create device, hr %#x.\n", hr);
|
|
|
|
*device = NULL;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2012-04-03 21:15:12 +02:00
|
|
|
return hr;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid,
|
|
|
|
IDirectDrawSurface4 *surface, IDirect3DDevice3 **device, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface_impl = unsafe_impl_from_IDirectDrawSurface4(surface);
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
|
2012-04-09 20:43:40 +02:00
|
|
|
struct d3d_device *device_impl;
|
2010-08-17 19:03:22 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, surface %p, device %p, outer_unknown %p.\n",
|
|
|
|
iface, debugstr_guid(riid), surface, device, outer_unknown);
|
|
|
|
|
2012-04-03 21:15:12 +02:00
|
|
|
if (outer_unknown)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2012-04-03 21:15:12 +02:00
|
|
|
wined3d_mutex_lock();
|
2013-09-17 09:22:36 +02:00
|
|
|
if (SUCCEEDED(hr = d3d_device_create(ddraw, surface_impl, (IUnknown *)surface, 3, &device_impl, NULL)))
|
|
|
|
{
|
2011-10-17 15:58:11 +02:00
|
|
|
*device = &device_impl->IDirect3DDevice3_iface;
|
2013-09-17 09:22:36 +02:00
|
|
|
}
|
2012-04-03 21:15:12 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Failed to create device, hr %#x.\n", hr);
|
|
|
|
*device = NULL;
|
2011-10-17 15:58:11 +02:00
|
|
|
}
|
2012-04-03 21:15:12 +02:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid,
|
|
|
|
IDirectDrawSurface *surface, IDirect3DDevice2 **device)
|
|
|
|
{
|
2012-03-11 22:03:12 +01:00
|
|
|
struct ddraw_surface *surface_impl = unsafe_impl_from_IDirectDrawSurface(surface);
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D2(iface);
|
2012-04-09 20:43:40 +02:00
|
|
|
struct d3d_device *device_impl;
|
2010-08-17 19:03:22 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, surface %p, device %p.\n",
|
|
|
|
iface, debugstr_guid(riid), surface, device);
|
|
|
|
|
2012-04-03 21:15:12 +02:00
|
|
|
wined3d_mutex_lock();
|
2013-09-17 09:22:36 +02:00
|
|
|
if (SUCCEEDED(hr = d3d_device_create(ddraw, surface_impl, (IUnknown *)surface, 2, &device_impl, NULL)))
|
|
|
|
{
|
2011-10-17 15:57:46 +02:00
|
|
|
*device = &device_impl->IDirect3DDevice2_iface;
|
2013-09-17 09:22:36 +02:00
|
|
|
}
|
2012-04-03 21:15:12 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Failed to create device, hr %#x.\n", hr);
|
|
|
|
*device = NULL;
|
2011-10-17 15:57:46 +02:00
|
|
|
}
|
2012-04-03 21:15:12 +02:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3D7::CreateVertexBuffer
|
|
|
|
*
|
|
|
|
* Creates a new vertex buffer object and returns a IDirect3DVertexBuffer7
|
|
|
|
* interface.
|
|
|
|
*
|
2016-04-20 08:56:24 +02:00
|
|
|
* Versions 3 and 7
|
2010-08-17 19:03:22 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* desc: Requested Vertex buffer properties
|
|
|
|
* vertex_buffer: Address to return the interface pointer at
|
|
|
|
* flags: Some flags, should be 0
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_OUTOFMEMORY if memory allocation failed
|
2014-06-19 23:30:35 +02:00
|
|
|
* DDERR_INVALIDPARAMS if desc or vertex_buffer is NULL
|
2010-08-17 19:03:22 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d7_CreateVertexBuffer(IDirect3D7 *iface, D3DVERTEXBUFFERDESC *desc,
|
|
|
|
IDirect3DVertexBuffer7 **vertex_buffer, DWORD flags)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D7(iface);
|
2012-04-11 22:52:04 +02:00
|
|
|
struct d3d_vertex_buffer *object;
|
2010-08-17 19:03:22 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, desc %p, vertex_buffer %p, flags %#x.\n",
|
|
|
|
iface, desc, vertex_buffer, flags);
|
|
|
|
|
|
|
|
if (!vertex_buffer || !desc) return DDERR_INVALIDPARAMS;
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = d3d_vertex_buffer_create(&object, ddraw, desc);
|
2011-06-15 12:36:49 +02:00
|
|
|
if (hr == D3D_OK)
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
2011-06-15 12:36:49 +02:00
|
|
|
TRACE("Created vertex buffer %p.\n", object);
|
2011-06-15 12:48:18 +02:00
|
|
|
*vertex_buffer = &object->IDirect3DVertexBuffer7_iface;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
2011-06-15 12:36:49 +02:00
|
|
|
else
|
|
|
|
WARN("Failed to create vertex buffer, hr %#x.\n", hr);
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2011-06-15 12:36:49 +02:00
|
|
|
return hr;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d3_CreateVertexBuffer(IDirect3D3 *iface, D3DVERTEXBUFFERDESC *desc,
|
|
|
|
IDirect3DVertexBuffer **vertex_buffer, DWORD flags, IUnknown *outer_unknown)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
|
2012-04-11 22:52:04 +02:00
|
|
|
struct d3d_vertex_buffer *object;
|
2010-08-17 19:03:22 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, desc %p, vertex_buffer %p, flags %#x, outer_unknown %p.\n",
|
|
|
|
iface, desc, vertex_buffer, flags, outer_unknown);
|
|
|
|
|
2011-06-15 12:38:47 +02:00
|
|
|
if (outer_unknown)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
if (!vertex_buffer || !desc)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
hr = d3d_vertex_buffer_create(&object, ddraw, desc);
|
2011-06-15 12:38:47 +02:00
|
|
|
if (hr == D3D_OK)
|
|
|
|
{
|
|
|
|
TRACE("Created vertex buffer %p.\n", object);
|
2017-02-24 19:37:26 +01:00
|
|
|
*vertex_buffer = (IDirect3DVertexBuffer *)&object->IDirect3DVertexBuffer7_iface;
|
2011-06-15 12:38:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
WARN("Failed to create vertex buffer, hr %#x.\n", hr);
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3D7::EnumZBufferFormats
|
|
|
|
*
|
|
|
|
* Enumerates all supported Z buffer pixel formats
|
|
|
|
*
|
2016-04-20 08:56:24 +02:00
|
|
|
* Versions 3 and 7
|
2010-08-17 19:03:22 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* device_iid:
|
|
|
|
* callback: callback to call for each pixel format
|
|
|
|
* context: Pointer to pass back to the callback
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if callback is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device_iid,
|
|
|
|
LPD3DENUMPIXELFORMATSCALLBACK callback, void *context)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D7(iface);
|
2011-11-16 20:08:06 +01:00
|
|
|
struct wined3d_display_mode mode;
|
2011-12-12 20:53:59 +01:00
|
|
|
enum wined3d_device_type type;
|
2010-08-17 19:03:22 +02:00
|
|
|
unsigned int i;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* Order matters. Specifically, BattleZone II (full version) expects the
|
|
|
|
* 16-bit depth formats to be listed before the 24 and 32 ones. */
|
2010-08-23 18:28:10 +02:00
|
|
|
static const enum wined3d_format_id formats[] =
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
|
|
|
WINED3DFMT_S1_UINT_D15_UNORM,
|
|
|
|
WINED3DFMT_D16_UNORM,
|
|
|
|
WINED3DFMT_X8D24_UNORM,
|
|
|
|
WINED3DFMT_S4X4_UINT_D24_UNORM,
|
|
|
|
WINED3DFMT_D24_UNORM_S8_UINT,
|
|
|
|
WINED3DFMT_D32_UNORM,
|
|
|
|
};
|
|
|
|
|
|
|
|
TRACE("iface %p, device_iid %s, callback %p, context %p.\n",
|
|
|
|
iface, debugstr_guid(device_iid), callback, context);
|
|
|
|
|
|
|
|
if (!callback) return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
if (IsEqualGUID(device_iid, &IID_IDirect3DHALDevice)
|
|
|
|
|| IsEqualGUID(device_iid, &IID_IDirect3DTnLHalDevice)
|
|
|
|
|| IsEqualGUID(device_iid, &IID_D3DDEVICE_WineD3D))
|
|
|
|
{
|
|
|
|
TRACE("Asked for HAL device.\n");
|
2011-12-12 20:53:59 +01:00
|
|
|
type = WINED3D_DEVICE_TYPE_HAL;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
else if (IsEqualGUID(device_iid, &IID_IDirect3DRGBDevice)
|
|
|
|
|| IsEqualGUID(device_iid, &IID_IDirect3DMMXDevice))
|
|
|
|
{
|
|
|
|
TRACE("Asked for SW device.\n");
|
2011-12-12 20:53:59 +01:00
|
|
|
type = WINED3D_DEVICE_TYPE_SW;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
else if (IsEqualGUID(device_iid, &IID_IDirect3DRefDevice))
|
|
|
|
{
|
|
|
|
TRACE("Asked for REF device.\n");
|
2011-12-12 20:53:59 +01:00
|
|
|
type = WINED3D_DEVICE_TYPE_REF;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
else if (IsEqualGUID(device_iid, &IID_IDirect3DNullDevice))
|
|
|
|
{
|
|
|
|
TRACE("Asked for NULLREF device.\n");
|
2011-12-12 20:53:59 +01:00
|
|
|
type = WINED3D_DEVICE_TYPE_NULLREF;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Unexpected device GUID %s.\n", debugstr_guid(device_iid));
|
2011-12-12 20:53:59 +01:00
|
|
|
type = WINED3D_DEVICE_TYPE_HAL;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2010-08-17 19:03:22 +02:00
|
|
|
/* We need an adapter format from somewhere to please wined3d and WGL.
|
|
|
|
* Use the current display mode. So far all cards offer the same depth
|
|
|
|
* stencil format for all modes, but if some do not and applications do
|
|
|
|
* not like that we'll have to find some workaround, like iterating over
|
|
|
|
* all imaginable formats and collecting all the depth stencil formats we
|
|
|
|
* can get. */
|
2012-06-27 19:02:28 +02:00
|
|
|
if (FAILED(hr = wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode, NULL)))
|
2012-06-21 19:35:33 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to get display mode, hr %#x.\n", hr);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return hr;
|
|
|
|
}
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
for (i = 0; i < (sizeof(formats) / sizeof(*formats)); ++i)
|
|
|
|
{
|
2013-01-17 10:24:28 +01:00
|
|
|
if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, WINED3DADAPTER_DEFAULT, type, mode.format_id,
|
2016-04-18 19:06:31 +02:00
|
|
|
WINED3DUSAGE_DEPTHSTENCIL, WINED3D_RTYPE_TEXTURE_2D, formats[i])))
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
|
|
|
DDPIXELFORMAT pformat;
|
|
|
|
|
|
|
|
memset(&pformat, 0, sizeof(pformat));
|
|
|
|
pformat.dwSize = sizeof(pformat);
|
2013-06-07 10:17:55 +02:00
|
|
|
ddrawformat_from_wined3dformat(&pformat, formats[i]);
|
2010-08-17 19:03:22 +02:00
|
|
|
|
|
|
|
TRACE("Enumerating wined3d format %#x.\n", formats[i]);
|
|
|
|
hr = callback(&pformat, context);
|
|
|
|
if (hr != DDENUMRET_OK)
|
|
|
|
{
|
|
|
|
TRACE("Format enumeration cancelled by application.\n");
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-17 19:03:22 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-26 13:40:04 +02:00
|
|
|
|
|
|
|
/* Historically some windows drivers used dwZBufferBitDepth=24 for WINED3DFMT_X8D24_UNORM,
|
|
|
|
* while others used dwZBufferBitDepth=32. In either case the pitch matches a 32 bits per
|
|
|
|
* pixel format, so we use dwZBufferBitDepth=32. Some games expect 24. Windows Vista and
|
|
|
|
* newer enumerate both versions, so we do the same(bug 22434) */
|
2013-01-17 10:24:28 +01:00
|
|
|
if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, WINED3DADAPTER_DEFAULT, type, mode.format_id,
|
2016-04-18 19:06:31 +02:00
|
|
|
WINED3DUSAGE_DEPTHSTENCIL, WINED3D_RTYPE_TEXTURE_2D, WINED3DFMT_X8D24_UNORM)))
|
2011-08-26 13:40:04 +02:00
|
|
|
{
|
|
|
|
DDPIXELFORMAT x8d24 =
|
|
|
|
{
|
|
|
|
sizeof(x8d24), DDPF_ZBUFFER, 0,
|
|
|
|
{24}, {0x00000000}, {0x00ffffff}, {0x00000000}
|
|
|
|
};
|
|
|
|
TRACE("Enumerating WINED3DFMT_X8D24_UNORM, dwZBufferBitDepth=24 version\n");
|
|
|
|
callback(&x8d24, context);
|
|
|
|
}
|
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("End of enumeration.\n");
|
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d3_EnumZBufferFormats(IDirect3D3 *iface, REFCLSID device_iid,
|
|
|
|
LPD3DENUMPIXELFORMATSCALLBACK callback, void *context)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
|
2011-01-19 01:30:21 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p, device_iid %s, callback %p, context %p.\n",
|
|
|
|
iface, debugstr_guid(device_iid), callback, context);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return d3d7_EnumZBufferFormats(&ddraw->IDirect3D7_iface, device_iid, callback, context);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3D7::EvictManagedTextures
|
|
|
|
*
|
|
|
|
* Removes all managed textures (=surfaces with DDSCAPS2_TEXTUREMANAGE or
|
|
|
|
* DDSCAPS2_D3DTEXTUREMANAGE caps) to be removed from video memory.
|
|
|
|
*
|
2016-04-20 08:56:24 +02:00
|
|
|
* Versions 3 and 7
|
2010-08-17 19:03:22 +02:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d7_EvictManagedTextures(IDirect3D7 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D7(iface);
|
2011-07-28 22:27:54 +02:00
|
|
|
|
2011-06-14 20:21:08 +02:00
|
|
|
TRACE("iface %p!\n", iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_lock();
|
2013-05-30 10:05:32 +02:00
|
|
|
if (ddraw->flags & DDRAW_D3D_INITIALIZED)
|
2012-03-08 20:27:16 +01:00
|
|
|
wined3d_device_evict_managed_resources(ddraw->wined3d_device);
|
2011-11-13 19:52:24 +01:00
|
|
|
wined3d_mutex_unlock();
|
2010-08-17 19:03:22 +02:00
|
|
|
|
2011-07-28 22:27:54 +02:00
|
|
|
return D3D_OK;
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d3_EvictManagedTextures(IDirect3D3 *iface)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
|
2011-01-19 01:30:21 +01:00
|
|
|
|
2010-08-17 19:03:22 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
return d3d7_EvictManagedTextures(&ddraw->IDirect3D7_iface);
|
2010-08-17 19:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDraw7 VTable
|
|
|
|
*****************************************************************************/
|
2010-08-19 18:57:48 +02:00
|
|
|
static const struct IDirectDraw7Vtbl ddraw7_vtbl =
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw7_QueryInterface,
|
|
|
|
ddraw7_AddRef,
|
|
|
|
ddraw7_Release,
|
|
|
|
/* IDirectDraw */
|
|
|
|
ddraw7_Compact,
|
|
|
|
ddraw7_CreateClipper,
|
|
|
|
ddraw7_CreatePalette,
|
|
|
|
ddraw7_CreateSurface,
|
|
|
|
ddraw7_DuplicateSurface,
|
|
|
|
ddraw7_EnumDisplayModes,
|
|
|
|
ddraw7_EnumSurfaces,
|
|
|
|
ddraw7_FlipToGDISurface,
|
|
|
|
ddraw7_GetCaps,
|
|
|
|
ddraw7_GetDisplayMode,
|
|
|
|
ddraw7_GetFourCCCodes,
|
|
|
|
ddraw7_GetGDISurface,
|
|
|
|
ddraw7_GetMonitorFrequency,
|
|
|
|
ddraw7_GetScanLine,
|
|
|
|
ddraw7_GetVerticalBlankStatus,
|
|
|
|
ddraw7_Initialize,
|
|
|
|
ddraw7_RestoreDisplayMode,
|
|
|
|
ddraw7_SetCooperativeLevel,
|
|
|
|
ddraw7_SetDisplayMode,
|
|
|
|
ddraw7_WaitForVerticalBlank,
|
|
|
|
/* IDirectDraw2 */
|
|
|
|
ddraw7_GetAvailableVidMem,
|
|
|
|
/* IDirectDraw3 */
|
|
|
|
ddraw7_GetSurfaceFromDC,
|
|
|
|
/* IDirectDraw4 */
|
|
|
|
ddraw7_RestoreAllSurfaces,
|
|
|
|
ddraw7_TestCooperativeLevel,
|
|
|
|
ddraw7_GetDeviceIdentifier,
|
|
|
|
/* IDirectDraw7 */
|
|
|
|
ddraw7_StartModeTest,
|
|
|
|
ddraw7_EvaluateMode
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:48 +02:00
|
|
|
static const struct IDirectDraw4Vtbl ddraw4_vtbl =
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw4_QueryInterface,
|
|
|
|
ddraw4_AddRef,
|
|
|
|
ddraw4_Release,
|
|
|
|
/* IDirectDraw */
|
|
|
|
ddraw4_Compact,
|
|
|
|
ddraw4_CreateClipper,
|
|
|
|
ddraw4_CreatePalette,
|
|
|
|
ddraw4_CreateSurface,
|
|
|
|
ddraw4_DuplicateSurface,
|
|
|
|
ddraw4_EnumDisplayModes,
|
|
|
|
ddraw4_EnumSurfaces,
|
|
|
|
ddraw4_FlipToGDISurface,
|
|
|
|
ddraw4_GetCaps,
|
|
|
|
ddraw4_GetDisplayMode,
|
|
|
|
ddraw4_GetFourCCCodes,
|
|
|
|
ddraw4_GetGDISurface,
|
|
|
|
ddraw4_GetMonitorFrequency,
|
|
|
|
ddraw4_GetScanLine,
|
|
|
|
ddraw4_GetVerticalBlankStatus,
|
|
|
|
ddraw4_Initialize,
|
|
|
|
ddraw4_RestoreDisplayMode,
|
|
|
|
ddraw4_SetCooperativeLevel,
|
|
|
|
ddraw4_SetDisplayMode,
|
|
|
|
ddraw4_WaitForVerticalBlank,
|
|
|
|
/* IDirectDraw2 */
|
|
|
|
ddraw4_GetAvailableVidMem,
|
|
|
|
/* IDirectDraw3 */
|
|
|
|
ddraw4_GetSurfaceFromDC,
|
|
|
|
/* IDirectDraw4 */
|
|
|
|
ddraw4_RestoreAllSurfaces,
|
|
|
|
ddraw4_TestCooperativeLevel,
|
|
|
|
ddraw4_GetDeviceIdentifier,
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:48 +02:00
|
|
|
static const struct IDirectDraw2Vtbl ddraw2_vtbl =
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw2_QueryInterface,
|
|
|
|
ddraw2_AddRef,
|
|
|
|
ddraw2_Release,
|
|
|
|
/* IDirectDraw */
|
|
|
|
ddraw2_Compact,
|
|
|
|
ddraw2_CreateClipper,
|
|
|
|
ddraw2_CreatePalette,
|
|
|
|
ddraw2_CreateSurface,
|
|
|
|
ddraw2_DuplicateSurface,
|
|
|
|
ddraw2_EnumDisplayModes,
|
|
|
|
ddraw2_EnumSurfaces,
|
|
|
|
ddraw2_FlipToGDISurface,
|
2010-07-19 18:36:19 +02:00
|
|
|
ddraw2_GetCaps,
|
|
|
|
ddraw2_GetDisplayMode,
|
|
|
|
ddraw2_GetFourCCCodes,
|
|
|
|
ddraw2_GetGDISurface,
|
|
|
|
ddraw2_GetMonitorFrequency,
|
|
|
|
ddraw2_GetScanLine,
|
|
|
|
ddraw2_GetVerticalBlankStatus,
|
|
|
|
ddraw2_Initialize,
|
|
|
|
ddraw2_RestoreDisplayMode,
|
|
|
|
ddraw2_SetCooperativeLevel,
|
|
|
|
ddraw2_SetDisplayMode,
|
|
|
|
ddraw2_WaitForVerticalBlank,
|
|
|
|
/* IDirectDraw2 */
|
|
|
|
ddraw2_GetAvailableVidMem,
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:48 +02:00
|
|
|
static const struct IDirectDrawVtbl ddraw1_vtbl =
|
2010-07-19 18:36:19 +02:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw1_QueryInterface,
|
|
|
|
ddraw1_AddRef,
|
|
|
|
ddraw1_Release,
|
|
|
|
/* IDirectDraw */
|
|
|
|
ddraw1_Compact,
|
|
|
|
ddraw1_CreateClipper,
|
|
|
|
ddraw1_CreatePalette,
|
|
|
|
ddraw1_CreateSurface,
|
|
|
|
ddraw1_DuplicateSurface,
|
|
|
|
ddraw1_EnumDisplayModes,
|
|
|
|
ddraw1_EnumSurfaces,
|
|
|
|
ddraw1_FlipToGDISurface,
|
|
|
|
ddraw1_GetCaps,
|
|
|
|
ddraw1_GetDisplayMode,
|
|
|
|
ddraw1_GetFourCCCodes,
|
|
|
|
ddraw1_GetGDISurface,
|
|
|
|
ddraw1_GetMonitorFrequency,
|
|
|
|
ddraw1_GetScanLine,
|
|
|
|
ddraw1_GetVerticalBlankStatus,
|
|
|
|
ddraw1_Initialize,
|
|
|
|
ddraw1_RestoreDisplayMode,
|
|
|
|
ddraw1_SetCooperativeLevel,
|
|
|
|
ddraw1_SetDisplayMode,
|
|
|
|
ddraw1_WaitForVerticalBlank,
|
2006-06-09 19:36:12 +02:00
|
|
|
};
|
2007-04-22 17:55:30 +02:00
|
|
|
|
2010-08-19 18:57:48 +02:00
|
|
|
static const struct IDirect3D7Vtbl d3d7_vtbl =
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d7_QueryInterface,
|
|
|
|
d3d7_AddRef,
|
|
|
|
d3d7_Release,
|
|
|
|
/* IDirect3D7 methods */
|
|
|
|
d3d7_EnumDevices,
|
|
|
|
d3d7_CreateDevice,
|
|
|
|
d3d7_CreateVertexBuffer,
|
|
|
|
d3d7_EnumZBufferFormats,
|
|
|
|
d3d7_EvictManagedTextures
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:48 +02:00
|
|
|
static const struct IDirect3D3Vtbl d3d3_vtbl =
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d3_QueryInterface,
|
|
|
|
d3d3_AddRef,
|
|
|
|
d3d3_Release,
|
|
|
|
/* IDirect3D3 methods */
|
|
|
|
d3d3_EnumDevices,
|
|
|
|
d3d3_CreateLight,
|
|
|
|
d3d3_CreateMaterial,
|
|
|
|
d3d3_CreateViewport,
|
|
|
|
d3d3_FindDevice,
|
|
|
|
d3d3_CreateDevice,
|
|
|
|
d3d3_CreateVertexBuffer,
|
|
|
|
d3d3_EnumZBufferFormats,
|
|
|
|
d3d3_EvictManagedTextures
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:48 +02:00
|
|
|
static const struct IDirect3D2Vtbl d3d2_vtbl =
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d2_QueryInterface,
|
|
|
|
d3d2_AddRef,
|
|
|
|
d3d2_Release,
|
|
|
|
/* IDirect3D2 methods */
|
|
|
|
d3d2_EnumDevices,
|
|
|
|
d3d2_CreateLight,
|
|
|
|
d3d2_CreateMaterial,
|
|
|
|
d3d2_CreateViewport,
|
|
|
|
d3d2_FindDevice,
|
|
|
|
d3d2_CreateDevice
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:48 +02:00
|
|
|
static const struct IDirect3DVtbl d3d1_vtbl =
|
2010-08-17 19:03:22 +02:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d1_QueryInterface,
|
|
|
|
d3d1_AddRef,
|
|
|
|
d3d1_Release,
|
|
|
|
/* IDirect3D methods */
|
|
|
|
d3d1_Initialize,
|
|
|
|
d3d1_EnumDevices,
|
|
|
|
d3d1_CreateLight,
|
|
|
|
d3d1_CreateMaterial,
|
|
|
|
d3d1_CreateViewport,
|
|
|
|
d3d1_FindDevice
|
|
|
|
};
|
|
|
|
|
2007-04-22 17:55:30 +02:00
|
|
|
/*****************************************************************************
|
2010-07-19 18:36:19 +02:00
|
|
|
* ddraw_find_decl
|
2007-04-22 17:55:30 +02:00
|
|
|
*
|
|
|
|
* Finds the WineD3D vertex declaration for a specific fvf, and creates one
|
|
|
|
* if none was found.
|
|
|
|
*
|
|
|
|
* This function is in ddraw.c and the DDraw object space because D3D7
|
|
|
|
* vertex buffers are created using the IDirect3D interface to the ddraw
|
2007-04-30 02:06:11 +02:00
|
|
|
* object, so they can be valid across D3D devices(theoretically. The ddraw
|
2007-04-22 17:55:30 +02:00
|
|
|
* object also owns the wined3d device
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* This: Device
|
|
|
|
* fvf: Fvf to find the decl for
|
|
|
|
*
|
|
|
|
* Returns:
|
2011-02-02 20:22:50 +01:00
|
|
|
* NULL in case of an error, the vertex declaration for the FVF otherwise.
|
2007-04-22 17:55:30 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2012-03-08 20:27:16 +01:00
|
|
|
struct wined3d_vertex_declaration *ddraw_find_decl(struct ddraw *This, DWORD fvf)
|
2007-04-22 17:55:30 +02:00
|
|
|
{
|
2011-02-02 20:22:50 +01:00
|
|
|
struct wined3d_vertex_declaration *pDecl = NULL;
|
2007-04-22 17:55:30 +02:00
|
|
|
HRESULT hr;
|
|
|
|
int p, low, high; /* deliberately signed */
|
|
|
|
struct FvfToDecl *convertedDecls = This->decls;
|
|
|
|
|
|
|
|
TRACE("Searching for declaration for fvf %08x... ", fvf);
|
|
|
|
|
|
|
|
low = 0;
|
|
|
|
high = This->numConvertedDecls - 1;
|
|
|
|
while(low <= high) {
|
|
|
|
p = (low + high) >> 1;
|
|
|
|
TRACE("%d ", p);
|
|
|
|
if(convertedDecls[p].fvf == fvf) {
|
|
|
|
TRACE("found %p\n", convertedDecls[p].decl);
|
|
|
|
return convertedDecls[p].decl;
|
|
|
|
} else if(convertedDecls[p].fvf < fvf) {
|
|
|
|
low = p + 1;
|
|
|
|
} else {
|
|
|
|
high = p - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("not found. Creating and inserting at position %d.\n", low);
|
|
|
|
|
2011-05-16 23:01:22 +02:00
|
|
|
hr = wined3d_vertex_declaration_create_from_fvf(This->wined3d_device,
|
2010-08-31 18:41:40 +02:00
|
|
|
fvf, This, &ddraw_null_wined3d_parent_ops, &pDecl);
|
2007-04-22 17:55:30 +02:00
|
|
|
if (hr != S_OK) return NULL;
|
|
|
|
|
|
|
|
if(This->declArraySize == This->numConvertedDecls) {
|
|
|
|
int grow = max(This->declArraySize / 2, 8);
|
|
|
|
convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls,
|
|
|
|
sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow));
|
2011-02-02 20:22:50 +01:00
|
|
|
if (!convertedDecls)
|
|
|
|
{
|
|
|
|
wined3d_vertex_declaration_decref(pDecl);
|
2007-04-22 17:55:30 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
This->decls = convertedDecls;
|
|
|
|
This->declArraySize += grow;
|
|
|
|
}
|
|
|
|
|
|
|
|
memmove(convertedDecls + low + 1, convertedDecls + low, sizeof(convertedDecls[0]) * (This->numConvertedDecls - low));
|
|
|
|
convertedDecls[low].decl = pDecl;
|
|
|
|
convertedDecls[low].fvf = fvf;
|
|
|
|
This->numConvertedDecls++;
|
|
|
|
|
|
|
|
TRACE("Returning %p. %d decls in array\n", pDecl, This->numConvertedDecls);
|
|
|
|
return pDecl;
|
|
|
|
}
|
2009-01-16 10:14:24 +01:00
|
|
|
|
2012-03-08 20:27:16 +01:00
|
|
|
static inline struct ddraw *ddraw_from_device_parent(struct wined3d_device_parent *device_parent)
|
2009-01-16 10:14:24 +01:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
return CONTAINING_RECORD(device_parent, struct ddraw, device_parent);
|
2009-01-16 10:14:24 +01:00
|
|
|
}
|
|
|
|
|
2011-05-18 22:30:13 +02:00
|
|
|
static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
|
2011-05-16 23:01:22 +02:00
|
|
|
struct wined3d_device *device)
|
2009-02-23 09:16:01 +01:00
|
|
|
{
|
2011-05-18 22:30:13 +02:00
|
|
|
TRACE("device_parent %p, device %p.\n", device_parent, device);
|
2009-02-23 09:16:01 +01:00
|
|
|
}
|
|
|
|
|
2012-02-21 10:02:13 +01:00
|
|
|
/* This is run from device_process_message() in wined3d, we can't take the
|
|
|
|
* wined3d mutex. */
|
2015-12-08 14:27:18 +01:00
|
|
|
/* FIXME: We only get mode change notifications in exclusive mode, but we
|
|
|
|
* should mark surfaces as lost on mode changes in DDSCL_NORMAL mode as well. */
|
2011-11-30 06:01:44 +01:00
|
|
|
static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
|
2011-11-30 06:01:44 +01:00
|
|
|
MONITORINFO monitor_info;
|
|
|
|
HMONITOR monitor;
|
|
|
|
RECT *r;
|
|
|
|
|
|
|
|
TRACE("device_parent %p.\n", device_parent);
|
|
|
|
|
|
|
|
if (!(ddraw->cooperative_level & DDSCL_EXCLUSIVE) || !ddraw->swapchain_window)
|
|
|
|
{
|
|
|
|
TRACE("Nothing to resize.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
monitor = MonitorFromWindow(ddraw->swapchain_window, MONITOR_DEFAULTTOPRIMARY);
|
|
|
|
monitor_info.cbSize = sizeof(monitor_info);
|
2012-11-20 21:58:23 +01:00
|
|
|
if (!GetMonitorInfoW(monitor, &monitor_info))
|
2011-11-30 06:01:44 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to get monitor info.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = &monitor_info.rcMonitor;
|
|
|
|
TRACE("Resizing window %p to %s.\n", ddraw->swapchain_window, wine_dbgstr_rect(r));
|
|
|
|
|
2012-11-20 21:58:23 +01:00
|
|
|
if (!SetWindowPos(ddraw->swapchain_window, HWND_TOP, r->left, r->top,
|
|
|
|
r->right - r->left, r->bottom - r->top, SWP_SHOWWINDOW | SWP_NOACTIVATE))
|
2011-11-30 06:01:44 +01:00
|
|
|
ERR("Failed to resize window.\n");
|
2015-12-08 14:27:18 +01:00
|
|
|
|
|
|
|
InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_NOT_RESTORED, DDRAW_DEVICE_STATE_OK);
|
2011-11-30 06:01:44 +01:00
|
|
|
}
|
|
|
|
|
2014-06-27 08:26:59 +02:00
|
|
|
static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate)
|
|
|
|
{
|
2014-06-30 11:17:03 +02:00
|
|
|
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
|
|
|
|
|
2014-06-27 08:26:59 +02:00
|
|
|
TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
|
2014-06-30 11:17:03 +02:00
|
|
|
|
|
|
|
if (!activate)
|
2015-12-04 11:30:15 +01:00
|
|
|
{
|
2015-12-04 11:30:14 +01:00
|
|
|
ddraw->device_state = DDRAW_DEVICE_STATE_LOST;
|
2015-12-04 11:30:15 +01:00
|
|
|
exclusive_window = NULL;
|
|
|
|
}
|
2014-06-30 11:17:03 +02:00
|
|
|
else
|
2015-12-04 11:30:15 +01:00
|
|
|
{
|
2015-12-04 11:30:14 +01:00
|
|
|
InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_NOT_RESTORED, DDRAW_DEVICE_STATE_LOST);
|
2015-12-04 11:30:15 +01:00
|
|
|
}
|
2015-12-04 11:30:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ddraw_update_lost_surfaces(struct ddraw *ddraw)
|
|
|
|
{
|
|
|
|
struct ddraw_surface *surface;
|
|
|
|
|
|
|
|
if (ddraw->device_state != DDRAW_DEVICE_STATE_NOT_RESTORED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(surface, &ddraw->surface_list, struct ddraw_surface, surface_list_entry)
|
|
|
|
{
|
|
|
|
surface->is_lost = TRUE;
|
|
|
|
}
|
|
|
|
ddraw->device_state = DDRAW_DEVICE_STATE_OK;
|
2014-06-27 08:26:59 +02:00
|
|
|
}
|
|
|
|
|
2013-11-15 08:24:31 +01:00
|
|
|
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
|
2016-02-12 11:06:08 +01:00
|
|
|
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
|
2013-11-15 08:24:31 +01:00
|
|
|
void **parent, const struct wined3d_parent_ops **parent_ops)
|
2009-01-16 10:14:24 +01:00
|
|
|
{
|
2012-07-13 12:53:09 +02:00
|
|
|
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
|
|
|
|
struct ddraw_surface *ddraw_surface;
|
2009-01-16 10:14:24 +01:00
|
|
|
|
2016-02-12 11:06:08 +01:00
|
|
|
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
|
|
|
|
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
|
2009-01-16 10:14:24 +01:00
|
|
|
|
2014-06-13 10:01:18 +02:00
|
|
|
/* We have a swapchain or wined3d internal texture. */
|
2015-10-12 12:44:07 +02:00
|
|
|
if (!wined3d_texture_get_parent(wined3d_texture) || wined3d_texture_get_parent(wined3d_texture) == ddraw)
|
2013-11-15 08:24:31 +01:00
|
|
|
{
|
|
|
|
*parent = NULL;
|
|
|
|
*parent_ops = &ddraw_null_wined3d_parent_ops;
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(ddraw_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ddraw_surface))))
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate surface memory.\n");
|
|
|
|
return DDERR_OUTOFVIDEOMEMORY;
|
|
|
|
}
|
2013-11-13 10:12:06 +01:00
|
|
|
|
2016-02-12 11:06:07 +01:00
|
|
|
ddraw_surface_init(ddraw_surface, ddraw, wined3d_texture, sub_resource_idx, parent_ops);
|
2013-11-15 08:24:31 +01:00
|
|
|
*parent = ddraw_surface;
|
2015-12-04 11:30:14 +01:00
|
|
|
|
|
|
|
ddraw_update_lost_surfaces(ddraw);
|
2013-11-15 08:24:31 +01:00
|
|
|
list_add_head(&ddraw->surface_list, &ddraw_surface->surface_list_entry);
|
|
|
|
|
|
|
|
TRACE("Created ddraw surface %p.\n", ddraw_surface);
|
2012-07-13 12:53:09 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
2009-01-16 10:14:24 +01:00
|
|
|
}
|
|
|
|
|
2013-12-06 11:09:53 +01:00
|
|
|
static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
|
2015-10-07 19:04:34 +02:00
|
|
|
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
|
2013-12-06 11:09:53 +01:00
|
|
|
void **parent, const struct wined3d_parent_ops **parent_ops)
|
|
|
|
{
|
2015-10-07 19:04:34 +02:00
|
|
|
TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
|
|
|
|
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
|
2013-12-06 11:09:53 +01:00
|
|
|
|
|
|
|
*parent = NULL;
|
|
|
|
*parent_ops = &ddraw_null_wined3d_parent_ops;
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-15 20:01:51 +02:00
|
|
|
static void STDMETHODCALLTYPE ddraw_frontbuffer_destroyed(void *parent)
|
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = parent;
|
2011-09-15 20:01:51 +02:00
|
|
|
ddraw->wined3d_frontbuffer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wined3d_parent_ops ddraw_frontbuffer_parent_ops =
|
|
|
|
{
|
|
|
|
ddraw_frontbuffer_destroyed,
|
|
|
|
};
|
|
|
|
|
2015-09-03 20:56:26 +02:00
|
|
|
static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_device_parent *device_parent,
|
2017-02-09 05:51:56 +01:00
|
|
|
void *container_parent, const struct wined3d_resource_desc *desc, DWORD texture_flags,
|
|
|
|
struct wined3d_texture **texture)
|
2009-01-16 10:14:24 +01:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
|
2011-09-15 20:01:51 +02:00
|
|
|
HRESULT hr;
|
2009-01-16 10:14:24 +01:00
|
|
|
|
2017-02-09 05:51:56 +01:00
|
|
|
TRACE("device_parent %p, container_parent %p, desc %p, texture flags %#x, texture %p.\n",
|
|
|
|
device_parent, container_parent, desc, texture_flags, texture);
|
2009-01-16 10:14:24 +01:00
|
|
|
|
2011-09-15 20:01:51 +02:00
|
|
|
if (ddraw->wined3d_frontbuffer)
|
2009-01-16 10:14:24 +01:00
|
|
|
{
|
2011-09-15 20:01:50 +02:00
|
|
|
ERR("Frontbuffer already created.\n");
|
|
|
|
return E_FAIL;
|
2009-01-16 10:14:24 +01:00
|
|
|
}
|
|
|
|
|
2016-04-25 12:25:29 +02:00
|
|
|
if (FAILED(hr = wined3d_texture_create(ddraw->wined3d_device, desc, 1, 1,
|
2017-02-09 05:51:56 +01:00
|
|
|
texture_flags | WINED3D_TEXTURE_CREATE_MAPPABLE, NULL, ddraw, &ddraw_frontbuffer_parent_ops, texture)))
|
2013-11-13 10:12:06 +01:00
|
|
|
{
|
|
|
|
WARN("Failed to create texture, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2016-01-29 18:48:54 +01:00
|
|
|
ddraw->wined3d_frontbuffer = *texture;
|
2009-01-16 10:14:24 +01:00
|
|
|
|
2011-09-15 20:01:51 +02:00
|
|
|
return hr;
|
2009-01-16 10:14:24 +01:00
|
|
|
}
|
|
|
|
|
2011-05-18 22:30:13 +02:00
|
|
|
static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
|
2011-12-02 08:15:52 +01:00
|
|
|
struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
|
2009-01-16 10:14:24 +01:00
|
|
|
{
|
2012-03-08 20:27:16 +01:00
|
|
|
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
|
2009-01-16 10:14:24 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2011-12-02 08:15:52 +01:00
|
|
|
TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain);
|
2009-01-16 10:14:24 +01:00
|
|
|
|
2011-09-19 21:50:24 +02:00
|
|
|
if (ddraw->wined3d_swapchain)
|
|
|
|
{
|
|
|
|
ERR("Swapchain already created.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2013-01-16 08:51:49 +01:00
|
|
|
if (FAILED(hr = wined3d_swapchain_create(ddraw->wined3d_device, desc, NULL,
|
|
|
|
&ddraw_null_wined3d_parent_ops, swapchain)))
|
2011-05-18 22:30:13 +02:00
|
|
|
WARN("Failed to create swapchain, hr %#x.\n", hr);
|
2009-01-16 10:14:24 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-05-18 22:30:13 +02:00
|
|
|
static const struct wined3d_device_parent_ops ddraw_wined3d_device_parent_ops =
|
2009-01-16 10:14:24 +01:00
|
|
|
{
|
2011-05-18 22:30:13 +02:00
|
|
|
device_parent_wined3d_device_created,
|
2011-11-30 06:01:44 +01:00
|
|
|
device_parent_mode_changed,
|
2014-06-27 08:26:59 +02:00
|
|
|
device_parent_activate,
|
2013-11-15 08:24:31 +01:00
|
|
|
device_parent_surface_created,
|
2013-12-06 11:09:53 +01:00
|
|
|
device_parent_volume_created,
|
2015-09-03 20:56:26 +02:00
|
|
|
device_parent_create_swapchain_texture,
|
2011-05-18 22:30:13 +02:00
|
|
|
device_parent_create_swapchain,
|
2009-01-16 10:14:24 +01:00
|
|
|
};
|
2010-08-19 18:57:48 +02:00
|
|
|
|
2015-04-23 22:41:12 +02:00
|
|
|
HRESULT ddraw_init(struct ddraw *ddraw, DWORD flags, enum wined3d_device_type device_type)
|
2010-08-19 18:57:48 +02:00
|
|
|
{
|
2013-05-30 10:05:33 +02:00
|
|
|
WINED3DCAPS caps;
|
2010-08-19 18:57:48 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2011-01-19 01:42:43 +01:00
|
|
|
ddraw->IDirectDraw7_iface.lpVtbl = &ddraw7_vtbl;
|
2011-01-19 01:33:42 +01:00
|
|
|
ddraw->IDirectDraw_iface.lpVtbl = &ddraw1_vtbl;
|
2011-01-19 01:36:36 +01:00
|
|
|
ddraw->IDirectDraw2_iface.lpVtbl = &ddraw2_vtbl;
|
2011-01-19 01:40:53 +01:00
|
|
|
ddraw->IDirectDraw4_iface.lpVtbl = &ddraw4_vtbl;
|
2011-01-18 12:28:15 +01:00
|
|
|
ddraw->IDirect3D_iface.lpVtbl = &d3d1_vtbl;
|
2011-01-18 12:30:17 +01:00
|
|
|
ddraw->IDirect3D2_iface.lpVtbl = &d3d2_vtbl;
|
2011-01-19 01:30:21 +01:00
|
|
|
ddraw->IDirect3D3_iface.lpVtbl = &d3d3_vtbl;
|
2011-01-19 01:32:36 +01:00
|
|
|
ddraw->IDirect3D7_iface.lpVtbl = &d3d7_vtbl;
|
2011-05-18 22:30:13 +02:00
|
|
|
ddraw->device_parent.ops = &ddraw_wined3d_device_parent_ops;
|
2010-08-19 18:57:48 +02:00
|
|
|
ddraw->numIfaces = 1;
|
|
|
|
ddraw->ref7 = 1;
|
|
|
|
|
2015-04-23 22:41:12 +02:00
|
|
|
flags |= DDRAW_WINED3D_FLAGS;
|
|
|
|
if (!(ddraw->wined3d = wined3d_create(flags)))
|
2010-08-19 18:57:48 +02:00
|
|
|
{
|
2015-04-23 22:41:12 +02:00
|
|
|
flags |= WINED3D_NO3D;
|
|
|
|
if (!(ddraw->wined3d = wined3d_create(flags)))
|
2013-01-13 22:08:09 +01:00
|
|
|
{
|
|
|
|
WARN("Failed to create a wined3d object.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2013-05-30 10:05:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = wined3d_get_device_caps(ddraw->wined3d, WINED3DADAPTER_DEFAULT, device_type, &caps)))
|
|
|
|
{
|
|
|
|
ERR("Failed to get device caps, hr %#x.\n", hr);
|
|
|
|
wined3d_decref(ddraw->wined3d);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2013-01-13 22:08:09 +01:00
|
|
|
|
2013-05-30 10:05:33 +02:00
|
|
|
if (!(caps.ddraw_caps.caps & WINEDDCAPS_3D))
|
|
|
|
{
|
2013-01-13 22:08:09 +01:00
|
|
|
WARN("Created a wined3d object without 3D support.\n");
|
2013-05-30 10:05:33 +02:00
|
|
|
ddraw->flags |= DDRAW_NO3D;
|
2010-08-19 18:57:48 +02:00
|
|
|
}
|
|
|
|
|
2013-08-29 10:26:24 +02:00
|
|
|
if (FAILED(hr = wined3d_device_create(ddraw->wined3d, WINED3DADAPTER_DEFAULT, device_type,
|
|
|
|
NULL, 0, DDRAW_STRIDE_ALIGNMENT, &ddraw->device_parent, &ddraw->wined3d_device)))
|
2010-08-19 18:57:48 +02:00
|
|
|
{
|
|
|
|
WARN("Failed to create a wined3d device, hr %#x.\n", hr);
|
2011-11-28 21:30:58 +01:00
|
|
|
wined3d_decref(ddraw->wined3d);
|
2010-08-19 18:57:48 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
list_init(&ddraw->surface_list);
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|