2 * Implementation of IDirect3DRMMaterial2 interface
4 * Copyright 2012 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/debug.h"
28 #include "d3drm_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(d3drm
);
41 IDirect3DRMMaterial2 IDirect3DRMMaterial2_iface
;
43 struct color_rgb emissive
;
44 struct color_rgb specular
;
46 struct color_rgb ambient
;
49 static inline struct d3drm_material
*impl_from_IDirect3DRMMaterial2(IDirect3DRMMaterial2
*iface
)
51 return CONTAINING_RECORD(iface
, struct d3drm_material
, IDirect3DRMMaterial2_iface
);
54 static HRESULT WINAPI
d3drm_material_QueryInterface(IDirect3DRMMaterial2
*iface
, REFIID riid
, void **out
)
56 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
58 if (IsEqualGUID(riid
, &IID_IDirect3DRMMaterial2
)
59 || IsEqualGUID(riid
, &IID_IDirect3DRMMaterial
)
60 || IsEqualGUID(riid
, &IID_IUnknown
))
62 IDirect3DRMMaterial2_AddRef(iface
);
67 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
73 static ULONG WINAPI
d3drm_material_AddRef(IDirect3DRMMaterial2
*iface
)
75 struct d3drm_material
*material
= impl_from_IDirect3DRMMaterial2(iface
);
76 ULONG refcount
= InterlockedIncrement(&material
->ref
);
78 TRACE("%p increasing refcount to %u.\n", iface
, refcount
);
83 static ULONG WINAPI
d3drm_material_Release(IDirect3DRMMaterial2
*iface
)
85 struct d3drm_material
*material
= impl_from_IDirect3DRMMaterial2(iface
);
86 ULONG refcount
= InterlockedDecrement(&material
->ref
);
88 TRACE("%p decreasing refcount to %u.\n", iface
, refcount
);
91 HeapFree(GetProcessHeap(), 0, material
);
96 static HRESULT WINAPI
d3drm_material_Clone(IDirect3DRMMaterial2
*iface
,
97 IUnknown
*outer
, REFIID iid
, void **out
)
99 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface
, outer
, debugstr_guid(iid
), out
);
104 static HRESULT WINAPI
d3drm_material_AddDestroyCallback(IDirect3DRMMaterial2
*iface
,
105 D3DRMOBJECTCALLBACK cb
, void *ctx
)
107 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
112 static HRESULT WINAPI
d3drm_material_DeleteDestroyCallback(IDirect3DRMMaterial2
*iface
,
113 D3DRMOBJECTCALLBACK cb
, void *ctx
)
115 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
120 static HRESULT WINAPI
d3drm_material_SetAppData(IDirect3DRMMaterial2
*iface
, DWORD data
)
122 FIXME("iface %p, data %#x stub!\n", iface
, data
);
127 static DWORD WINAPI
d3drm_material_GetAppData(IDirect3DRMMaterial2
*iface
)
129 FIXME("iface %p stub!\n", iface
);
134 static HRESULT WINAPI
d3drm_material_SetName(IDirect3DRMMaterial2
*iface
, const char *name
)
136 FIXME("iface %p, name %s stub!\n", iface
, debugstr_a(name
));
141 static HRESULT WINAPI
d3drm_material_GetName(IDirect3DRMMaterial2
*iface
, DWORD
*size
, char *name
)
143 FIXME("iface %p, size %p, name %p stub!\n", iface
, size
, name
);
148 static HRESULT WINAPI
d3drm_material_GetClassName(IDirect3DRMMaterial2
*iface
, DWORD
*size
, char *name
)
150 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
152 if (!size
|| *size
< strlen("Material") || !name
)
155 strcpy(name
, "Material");
156 *size
= sizeof("Material");
161 static HRESULT WINAPI
d3drm_material_SetPower(IDirect3DRMMaterial2
*iface
, D3DVALUE power
)
163 struct d3drm_material
*material
= impl_from_IDirect3DRMMaterial2(iface
);
165 TRACE("iface %p, power %.8e.\n", iface
, power
);
167 material
->power
= power
;
172 static HRESULT WINAPI
d3drm_material_SetSpecular(IDirect3DRMMaterial2
*iface
,
173 D3DVALUE r
, D3DVALUE g
, D3DVALUE b
)
175 struct d3drm_material
*material
= impl_from_IDirect3DRMMaterial2(iface
);
177 TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface
, r
, g
, b
);
179 material
->specular
.r
= r
;
180 material
->specular
.g
= g
;
181 material
->specular
.b
= b
;
186 static HRESULT WINAPI
d3drm_material_SetEmissive(IDirect3DRMMaterial2
*iface
,
187 D3DVALUE r
, D3DVALUE g
, D3DVALUE b
)
189 struct d3drm_material
*material
= impl_from_IDirect3DRMMaterial2(iface
);
191 TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface
, r
, g
, b
);
193 material
->emissive
.r
= r
;
194 material
->emissive
.g
= g
;
195 material
->emissive
.b
= b
;
200 static D3DVALUE WINAPI
d3drm_material_GetPower(IDirect3DRMMaterial2
*iface
)
202 struct d3drm_material
*material
= impl_from_IDirect3DRMMaterial2(iface
);
204 TRACE("iface %p.\n", iface
);
206 return material
->power
;
209 static HRESULT WINAPI
d3drm_material_GetSpecular(IDirect3DRMMaterial2
*iface
,
210 D3DVALUE
*r
, D3DVALUE
*g
, D3DVALUE
*b
)
212 struct d3drm_material
*material
= impl_from_IDirect3DRMMaterial2(iface
);
214 TRACE("iface %p, r %p, g %p, b %p.\n", iface
, r
, g
, b
);
216 *r
= material
->specular
.r
;
217 *g
= material
->specular
.g
;
218 *b
= material
->specular
.b
;
223 static HRESULT WINAPI
d3drm_material_GetEmissive(IDirect3DRMMaterial2
*iface
,
224 D3DVALUE
*r
, D3DVALUE
*g
, D3DVALUE
*b
)
226 struct d3drm_material
*material
= impl_from_IDirect3DRMMaterial2(iface
);
228 TRACE("iface %p, r %p, g %p, b %p.\n", iface
, r
, g
, b
);
230 *r
= material
->emissive
.r
;
231 *g
= material
->emissive
.g
;
232 *b
= material
->emissive
.b
;
237 static HRESULT WINAPI
d3drm_material_GetAmbient(IDirect3DRMMaterial2
*iface
,
238 D3DVALUE
*r
, D3DVALUE
*g
, D3DVALUE
*b
)
240 struct d3drm_material
*material
= impl_from_IDirect3DRMMaterial2(iface
);
242 TRACE("iface %p, r %p, g %p, b %p.\n", iface
, r
, g
, b
);
244 *r
= material
->ambient
.r
;
245 *g
= material
->ambient
.g
;
246 *b
= material
->ambient
.b
;
251 static HRESULT WINAPI
d3drm_material_SetAmbient(IDirect3DRMMaterial2
*iface
,
252 D3DVALUE r
, D3DVALUE g
, D3DVALUE b
)
254 struct d3drm_material
*material
= impl_from_IDirect3DRMMaterial2(iface
);
256 TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface
, r
, g
, b
);
258 material
->ambient
.r
= r
;
259 material
->ambient
.g
= g
;
260 material
->ambient
.b
= b
;
265 static const struct IDirect3DRMMaterial2Vtbl d3drm_material_vtbl
=
267 d3drm_material_QueryInterface
,
268 d3drm_material_AddRef
,
269 d3drm_material_Release
,
270 d3drm_material_Clone
,
271 d3drm_material_AddDestroyCallback
,
272 d3drm_material_DeleteDestroyCallback
,
273 d3drm_material_SetAppData
,
274 d3drm_material_GetAppData
,
275 d3drm_material_SetName
,
276 d3drm_material_GetName
,
277 d3drm_material_GetClassName
,
278 d3drm_material_SetPower
,
279 d3drm_material_SetSpecular
,
280 d3drm_material_SetEmissive
,
281 d3drm_material_GetPower
,
282 d3drm_material_GetSpecular
,
283 d3drm_material_GetEmissive
,
284 d3drm_material_GetAmbient
,
285 d3drm_material_SetAmbient
,
288 HRESULT
Direct3DRMMaterial_create(IDirect3DRMMaterial2
**out
)
290 struct d3drm_material
*object
;
292 TRACE("out %p.\n", out
);
294 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
295 return E_OUTOFMEMORY
;
297 object
->IDirect3DRMMaterial2_iface
.lpVtbl
= &d3drm_material_vtbl
;
300 object
->specular
.r
= 1.0f
;
301 object
->specular
.g
= 1.0f
;
302 object
->specular
.b
= 1.0f
;
304 *out
= &object
->IDirect3DRMMaterial2_iface
;