Commit 3d343d6e authored by Aaryaman Vasishta's avatar Aaryaman Vasishta Committed by Alexandre Julliard

d3drm: Implement IDirect3DRMDevice*::InitFromD3D.

parent e13011f6
......@@ -64,6 +64,19 @@ static HRESULT d3drm_create_texture_object(void **object, IDirect3DRM *d3drm)
return hr;
}
static HRESULT d3drm_create_device_object(void **object, IDirect3DRM *d3drm)
{
struct d3drm_device *device;
HRESULT hr;
if (FAILED(hr = d3drm_device_create(&device, d3drm)))
return hr;
*object = &device->IDirect3DRMDevice_iface;
return hr;
}
struct d3drm
{
IDirect3DRM IDirect3DRM_iface;
......@@ -322,13 +335,11 @@ static HRESULT WINAPI d3drm1_CreateDeviceFromD3D(IDirect3DRM *iface,
if (!device)
return D3DRMERR_BADVALUE;
*device = NULL;
if (!d3d || !d3d_device)
return D3DRMERR_BADVALUE;
if (FAILED(hr = d3drm_device_create(&object, iface)))
return hr;
if (FAILED(hr = d3drm_device_set_ddraw_device_d3d(object, d3d, d3d_device)))
if (FAILED(hr = IDirect3DRMDevice_InitFromD3D(&object->IDirect3DRMDevice_iface, d3d, d3d_device)))
{
d3drm_device_destroy(object);
return hr;
......@@ -1125,6 +1136,7 @@ static HRESULT WINAPI d3drm3_CreateObject(IDirect3DRM3 *iface,
object_table[] =
{
{&CLSID_CDirect3DRMTexture, d3drm_create_texture_object},
{&CLSID_CDirect3DRMDevice, d3drm_create_device_object},
};
TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
......
......@@ -210,11 +210,21 @@ HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirectDraw
HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3D *d3d, IDirect3DDevice *d3d_device)
{
IDirectDraw *ddraw;
IDirectDrawSurface *surface;
IDirect3DDevice2 *d3d_device2;
DDSURFACEDESC desc;
HRESULT hr;
/* AddRef these interfaces beforehand for the intentional leak on reinitialization. */
if (FAILED(hr = IDirect3D_QueryInterface(d3d, &IID_IDirectDraw, (void **)&ddraw)))
return hr;
IDirect3DRM_AddRef(device->d3drm);
IDirect3DDevice_AddRef(d3d_device);
if (device->ddraw)
return D3DRMERR_BADOBJECT;
/* Fetch render target and get width/height from there */
if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirectDrawSurface, (void **)&surface)))
{
......@@ -232,14 +242,10 @@ HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3D
if (FAILED(hr))
return hr;
if (FAILED(hr = IDirect3D_QueryInterface(d3d, &IID_IDirectDraw, (void **)&device->ddraw)))
return hr;
device->ddraw = ddraw;
device->width = desc.dwWidth;
device->height = desc.dwHeight;
IDirect3DRM_AddRef(device->d3drm);
device->device = d3d_device;
IDirect3DDevice_AddRef(d3d_device);
return hr;
}
......@@ -610,7 +616,10 @@ static HRESULT WINAPI d3drm_device3_InitFromD3D(IDirect3DRMDevice3 *iface,
{
FIXME("iface %p, d3d %p, d3d_device %p stub!\n", iface, d3d, d3d_device);
return E_NOTIMPL;
if (!d3d || !d3d_device)
return D3DRMERR_BADVALUE;
return E_NOINTERFACE;
}
static HRESULT WINAPI d3drm_device2_InitFromD3D(IDirect3DRMDevice2 *iface,
......@@ -630,7 +639,10 @@ static HRESULT WINAPI d3drm_device1_InitFromD3D(IDirect3DRMDevice *iface,
TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
return d3drm_device3_InitFromD3D(&device->IDirect3DRMDevice3_iface, d3d, d3d_device);
if (!d3d || !d3d_device)
return D3DRMERR_BADVALUE;
return d3drm_device_set_ddraw_device_d3d(device, d3d, d3d_device);
}
static HRESULT WINAPI d3drm_device3_InitFromClipper(IDirect3DRMDevice3 *iface,
......
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