d3drm: Make it possible to create light objects using 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
02c085e313
commit
f43dfe5c08
|
@ -123,6 +123,19 @@ static HRESULT d3drm_create_frame_object(void **object, IDirect3DRM *d3drm)
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT d3drm_create_light_object(void **object, IDirect3DRM *d3drm)
|
||||||
|
{
|
||||||
|
struct d3drm_light *light;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
if (FAILED(hr = d3drm_light_create(&light, d3drm)))
|
||||||
|
return hr;
|
||||||
|
|
||||||
|
*object = &light->IDirect3DRMLight_iface;
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
struct d3drm
|
struct d3drm
|
||||||
{
|
{
|
||||||
IDirect3DRM IDirect3DRM_iface;
|
IDirect3DRM IDirect3DRM_iface;
|
||||||
|
@ -1271,6 +1284,7 @@ static HRESULT WINAPI d3drm3_CreateObject(IDirect3DRM3 *iface,
|
||||||
{&CLSID_CDirect3DRMFace, d3drm_create_face_object},
|
{&CLSID_CDirect3DRMFace, d3drm_create_face_object},
|
||||||
{&CLSID_CDirect3DRMMeshBuilder, d3drm_create_mesh_builder_object},
|
{&CLSID_CDirect3DRMMeshBuilder, d3drm_create_mesh_builder_object},
|
||||||
{&CLSID_CDirect3DRMFrame, d3drm_create_frame_object},
|
{&CLSID_CDirect3DRMFrame, d3drm_create_frame_object},
|
||||||
|
{&CLSID_CDirect3DRMLight, d3drm_create_light_object},
|
||||||
};
|
};
|
||||||
|
|
||||||
TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
|
TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
|
||||||
|
@ -1419,33 +1433,41 @@ static HRESULT WINAPI d3drm3_CreateTexture(IDirect3DRM3 *iface,
|
||||||
static HRESULT WINAPI d3drm3_CreateLight(IDirect3DRM3 *iface,
|
static HRESULT WINAPI d3drm3_CreateLight(IDirect3DRM3 *iface,
|
||||||
D3DRMLIGHTTYPE type, D3DCOLOR color, IDirect3DRMLight **light)
|
D3DRMLIGHTTYPE type, D3DCOLOR color, IDirect3DRMLight **light)
|
||||||
{
|
{
|
||||||
|
struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
|
||||||
|
struct d3drm_light *object;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
FIXME("iface %p, type %#x, color 0x%08x, light %p partial stub!\n", iface, type, color, light);
|
FIXME("iface %p, type %#x, color 0x%08x, light %p partial stub!\n", iface, type, color, light);
|
||||||
|
|
||||||
if (SUCCEEDED(hr = Direct3DRMLight_create((IUnknown **)light)))
|
if (SUCCEEDED(hr = d3drm_light_create(&object, &d3drm->IDirect3DRM_iface)))
|
||||||
{
|
{
|
||||||
IDirect3DRMLight_SetType(*light, type);
|
IDirect3DRMLight_SetType(&object->IDirect3DRMLight_iface, type);
|
||||||
IDirect3DRMLight_SetColor(*light, color);
|
IDirect3DRMLight_SetColor(&object->IDirect3DRMLight_iface, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*light = &object->IDirect3DRMLight_iface;
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI d3drm3_CreateLightRGB(IDirect3DRM3 *iface, D3DRMLIGHTTYPE type,
|
static HRESULT WINAPI d3drm3_CreateLightRGB(IDirect3DRM3 *iface, D3DRMLIGHTTYPE type,
|
||||||
D3DVALUE red, D3DVALUE green, D3DVALUE blue, IDirect3DRMLight **light)
|
D3DVALUE red, D3DVALUE green, D3DVALUE blue, IDirect3DRMLight **light)
|
||||||
{
|
{
|
||||||
|
struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
|
||||||
|
struct d3drm_light *object;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
FIXME("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p partial stub!\n",
|
FIXME("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p partial stub!\n",
|
||||||
iface, type, red, green, blue, light);
|
iface, type, red, green, blue, light);
|
||||||
|
|
||||||
if (SUCCEEDED(hr = Direct3DRMLight_create((IUnknown **)light)))
|
if (SUCCEEDED(hr = d3drm_light_create(&object, &d3drm->IDirect3DRM_iface)))
|
||||||
{
|
{
|
||||||
IDirect3DRMLight_SetType(*light, type);
|
IDirect3DRMLight_SetType(&object->IDirect3DRMLight_iface, type);
|
||||||
IDirect3DRMLight_SetColorRGB(*light, red, green, blue);
|
IDirect3DRMLight_SetColorRGB(&object->IDirect3DRMLight_iface, red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*light = &object->IDirect3DRMLight_iface;
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,22 @@ struct d3drm_mesh_builder
|
||||||
DWORD *material_indices;
|
DWORD *material_indices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct d3drm_light
|
||||||
|
{
|
||||||
|
struct d3drm_object obj;
|
||||||
|
IDirect3DRMLight IDirect3DRMLight_iface;
|
||||||
|
LONG ref;
|
||||||
|
IDirect3DRM *d3drm;
|
||||||
|
D3DRMLIGHTTYPE type;
|
||||||
|
D3DCOLOR color;
|
||||||
|
D3DVALUE range;
|
||||||
|
D3DVALUE cattenuation;
|
||||||
|
D3DVALUE lattenuation;
|
||||||
|
D3DVALUE qattenuation;
|
||||||
|
D3DVALUE umbra;
|
||||||
|
D3DVALUE penumbra;
|
||||||
|
};
|
||||||
|
|
||||||
HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
|
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,
|
HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw,
|
||||||
IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface) DECLSPEC_HIDDEN;
|
IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface) DECLSPEC_HIDDEN;
|
||||||
|
@ -168,7 +184,7 @@ HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, I
|
||||||
HRESULT d3drm_face_create(struct d3drm_face **face) DECLSPEC_HIDDEN;
|
HRESULT d3drm_face_create(struct d3drm_face **face) DECLSPEC_HIDDEN;
|
||||||
HRESULT d3drm_viewport_create(struct d3drm_viewport **viewport, IDirect3DRM *d3drm) 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_mesh_builder_create(struct d3drm_mesh_builder **mesh_builder, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
|
||||||
HRESULT Direct3DRMLight_create(IUnknown** ppObj) DECLSPEC_HIDDEN;
|
HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
|
||||||
HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj) DECLSPEC_HIDDEN;
|
HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj) DECLSPEC_HIDDEN;
|
||||||
HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2** ret_iface) DECLSPEC_HIDDEN;
|
HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2** ret_iface) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
|
|
@ -25,21 +25,6 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
|
WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
|
||||||
|
|
||||||
struct d3drm_light
|
|
||||||
{
|
|
||||||
struct d3drm_object obj;
|
|
||||||
IDirect3DRMLight IDirect3DRMLight_iface;
|
|
||||||
LONG ref;
|
|
||||||
D3DRMLIGHTTYPE type;
|
|
||||||
D3DCOLOR color;
|
|
||||||
D3DVALUE range;
|
|
||||||
D3DVALUE cattenuation;
|
|
||||||
D3DVALUE lattenuation;
|
|
||||||
D3DVALUE qattenuation;
|
|
||||||
D3DVALUE umbra;
|
|
||||||
D3DVALUE penumbra;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline struct d3drm_light *impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
|
static inline struct d3drm_light *impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
|
||||||
{
|
{
|
||||||
return CONTAINING_RECORD(iface, struct d3drm_light, IDirect3DRMLight_iface);
|
return CONTAINING_RECORD(iface, struct d3drm_light, IDirect3DRMLight_iface);
|
||||||
|
@ -50,6 +35,7 @@ static HRESULT WINAPI d3drm_light_QueryInterface(IDirect3DRMLight *iface, REFIID
|
||||||
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
||||||
|
|
||||||
if (IsEqualGUID(riid, &IID_IDirect3DRMLight)
|
if (IsEqualGUID(riid, &IID_IDirect3DRMLight)
|
||||||
|
|| IsEqualGUID(riid, &IID_IDirect3DRMObject)
|
||||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||||
{
|
{
|
||||||
IDirect3DRMLight_AddRef(iface);
|
IDirect3DRMLight_AddRef(iface);
|
||||||
|
@ -81,7 +67,11 @@ static ULONG WINAPI d3drm_light_Release(IDirect3DRMLight *iface)
|
||||||
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
||||||
|
|
||||||
if (!refcount)
|
if (!refcount)
|
||||||
|
{
|
||||||
|
d3drm_object_cleanup((IDirect3DRMObject *)iface, &light->obj);
|
||||||
|
IDirect3DRM_Release(light->d3drm);
|
||||||
HeapFree(GetProcessHeap(), 0, light);
|
HeapFree(GetProcessHeap(), 0, light);
|
||||||
|
}
|
||||||
|
|
||||||
return refcount;
|
return refcount;
|
||||||
}
|
}
|
||||||
|
@ -97,17 +87,21 @@ static HRESULT WINAPI d3drm_light_Clone(IDirect3DRMLight *iface,
|
||||||
static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface,
|
static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface,
|
||||||
D3DRMOBJECTCALLBACK cb, void *ctx)
|
D3DRMOBJECTCALLBACK cb, void *ctx)
|
||||||
{
|
{
|
||||||
FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
|
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
|
||||||
|
|
||||||
return E_NOTIMPL;
|
TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
|
||||||
|
|
||||||
|
return d3drm_object_add_destroy_callback(&light->obj, cb, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface,
|
static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface,
|
||||||
D3DRMOBJECTCALLBACK cb, void *ctx)
|
D3DRMOBJECTCALLBACK cb, void *ctx)
|
||||||
{
|
{
|
||||||
FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
|
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
|
||||||
|
|
||||||
return E_NOTIMPL;
|
TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
|
||||||
|
|
||||||
|
return d3drm_object_delete_destroy_callback(&light->obj, cb, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI d3drm_light_SetAppData(IDirect3DRMLight *iface, DWORD data)
|
static HRESULT WINAPI d3drm_light_SetAppData(IDirect3DRMLight *iface, DWORD data)
|
||||||
|
@ -367,22 +361,24 @@ static const struct IDirect3DRMLightVtbl d3drm_light_vtbl =
|
||||||
d3drm_light_GetEnableFrame,
|
d3drm_light_GetEnableFrame,
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT Direct3DRMLight_create(IUnknown **out)
|
HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm)
|
||||||
{
|
{
|
||||||
static const char classname[] = "Light";
|
static const char classname[] = "Light";
|
||||||
struct d3drm_light *object;
|
struct d3drm_light *object;
|
||||||
|
|
||||||
TRACE("out %p.\n", out);
|
TRACE("light %p.\n", light);
|
||||||
|
|
||||||
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
object->IDirect3DRMLight_iface.lpVtbl = &d3drm_light_vtbl;
|
object->IDirect3DRMLight_iface.lpVtbl = &d3drm_light_vtbl;
|
||||||
object->ref = 1;
|
object->ref = 1;
|
||||||
|
object->d3drm = d3drm;
|
||||||
|
IDirect3DRM_AddRef(object->d3drm);
|
||||||
|
|
||||||
d3drm_object_init(&object->obj, classname);
|
d3drm_object_init(&object->obj, classname);
|
||||||
|
|
||||||
*out = (IUnknown *)&object->IDirect3DRMLight_iface;
|
*light = object;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1403,6 +1403,7 @@ static void test_object(void)
|
||||||
{ &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame },
|
{ &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame },
|
||||||
{ &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame2 },
|
{ &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame2 },
|
||||||
{ &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame3 },
|
{ &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame3 },
|
||||||
|
{ &CLSID_CDirect3DRMLight, &IID_IDirect3DRMLight },
|
||||||
};
|
};
|
||||||
IDirect3DRM *d3drm1;
|
IDirect3DRM *d3drm1;
|
||||||
IDirect3DRM2 *d3drm2;
|
IDirect3DRM2 *d3drm2;
|
||||||
|
@ -1427,7 +1428,8 @@ static void test_object(void)
|
||||||
for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
|
for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
|
||||||
{
|
{
|
||||||
BOOL takes_ref = IsEqualGUID(tests[i].clsid, &CLSID_CDirect3DRMMeshBuilder) ||
|
BOOL takes_ref = IsEqualGUID(tests[i].clsid, &CLSID_CDirect3DRMMeshBuilder) ||
|
||||||
IsEqualGUID(tests[i].clsid, &CLSID_CDirect3DRMFrame);
|
IsEqualGUID(tests[i].clsid, &CLSID_CDirect3DRMFrame) ||
|
||||||
|
IsEqualGUID(tests[i].clsid, &CLSID_CDirect3DRMLight);
|
||||||
|
|
||||||
unknown = (IUnknown *)0xdeadbeef;
|
unknown = (IUnknown *)0xdeadbeef;
|
||||||
hr = IDirect3DRM_CreateObject(d3drm1, NULL, NULL, tests[i].iid, (void **)&unknown);
|
hr = IDirect3DRM_CreateObject(d3drm1, NULL, NULL, tests[i].iid, (void **)&unknown);
|
||||||
|
@ -2062,6 +2064,7 @@ static void test_Viewport(void)
|
||||||
|
|
||||||
static void test_Light(void)
|
static void test_Light(void)
|
||||||
{
|
{
|
||||||
|
IDirect3DRMObject *object;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IDirect3DRM *d3drm;
|
IDirect3DRM *d3drm;
|
||||||
IDirect3DRMLight *light;
|
IDirect3DRMLight *light;
|
||||||
|
@ -2074,6 +2077,10 @@ static void test_Light(void)
|
||||||
hr = IDirect3DRM_CreateLightRGB(d3drm, D3DRMLIGHT_SPOT, 0.5, 0.5, 0.5, &light);
|
hr = IDirect3DRM_CreateLightRGB(d3drm, D3DRMLIGHT_SPOT, 0.5, 0.5, 0.5, &light);
|
||||||
ok(hr == D3DRM_OK, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr);
|
ok(hr == D3DRM_OK, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DRMLight_QueryInterface(light, &IID_IDirect3DRMObject, (void **)&object);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, hr %#x.\n", hr);
|
||||||
|
IDirect3DRMObject_Release(object);
|
||||||
|
|
||||||
test_class_name((IDirect3DRMObject *)light, "Light");
|
test_class_name((IDirect3DRMObject *)light, "Light");
|
||||||
|
|
||||||
type = IDirect3DRMLight_GetType(light);
|
type = IDirect3DRMLight_GetType(light);
|
||||||
|
|
Loading…
Reference in New Issue