d3d8: Add a separate function for d3d8 initialization.

This commit is contained in:
Henri Verbeet 2012-05-03 21:49:36 +02:00 committed by Alexandre Julliard
parent 0f9ccac447
commit 5a4c15b9d9
3 changed files with 34 additions and 31 deletions

View File

@ -35,27 +35,27 @@ void WINAPI DebugSetMute(void) {
/* nothing to do */
}
IDirect3D8* WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT SDKVersion) {
IDirect3D8Impl* object;
TRACE("SDKVersion = %x\n", SDKVersion);
IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version)
{
IDirect3D8Impl *object;
wined3d_mutex_lock();
TRACE("sdk_version %#x.\n", sdk_version);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D8Impl));
object->IDirect3D8_iface.lpVtbl = &Direct3D8_Vtbl;
object->ref = 1;
object->WineD3D = wined3d_create(8, WINED3D_LEGACY_DEPTH_BIAS);
TRACE("Created Direct3D object @ %p, WineObj @ %p\n", object, object->WineD3D);
wined3d_mutex_unlock();
if (!object->WineD3D)
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
{
HeapFree( GetProcessHeap(), 0, object );
object = NULL;
ERR("Failed to allocate d3d8 object memory.\n");
return NULL;
}
if (!d3d8_init(object))
{
WARN("Failed to initialize d3d8.\n");
HeapFree(GetProcessHeap(), 0, object);
return NULL;
}
TRACE("Created d3d8 object %p.\n", object);
return &object->IDirect3D8_iface;
}

View File

@ -110,19 +110,6 @@ typedef struct IDirect3DSwapChain8Impl IDirect3DSwapChain8Impl;
typedef struct IDirect3DVolume8Impl IDirect3DVolume8Impl;
typedef struct IDirect3DVertexBuffer8Impl IDirect3DVertexBuffer8Impl;
/* ===========================================================================
The interfaces themselves
=========================================================================== */
/* ---------- */
/* IDirect3D8 */
/* ---------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3D8Vtbl Direct3D8_Vtbl DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirect3D implementation structure
*/
@ -133,6 +120,8 @@ struct IDirect3D8Impl
struct wined3d *WineD3D;
};
BOOL d3d8_init(IDirect3D8Impl *d3d8) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirect3DDevice8 implementation structure
*/

View File

@ -378,7 +378,7 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(IDirect3D8 *iface, UINT adapte
return D3D_OK;
}
const IDirect3D8Vtbl Direct3D8_Vtbl =
static const struct IDirect3D8Vtbl Direct3D8_Vtbl =
{
/* IUnknown */
IDirect3D8Impl_QueryInterface,
@ -399,3 +399,17 @@ const IDirect3D8Vtbl Direct3D8_Vtbl =
IDirect3D8Impl_GetAdapterMonitor,
IDirect3D8Impl_CreateDevice
};
BOOL d3d8_init(IDirect3D8Impl *d3d8)
{
d3d8->IDirect3D8_iface.lpVtbl = &Direct3D8_Vtbl;
d3d8->ref = 1;
wined3d_mutex_lock();
d3d8->WineD3D = wined3d_create(8, WINED3D_LEGACY_DEPTH_BIAS);
wined3d_mutex_unlock();
if (!d3d8->WineD3D)
return FALSE;
return TRUE;
}