From 735e69f94e8fe8b7f357b1b4b5e12b0437f69ba7 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 29 May 2013 09:45:39 +0200 Subject: [PATCH] d3drm: Avoid LPDIRECT3DRMMATERIAL2. --- dlls/d3drm/d3drm.c | 15 ++++++--------- dlls/d3drm/frame.c | 14 ++++---------- dlls/d3drm/meshbuilder.c | 14 +++++++------- dlls/d3drm/tests/d3drm.c | 38 +++++++++++++++++++------------------- include/d3drm.h | 2 +- include/d3drmobj.h | 10 +++++----- 6 files changed, 42 insertions(+), 51 deletions(-) diff --git a/dlls/d3drm/d3drm.c b/dlls/d3drm/d3drm.c index 567464737e3..cd65847794c 100644 --- a/dlls/d3drm/d3drm.c +++ b/dlls/d3drm/d3drm.c @@ -997,20 +997,17 @@ static HRESULT WINAPI IDirect3DRM3Impl_CreateLightRGB(IDirect3DRM3 *iface, D3DRM return hr; } -static HRESULT WINAPI IDirect3DRM3Impl_CreateMaterial(IDirect3DRM3* iface, D3DVALUE power, - LPDIRECT3DRMMATERIAL2* material) +static HRESULT WINAPI IDirect3DRM3Impl_CreateMaterial(IDirect3DRM3 *iface, + D3DVALUE power, IDirect3DRMMaterial2 **material) { - IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface); - HRESULT ret; + HRESULT hr; - TRACE("(%p/%p)->(%f,%p)\n", iface, This, power, material); + TRACE("iface %p, power %.8e, material %p.\n", iface, power, material); - ret = Direct3DRMMaterial_create(material); - - if (SUCCEEDED(ret)) + if (SUCCEEDED(hr = Direct3DRMMaterial_create(material))) IDirect3DRMMaterial2_SetPower(*material, power); - return ret; + return hr; } static HRESULT WINAPI IDirect3DRM3Impl_CreateDevice(IDirect3DRM3 *iface, diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c index 87330cd5167..35d5643151c 100644 --- a/dlls/d3drm/frame.c +++ b/dlls/d3drm/frame.c @@ -2280,12 +2280,9 @@ static HRESULT WINAPI IDirect3DRMFrame3Impl_GetAxes(IDirect3DRMFrame3 *iface, D3 return E_NOTIMPL; } -static HRESULT WINAPI IDirect3DRMFrame3Impl_GetMaterial(IDirect3DRMFrame3* iface, - LPDIRECT3DRMMATERIAL2 *material) +static HRESULT WINAPI IDirect3DRMFrame3Impl_GetMaterial(IDirect3DRMFrame3 *iface, IDirect3DRMMaterial2 **material) { - IDirect3DRMFrameImpl *This = impl_from_IDirect3DRMFrame3(iface); - - FIXME("(%p/%p)->(%p): stub\n", iface, This, material); + FIXME("iface %p, material %p stub!\n", iface, material); return E_NOTIMPL; } @@ -2347,12 +2344,9 @@ static HRESULT WINAPI IDirect3DRMFrame3Impl_SetInheritAxes(IDirect3DRMFrame3* if return E_NOTIMPL; } -static HRESULT WINAPI IDirect3DRMFrame3Impl_SetMaterial(IDirect3DRMFrame3* iface, - LPDIRECT3DRMMATERIAL2 material) +static HRESULT WINAPI IDirect3DRMFrame3Impl_SetMaterial(IDirect3DRMFrame3 *iface, IDirect3DRMMaterial2 *material) { - IDirect3DRMFrameImpl *This = impl_from_IDirect3DRMFrame3(iface); - - FIXME("(%p/%p)->(%p): stub\n", iface, This, material); + FIXME("iface %p, material %p stub!\n", iface, material); return E_NOTIMPL; } diff --git a/dlls/d3drm/meshbuilder.c b/dlls/d3drm/meshbuilder.c index e60bc077150..42a5a7e659f 100644 --- a/dlls/d3drm/meshbuilder.c +++ b/dlls/d3drm/meshbuilder.c @@ -1832,18 +1832,18 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuil return D3DRM_OK; } -static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3* iface, - LPDIRECT3DRMMATERIAL2 material) +static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3 *iface, + IDirect3DRMMaterial2 *material) { - IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface); + IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface); - TRACE("(%p)->(%p)\n", This, material); + TRACE("iface %p, material %p.\n", iface, material); if (material) IDirect3DRMTexture2_AddRef(material); - if (This->material) - IDirect3DRMTexture2_Release(This->material); - This->material = material; + if (mesh_builder->material) + IDirect3DRMTexture2_Release(mesh_builder->material); + mesh_builder->material = material; return D3DRM_OK; } diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 754b25eebd6..e1b6cfe408c 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1356,7 +1356,7 @@ static void test_Material2(void) HRESULT hr; IDirect3DRM *d3drm; IDirect3DRM3 *d3drm3; - LPDIRECT3DRMMATERIAL2 pMaterial2; + IDirect3DRMMaterial2 *material2; D3DVALUE r, g, b; DWORD size; CHAR cname[64] = {0}; @@ -1371,61 +1371,61 @@ static void test_Material2(void) return; } - hr = IDirect3DRM3_CreateMaterial(d3drm3, 18.5f, &pMaterial2); + hr = IDirect3DRM3_CreateMaterial(d3drm3, 18.5f, &material2); ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMaterial2 interface (hr = %x)\n", hr); - hr = IDirect3DRMMaterial2_GetClassName(pMaterial2, NULL, cname); + hr = IDirect3DRMMaterial2_GetClassName(material2, NULL, cname); ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); - hr = IDirect3DRMMaterial2_GetClassName(pMaterial2, NULL, NULL); + hr = IDirect3DRMMaterial2_GetClassName(material2, NULL, NULL); ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); size = 1; - hr = IDirect3DRMMaterial2_GetClassName(pMaterial2, &size, cname); + hr = IDirect3DRMMaterial2_GetClassName(material2, &size, cname); ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr); size = sizeof(cname); - hr = IDirect3DRMMaterial2_GetClassName(pMaterial2, &size, cname); + hr = IDirect3DRMMaterial2_GetClassName(material2, &size, cname); ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr); ok(size == sizeof("Material"), "wrong size: %u\n", size); ok(!strcmp(cname, "Material"), "Expected cname to be \"Material\", but got \"%s\"\n", cname); - r = IDirect3DRMMaterial2_GetPower(pMaterial2); + r = IDirect3DRMMaterial2_GetPower(material2); ok(r == 18.5f, "wrong power (%f)\n", r); - hr = IDirect3DRMMaterial2_GetEmissive(pMaterial2, &r, &g, &b); + hr = IDirect3DRMMaterial2_GetEmissive(material2, &r, &g, &b); ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr); ok(r == 0.0f && g == 0.0f && b == 0.0f, "wrong emissive r=%f g=%f b=%f, expected r=0.0 g=0.0 b=0.0\n", r, g, b); - hr = IDirect3DRMMaterial2_GetSpecular(pMaterial2, &r, &g, &b); + hr = IDirect3DRMMaterial2_GetSpecular(material2, &r, &g, &b); ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr); ok(r == 1.0f && g == 1.0f && b == 1.0f, "wrong specular r=%f g=%f b=%f, expected r=1.0 g=1.0 b=1.0\n", r, g, b); - hr = IDirect3DRMMaterial2_GetAmbient(pMaterial2, &r, &g, &b); + hr = IDirect3DRMMaterial2_GetAmbient(material2, &r, &g, &b); ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr); ok(r == 0.0f && g == 0.0f && b == 0.0f, "wrong ambient r=%f g=%f b=%f, expected r=0.0 g=0.0 b=0.0\n", r, g, b); - hr = IDirect3DRMMaterial2_SetPower(pMaterial2, 5.87f); + hr = IDirect3DRMMaterial2_SetPower(material2, 5.87f); ok(hr == D3DRM_OK, "Cannot set power (hr = %x)\n", hr); - r = IDirect3DRMMaterial2_GetPower(pMaterial2); + r = IDirect3DRMMaterial2_GetPower(material2); ok(r == 5.87f, "wrong power (%f)\n", r); - hr = IDirect3DRMMaterial2_SetEmissive(pMaterial2, 0.5f, 0.5f, 0.5f); + hr = IDirect3DRMMaterial2_SetEmissive(material2, 0.5f, 0.5f, 0.5f); ok(hr == D3DRM_OK, "Cannot set emissive (hr = %x)\n", hr); - hr = IDirect3DRMMaterial2_GetEmissive(pMaterial2, &r, &g, &b); + hr = IDirect3DRMMaterial2_GetEmissive(material2, &r, &g, &b); ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr); ok(r == 0.5f && g == 0.5f && b == 0.5f, "wrong emissive r=%f g=%f b=%f, expected r=0.5 g=0.5 b=0.5\n", r, g, b); - hr = IDirect3DRMMaterial2_SetSpecular(pMaterial2, 0.6f, 0.6f, 0.6f); + hr = IDirect3DRMMaterial2_SetSpecular(material2, 0.6f, 0.6f, 0.6f); ok(hr == D3DRM_OK, "Cannot set specular (hr = %x)\n", hr); - hr = IDirect3DRMMaterial2_GetSpecular(pMaterial2, &r, &g, &b); + hr = IDirect3DRMMaterial2_GetSpecular(material2, &r, &g, &b); ok(hr == D3DRM_OK, "Cannot get specular (hr = %x)\n", hr); ok(r == 0.6f && g == 0.6f && b == 0.6f, "wrong specular r=%f g=%f b=%f, expected r=0.6 g=0.6 b=0.6\n", r, g, b); - hr = IDirect3DRMMaterial2_SetAmbient(pMaterial2, 0.7f, 0.7f, 0.7f); + hr = IDirect3DRMMaterial2_SetAmbient(material2, 0.7f, 0.7f, 0.7f); ok(hr == D3DRM_OK, "Cannot set ambient (hr = %x)\n", hr); - hr = IDirect3DRMMaterial2_GetAmbient(pMaterial2, &r, &g, &b); + hr = IDirect3DRMMaterial2_GetAmbient(material2, &r, &g, &b); ok(hr == D3DRM_OK, "Cannot get ambient (hr = %x)\n", hr); ok(r == 0.7f && g == 0.7f && b == 0.7f, "wrong ambient r=%f g=%f b=%f, expected r=0.7 g=0.7 b=0.7\n", r, g, b); - IDirect3DRMMaterial2_Release(pMaterial2); + IDirect3DRMMaterial2_Release(material2); IDirect3DRM3_Release(d3drm3); IDirect3DRM_Release(d3drm); diff --git a/include/d3drm.h b/include/d3drm.h index 4b105db0ff6..24c2dbc73ec 100644 --- a/include/d3drm.h +++ b/include/d3drm.h @@ -350,7 +350,7 @@ DECLARE_INTERFACE_(IDirect3DRM3,IUnknown) STDMETHOD(CreateLight)(THIS_ D3DRMLIGHTTYPE type, D3DCOLOR color, IDirect3DRMLight **light) PURE; STDMETHOD(CreateLightRGB)(THIS_ D3DRMLIGHTTYPE type, D3DVALUE r, D3DVALUE g, D3DVALUE b, IDirect3DRMLight **light) PURE; - STDMETHOD(CreateMaterial)(THIS_ D3DVALUE, LPDIRECT3DRMMATERIAL2 *) PURE; + STDMETHOD(CreateMaterial)(THIS_ D3DVALUE, IDirect3DRMMaterial2 **material) PURE; STDMETHOD(CreateDevice)(THIS_ DWORD width, DWORD height, IDirect3DRMDevice3 **device) PURE; STDMETHOD(CreateDeviceFromSurface)(THIS_ GUID *guid, IDirectDraw *ddraw, IDirectDrawSurface *surface, IDirect3DRMDevice3 **device) PURE; diff --git a/include/d3drmobj.h b/include/d3drmobj.h index 800fd842e51..52f2b2970ab 100644 --- a/include/d3drmobj.h +++ b/include/d3drmobj.h @@ -1676,14 +1676,14 @@ DECLARE_INTERFACE_(IDirect3DRMFrame3,IDirect3DRMVisual) STDMETHOD(GetBox)(THIS_ D3DRMBOX *box) PURE; STDMETHOD_(BOOL, GetBoxEnable)(THIS) PURE; STDMETHOD(GetAxes)(THIS_ D3DVECTOR *dir, D3DVECTOR *up); - STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2 *) PURE; + STDMETHOD(GetMaterial)(THIS_ struct IDirect3DRMMaterial2 **material) PURE; STDMETHOD_(BOOL, GetInheritAxes)(THIS); STDMETHOD(GetHierarchyBox)(THIS_ D3DRMBOX *box) PURE; STDMETHOD(SetBox)(THIS_ D3DRMBOX *box) PURE; STDMETHOD(SetBoxEnable)(THIS_ BOOL) PURE; STDMETHOD(SetAxes)(THIS_ D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux, D3DVALUE uy, D3DVALUE uz); STDMETHOD(SetInheritAxes)(THIS_ BOOL inherit_from_parent); - STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE; + STDMETHOD(SetMaterial)(THIS_ struct IDirect3DRMMaterial2 *material) PURE; STDMETHOD(SetQuaternion)(THIS_ IDirect3DRMFrame3 *reference, D3DRMQUATERNION *q) PURE; STDMETHOD(RayPick)(THIS_ IDirect3DRMFrame3 *reference, D3DRMRAY *ray, DWORD flags, struct IDirect3DRMPicked2Array **return_visuals) PURE; @@ -2397,7 +2397,7 @@ DECLARE_INTERFACE_(IDirect3DRMFace2,IDirect3DRMObject) STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; STDMETHOD(SetTexture)(THIS_ struct IDirect3DRMTexture3 *texture) PURE; STDMETHOD(SetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE u, D3DVALUE v) PURE; - STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE; + STDMETHOD(SetMaterial)(THIS_ struct IDirect3DRMMaterial2 *material) PURE; STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; STDMETHOD(GetVertex)(THIS_ DWORD index, D3DVECTOR *vertex, D3DVECTOR *normal) PURE; STDMETHOD(GetVertices)(THIS_ DWORD *vertex_count, D3DVECTOR *coords, D3DVECTOR *normals); @@ -2405,7 +2405,7 @@ DECLARE_INTERFACE_(IDirect3DRMFace2,IDirect3DRMObject) STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE; STDMETHOD(GetNormal)(THIS_ D3DVECTOR *) PURE; STDMETHOD(GetTexture)(THIS_ struct IDirect3DRMTexture3 **texture) PURE; - STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2 *) PURE; + STDMETHOD(GetMaterial)(THIS_ struct IDirect3DRMMaterial2 **material) PURE; STDMETHOD_(int, GetVertexCount)(THIS) PURE; STDMETHOD_(int, GetVertexIndex)(THIS_ DWORD which) PURE; STDMETHOD_(int, GetTextureCoordinateIndex)(THIS_ DWORD which) PURE; @@ -2870,7 +2870,7 @@ DECLARE_INTERFACE_(IDirect3DRMMeshBuilder3,IDirect3DRMVisual) STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE; STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE; STDMETHOD(SetTexture)(THIS_ struct IDirect3DRMTexture3 *texture) PURE; - STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE; + STDMETHOD(SetMaterial)(THIS_ struct IDirect3DRMMaterial2 *material) PURE; STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE; STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE; STDMETHOD(SetPerspective)(THIS_ BOOL) PURE;