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
);
40 IDirect3DRMMaterial2 IDirect3DRMMaterial2_iface
;
46 } IDirect3DRMMaterialImpl
;
48 static inline IDirect3DRMMaterialImpl
*impl_from_IDirect3DRMMaterial2(IDirect3DRMMaterial2
*iface
)
50 return CONTAINING_RECORD(iface
, IDirect3DRMMaterialImpl
, IDirect3DRMMaterial2_iface
);
53 /*** IUnknown methods ***/
54 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_QueryInterface(IDirect3DRMMaterial2
* iface
,
55 REFIID riid
, void** ret_iface
)
57 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
59 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ret_iface
);
61 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
62 IsEqualGUID(riid
, &IID_IDirect3DRMMaterial
) ||
63 IsEqualGUID(riid
, &IID_IDirect3DRMMaterial2
))
65 *ret_iface
= &This
->IDirect3DRMMaterial2_iface
;
70 FIXME("Interface %s not implemented\n", debugstr_guid(riid
));
74 IDirect3DRMMaterial_AddRef(iface
);
79 static ULONG WINAPI
IDirect3DRMMaterial2Impl_AddRef(IDirect3DRMMaterial2
* iface
)
81 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
82 ULONG ref
= InterlockedIncrement(&This
->ref
);
84 TRACE("(%p)->(): new ref = %d\n", iface
, ref
);
89 static ULONG WINAPI
IDirect3DRMMaterial2Impl_Release(IDirect3DRMMaterial2
* iface
)
91 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
92 ULONG ref
= InterlockedDecrement(&This
->ref
);
94 TRACE("(%p)->(): new ref = %d\n", iface
, ref
);
97 HeapFree(GetProcessHeap(), 0, This
);
102 /*** IDirect3DRMObject methods ***/
103 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_Clone(IDirect3DRMMaterial2
*iface
,
104 IUnknown
*outer
, REFIID iid
, void **out
)
106 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface
, outer
, debugstr_guid(iid
), out
);
111 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_AddDestroyCallback(IDirect3DRMMaterial2
*iface
,
112 D3DRMOBJECTCALLBACK cb
, void *ctx
)
114 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
119 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_DeleteDestroyCallback(IDirect3DRMMaterial2
*iface
,
120 D3DRMOBJECTCALLBACK cb
, void *ctx
)
122 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
127 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_SetAppData(IDirect3DRMMaterial2
* iface
,
130 FIXME("(%p)->(%u): stub\n", iface
, data
);
135 static DWORD WINAPI
IDirect3DRMMaterial2Impl_GetAppData(IDirect3DRMMaterial2
* iface
)
137 FIXME("(%p)->(): stub\n", iface
);
142 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_SetName(IDirect3DRMMaterial2
*iface
, const char *name
)
144 FIXME("iface %p, name %s stub!\n", iface
, debugstr_a(name
));
149 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_GetName(IDirect3DRMMaterial2
*iface
, DWORD
*size
, char *name
)
151 FIXME("iface %p, size %p, name %p stub!\n", iface
, size
, name
);
156 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_GetClassName(IDirect3DRMMaterial2
*iface
, DWORD
*size
, char *name
)
158 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
160 if (!size
|| *size
< strlen("Material") || !name
)
163 strcpy(name
, "Material");
164 *size
= sizeof("Material");
169 /*** IDirect3DRMMaterial methods ***/
170 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_SetPower(IDirect3DRMMaterial2
* iface
, D3DVALUE power
)
172 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
174 TRACE("(%p)->(%f)\n", iface
, power
);
181 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_SetSpecular(IDirect3DRMMaterial2
* iface
,
182 D3DVALUE r
, D3DVALUE g
, D3DVALUE b
)
184 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
186 TRACE("(%p)->(%f, %f, %f)\n", iface
, r
, g
, b
);
188 This
->specular
.r
= r
;
189 This
->specular
.g
= g
;
190 This
->specular
.b
= b
;
195 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_SetEmissive(IDirect3DRMMaterial2
* iface
,
196 D3DVALUE r
, D3DVALUE g
, D3DVALUE b
)
198 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
200 TRACE("(%p)->(%f, %f, %f)\n", iface
, r
, g
, b
);
202 This
->emissive
.r
= r
;
203 This
->emissive
.g
= g
;
204 This
->emissive
.b
= b
;
209 static D3DVALUE WINAPI
IDirect3DRMMaterial2Impl_GetPower(IDirect3DRMMaterial2
* iface
)
211 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
213 TRACE("(%p)->()\n", iface
);
218 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_GetSpecular(IDirect3DRMMaterial2
* iface
,
219 D3DVALUE
* r
, D3DVALUE
* g
, D3DVALUE
* b
)
221 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
223 TRACE("(%p)->(%p, %p, %p)\n", iface
, r
, g
, b
);
225 *r
= This
->specular
.r
;
226 *g
= This
->specular
.g
;
227 *b
= This
->specular
.b
;
232 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_GetEmissive(IDirect3DRMMaterial2
* iface
,
233 D3DVALUE
* r
, D3DVALUE
* g
, D3DVALUE
* b
)
235 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
237 TRACE("(%p)->(%p, %p, %p)\n", iface
, r
, g
, b
);
239 *r
= This
->emissive
.r
;
240 *g
= This
->emissive
.g
;
241 *b
= This
->emissive
.b
;
246 /*** IDirect3DRMMaterial2 methods ***/
247 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_GetAmbient(IDirect3DRMMaterial2
* iface
,
248 D3DVALUE
* r
, D3DVALUE
* g
, D3DVALUE
* b
)
250 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
252 TRACE("(%p)->(%p, %p, %p)\n", iface
, r
, g
, b
);
254 *r
= This
->ambient
.r
;
255 *g
= This
->ambient
.g
;
256 *b
= This
->ambient
.b
;
261 static HRESULT WINAPI
IDirect3DRMMaterial2Impl_SetAmbient(IDirect3DRMMaterial2
* iface
,
262 D3DVALUE r
, D3DVALUE g
, D3DVALUE b
)
264 IDirect3DRMMaterialImpl
*This
= impl_from_IDirect3DRMMaterial2(iface
);
266 TRACE("(%p)->(%f, %f, %f)\n", iface
, r
, g
, b
);
275 static const struct IDirect3DRMMaterial2Vtbl Direct3DRMMaterial2_Vtbl
=
277 /*** IUnknown methods ***/
278 IDirect3DRMMaterial2Impl_QueryInterface
,
279 IDirect3DRMMaterial2Impl_AddRef
,
280 IDirect3DRMMaterial2Impl_Release
,
281 /*** IDirect3DRMObject methods ***/
282 IDirect3DRMMaterial2Impl_Clone
,
283 IDirect3DRMMaterial2Impl_AddDestroyCallback
,
284 IDirect3DRMMaterial2Impl_DeleteDestroyCallback
,
285 IDirect3DRMMaterial2Impl_SetAppData
,
286 IDirect3DRMMaterial2Impl_GetAppData
,
287 IDirect3DRMMaterial2Impl_SetName
,
288 IDirect3DRMMaterial2Impl_GetName
,
289 IDirect3DRMMaterial2Impl_GetClassName
,
290 /*** IDirect3DRMMaterial methods ***/
291 IDirect3DRMMaterial2Impl_SetPower
,
292 IDirect3DRMMaterial2Impl_SetSpecular
,
293 IDirect3DRMMaterial2Impl_SetEmissive
,
294 IDirect3DRMMaterial2Impl_GetPower
,
295 IDirect3DRMMaterial2Impl_GetSpecular
,
296 IDirect3DRMMaterial2Impl_GetEmissive
,
297 /*** IDirect3DRMMaterial2 methods ***/
298 IDirect3DRMMaterial2Impl_GetAmbient
,
299 IDirect3DRMMaterial2Impl_SetAmbient
302 HRESULT
Direct3DRMMaterial_create(IDirect3DRMMaterial2
** ret_iface
)
304 IDirect3DRMMaterialImpl
* object
;
306 TRACE("(%p)\n", ret_iface
);
308 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DRMMaterialImpl
));
310 return E_OUTOFMEMORY
;
312 object
->IDirect3DRMMaterial2_iface
.lpVtbl
= &Direct3DRMMaterial2_Vtbl
;
315 object
->specular
.r
= 1.0f
;
316 object
->specular
.g
= 1.0f
;
317 object
->specular
.b
= 1.0f
;
319 *ret_iface
= &object
->IDirect3DRMMaterial2_iface
;