Commit 5a4c15b9 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d8: Add a separate function for d3d8 initialization.

parent 0f9ccac4
......@@ -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);
wined3d_mutex_lock();
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);
IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version)
{
IDirect3D8Impl *object;
TRACE("Created Direct3D object @ %p, WineObj @ %p\n", object, object->WineD3D);
TRACE("sdk_version %#x.\n", sdk_version);
wined3d_mutex_unlock();
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
{
ERR("Failed to allocate d3d8 object memory.\n");
return NULL;
}
if (!object->WineD3D)
if (!d3d8_init(object))
{
HeapFree( GetProcessHeap(), 0, object );
object = NULL;
WARN("Failed to initialize d3d8.\n");
HeapFree(GetProcessHeap(), 0, object);
return NULL;
}
TRACE("Created d3d8 object %p.\n", object);
return &object->IDirect3D8_iface;
}
......
......@@ -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
*/
......
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment