d3drm: Make it possible to create material objects with CreateObject().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4019682855
commit
48a047027b
|
@ -136,6 +136,19 @@ static HRESULT d3drm_create_light_object(void **object, IDirect3DRM *d3drm)
|
|||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT d3drm_create_material_object(void **object, IDirect3DRM *d3drm)
|
||||
{
|
||||
struct d3drm_material *material;
|
||||
HRESULT hr;
|
||||
|
||||
if (FAILED(hr = d3drm_material_create(&material, d3drm)))
|
||||
return hr;
|
||||
|
||||
*object = &material->IDirect3DRMMaterial2_iface;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
struct d3drm
|
||||
{
|
||||
IDirect3DRM IDirect3DRM_iface;
|
||||
|
@ -1285,6 +1298,7 @@ static HRESULT WINAPI d3drm3_CreateObject(IDirect3DRM3 *iface,
|
|||
{&CLSID_CDirect3DRMMeshBuilder, d3drm_create_mesh_builder_object},
|
||||
{&CLSID_CDirect3DRMFrame, d3drm_create_frame_object},
|
||||
{&CLSID_CDirect3DRMLight, d3drm_create_light_object},
|
||||
{&CLSID_CDirect3DRMMaterial, d3drm_create_material_object},
|
||||
};
|
||||
|
||||
TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
|
||||
|
@ -1474,12 +1488,16 @@ static HRESULT WINAPI d3drm3_CreateLightRGB(IDirect3DRM3 *iface, D3DRMLIGHTTYPE
|
|||
static HRESULT WINAPI d3drm3_CreateMaterial(IDirect3DRM3 *iface,
|
||||
D3DVALUE power, IDirect3DRMMaterial2 **material)
|
||||
{
|
||||
struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
|
||||
struct d3drm_material *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, power %.8e, material %p.\n", iface, power, material);
|
||||
|
||||
if (SUCCEEDED(hr = Direct3DRMMaterial_create(material)))
|
||||
IDirect3DRMMaterial2_SetPower(*material, power);
|
||||
if (SUCCEEDED(hr = d3drm_material_create(&object, &d3drm->IDirect3DRM_iface)))
|
||||
IDirect3DRMMaterial2_SetPower(&object->IDirect3DRMMaterial2_iface, power);
|
||||
|
||||
*material = &object->IDirect3DRMMaterial2_iface;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -163,6 +163,25 @@ struct d3drm_light
|
|||
D3DVALUE penumbra;
|
||||
};
|
||||
|
||||
struct color_rgb
|
||||
{
|
||||
D3DVALUE r;
|
||||
D3DVALUE g;
|
||||
D3DVALUE b;
|
||||
};
|
||||
|
||||
struct d3drm_material
|
||||
{
|
||||
struct d3drm_object obj;
|
||||
IDirect3DRMMaterial2 IDirect3DRMMaterial2_iface;
|
||||
LONG ref;
|
||||
IDirect3DRM *d3drm;
|
||||
struct color_rgb emissive;
|
||||
struct color_rgb specular;
|
||||
D3DVALUE power;
|
||||
struct color_rgb ambient;
|
||||
};
|
||||
|
||||
HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
|
||||
HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw,
|
||||
IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface) DECLSPEC_HIDDEN;
|
||||
|
@ -185,8 +204,8 @@ HRESULT d3drm_face_create(struct d3drm_face **face) DECLSPEC_HIDDEN;
|
|||
HRESULT d3drm_viewport_create(struct d3drm_viewport **viewport, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
|
||||
HRESULT d3drm_mesh_builder_create(struct d3drm_mesh_builder **mesh_builder, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
|
||||
HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
|
||||
HRESULT d3drm_material_create(struct d3drm_material **material, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
|
||||
HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj) DECLSPEC_HIDDEN;
|
||||
HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2** ret_iface) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *data,
|
||||
D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -25,24 +25,6 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
|
||||
|
||||
struct color_rgb
|
||||
{
|
||||
D3DVALUE r;
|
||||
D3DVALUE g;
|
||||
D3DVALUE b;
|
||||
};
|
||||
|
||||
struct d3drm_material
|
||||
{
|
||||
struct d3drm_object obj;
|
||||
IDirect3DRMMaterial2 IDirect3DRMMaterial2_iface;
|
||||
LONG ref;
|
||||
struct color_rgb emissive;
|
||||
struct color_rgb specular;
|
||||
D3DVALUE power;
|
||||
struct color_rgb ambient;
|
||||
};
|
||||
|
||||
static inline struct d3drm_material *impl_from_IDirect3DRMMaterial2(IDirect3DRMMaterial2 *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, struct d3drm_material, IDirect3DRMMaterial2_iface);
|
||||
|
@ -54,6 +36,7 @@ static HRESULT WINAPI d3drm_material_QueryInterface(IDirect3DRMMaterial2 *iface,
|
|||
|
||||
if (IsEqualGUID(riid, &IID_IDirect3DRMMaterial2)
|
||||
|| IsEqualGUID(riid, &IID_IDirect3DRMMaterial)
|
||||
|| IsEqualGUID(riid, &IID_IDirect3DRMObject)
|
||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
IDirect3DRMMaterial2_AddRef(iface);
|
||||
|
@ -85,7 +68,11 @@ static ULONG WINAPI d3drm_material_Release(IDirect3DRMMaterial2 *iface)
|
|||
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
||||
|
||||
if (!refcount)
|
||||
{
|
||||
d3drm_object_cleanup((IDirect3DRMObject *)iface, &material->obj);
|
||||
IDirect3DRM_Release(material->d3drm);
|
||||
HeapFree(GetProcessHeap(), 0, material);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
@ -101,17 +88,21 @@ static HRESULT WINAPI d3drm_material_Clone(IDirect3DRMMaterial2 *iface,
|
|||
static HRESULT WINAPI d3drm_material_AddDestroyCallback(IDirect3DRMMaterial2 *iface,
|
||||
D3DRMOBJECTCALLBACK cb, void *ctx)
|
||||
{
|
||||
FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
|
||||
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
|
||||
|
||||
return d3drm_object_add_destroy_callback(&material->obj, cb, ctx);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3drm_material_DeleteDestroyCallback(IDirect3DRMMaterial2 *iface,
|
||||
D3DRMOBJECTCALLBACK cb, void *ctx)
|
||||
{
|
||||
FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
|
||||
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
|
||||
|
||||
return d3drm_object_delete_destroy_callback(&material->obj, cb, ctx);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3drm_material_SetAppData(IDirect3DRMMaterial2 *iface, DWORD data)
|
||||
|
@ -278,18 +269,20 @@ static const struct IDirect3DRMMaterial2Vtbl d3drm_material_vtbl =
|
|||
d3drm_material_SetAmbient,
|
||||
};
|
||||
|
||||
HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2 **out)
|
||||
HRESULT d3drm_material_create(struct d3drm_material **material, IDirect3DRM *d3drm)
|
||||
{
|
||||
static const char classname[] = "Material";
|
||||
struct d3drm_material *object;
|
||||
|
||||
TRACE("out %p.\n", out);
|
||||
TRACE("material %p, d3drm %p.\n", material, d3drm);
|
||||
|
||||
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
object->IDirect3DRMMaterial2_iface.lpVtbl = &d3drm_material_vtbl;
|
||||
object->ref = 1;
|
||||
object->d3drm = d3drm;
|
||||
IDirect3DRM_AddRef(object->d3drm);
|
||||
|
||||
object->specular.r = 1.0f;
|
||||
object->specular.g = 1.0f;
|
||||
|
@ -297,7 +290,7 @@ HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2 **out)
|
|||
|
||||
d3drm_object_init(&object->obj, classname);
|
||||
|
||||
*out = &object->IDirect3DRMMaterial2_iface;
|
||||
*material = object;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -1232,6 +1232,7 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData,
|
|||
IDirectXFileData *data;
|
||||
IDirectXFileDataReference *reference;
|
||||
IDirectXFileObject *material_child;
|
||||
struct d3drm_material *object;
|
||||
|
||||
hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
|
||||
if (FAILED(hr))
|
||||
|
@ -1251,12 +1252,13 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData,
|
|||
IDirectXFileObject_Release(child);
|
||||
}
|
||||
|
||||
hr = Direct3DRMMaterial_create(&mesh_builder->materials[i].material);
|
||||
hr = d3drm_material_create(&object, mesh_builder->d3drm);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
IDirectXFileData_Release(data);
|
||||
goto end;
|
||||
}
|
||||
mesh_builder->materials[i].material = &object->IDirect3DRMMaterial2_iface;
|
||||
|
||||
hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
|
||||
if (hr != DXFILE_OK)
|
||||
|
|
|
@ -1404,6 +1404,8 @@ static void test_object(void)
|
|||
{ &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame2 },
|
||||
{ &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame3 },
|
||||
{ &CLSID_CDirect3DRMLight, &IID_IDirect3DRMLight },
|
||||
{ &CLSID_CDirect3DRMMaterial, &IID_IDirect3DRMMaterial },
|
||||
{ &CLSID_CDirect3DRMMaterial, &IID_IDirect3DRMMaterial2 },
|
||||
};
|
||||
IDirect3DRM *d3drm1;
|
||||
IDirect3DRM2 *d3drm2;
|
||||
|
@ -1429,7 +1431,8 @@ static void test_object(void)
|
|||
{
|
||||
BOOL takes_ref = IsEqualGUID(tests[i].clsid, &CLSID_CDirect3DRMMeshBuilder) ||
|
||||
IsEqualGUID(tests[i].clsid, &CLSID_CDirect3DRMFrame) ||
|
||||
IsEqualGUID(tests[i].clsid, &CLSID_CDirect3DRMLight);
|
||||
IsEqualGUID(tests[i].clsid, &CLSID_CDirect3DRMLight) ||
|
||||
IsEqualGUID(tests[i].clsid, &CLSID_CDirect3DRMMaterial);
|
||||
|
||||
unknown = (IUnknown *)0xdeadbeef;
|
||||
hr = IDirect3DRM_CreateObject(d3drm1, NULL, NULL, tests[i].iid, (void **)&unknown);
|
||||
|
|
Loading…
Reference in New Issue