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 LPUNKNOWN unknown, REFIID riid,
107 FIXME("(%p)->(%p, %s, %p): stub\n", iface, unknown, debugstr_guid(riid), object);
112 static HRESULT WINAPI IDirect3DRMMaterial2Impl_AddDestroyCallback(IDirect3DRMMaterial2* iface,
113 D3DRMOBJECTCALLBACK cb,
116 FIXME("(%p)->(%p, %p): stub\n", iface, cb, argument);
121 static HRESULT WINAPI IDirect3DRMMaterial2Impl_DeleteDestroyCallback(IDirect3DRMMaterial2* iface,
122 D3DRMOBJECTCALLBACK cb,
125 FIXME("(%p)->(%p, %p): stub\n", iface, cb, argument);
130 static HRESULT WINAPI IDirect3DRMMaterial2Impl_SetAppData(IDirect3DRMMaterial2* iface,
133 FIXME("(%p)->(%u): stub\n", iface, data);
138 static DWORD WINAPI IDirect3DRMMaterial2Impl_GetAppData(IDirect3DRMMaterial2* iface)
140 FIXME("(%p)->(): stub\n", iface);
145 static HRESULT WINAPI IDirect3DRMMaterial2Impl_SetName(IDirect3DRMMaterial2* iface, LPCSTR name)
147 FIXME("(%p)->(%s): stub\n", iface, name);
152 static HRESULT WINAPI IDirect3DRMMaterial2Impl_GetName(IDirect3DRMMaterial2* iface,
153 LPDWORD size, LPSTR name)
155 FIXME("(%p)->(%p, %p): stub\n", iface, size, name);
160 static HRESULT WINAPI IDirect3DRMMaterial2Impl_GetClassName(IDirect3DRMMaterial2* iface,
161 LPDWORD size, LPSTR name)
163 TRACE("(%p)->(%p, %p)\n", iface, size, name);
165 if (!size || *size < strlen("Material") || !name)
168 strcpy(name, "Material");
169 *size = sizeof("Material");
174 /*** IDirect3DRMMaterial methods ***/
175 static HRESULT WINAPI IDirect3DRMMaterial2Impl_SetPower(IDirect3DRMMaterial2* iface, D3DVALUE power)
177 IDirect3DRMMaterialImpl *This = impl_from_IDirect3DRMMaterial2(iface);
179 TRACE("(%p)->(%f)\n", iface, power);
186 static HRESULT WINAPI IDirect3DRMMaterial2Impl_SetSpecular(IDirect3DRMMaterial2* iface,
187 D3DVALUE r, D3DVALUE g, D3DVALUE b)
189 IDirect3DRMMaterialImpl *This = impl_from_IDirect3DRMMaterial2(iface);
191 TRACE("(%p)->(%f, %f, %f)\n", iface, r, g, b);
193 This->specular.r = r;
194 This->specular.g = g;
195 This->specular.b = b;
200 static HRESULT WINAPI IDirect3DRMMaterial2Impl_SetEmissive(IDirect3DRMMaterial2* iface,
201 D3DVALUE r, D3DVALUE g, D3DVALUE b)
203 IDirect3DRMMaterialImpl *This = impl_from_IDirect3DRMMaterial2(iface);
205 TRACE("(%p)->(%f, %f, %f)\n", iface, r, g, b);
207 This->emissive.r = r;
208 This->emissive.g = g;
209 This->emissive.b = b;
214 static D3DVALUE WINAPI IDirect3DRMMaterial2Impl_GetPower(IDirect3DRMMaterial2* iface)
216 IDirect3DRMMaterialImpl *This = impl_from_IDirect3DRMMaterial2(iface);
218 TRACE("(%p)->()\n", iface);
223 static HRESULT WINAPI IDirect3DRMMaterial2Impl_GetSpecular(IDirect3DRMMaterial2* iface,
224 D3DVALUE* r, D3DVALUE* g, D3DVALUE* b)
226 IDirect3DRMMaterialImpl *This = impl_from_IDirect3DRMMaterial2(iface);
228 TRACE("(%p)->(%p, %p, %p)\n", iface, r, g, b);
230 *r = This->specular.r;
231 *g = This->specular.g;
232 *b = This->specular.b;
237 static HRESULT WINAPI IDirect3DRMMaterial2Impl_GetEmissive(IDirect3DRMMaterial2* iface,
238 D3DVALUE* r, D3DVALUE* g, D3DVALUE* b)
240 IDirect3DRMMaterialImpl *This = impl_from_IDirect3DRMMaterial2(iface);
242 TRACE("(%p)->(%p, %p, %p)\n", iface, r, g, b);
244 *r = This->emissive.r;
245 *g = This->emissive.g;
246 *b = This->emissive.b;
251 /*** IDirect3DRMMaterial2 methods ***/
252 static HRESULT WINAPI IDirect3DRMMaterial2Impl_GetAmbient(IDirect3DRMMaterial2* iface,
253 D3DVALUE* r, D3DVALUE* g, D3DVALUE* b)
255 IDirect3DRMMaterialImpl *This = impl_from_IDirect3DRMMaterial2(iface);
257 TRACE("(%p)->(%p, %p, %p)\n", iface, r, g, b);
259 *r = This->ambient.r;
260 *g = This->ambient.g;
261 *b = This->ambient.b;
266 static HRESULT WINAPI IDirect3DRMMaterial2Impl_SetAmbient(IDirect3DRMMaterial2* iface,
267 D3DVALUE r, D3DVALUE g, D3DVALUE b)
269 IDirect3DRMMaterialImpl *This = impl_from_IDirect3DRMMaterial2(iface);
271 TRACE("(%p)->(%f, %f, %f)\n", iface, r, g, b);
280 static const struct IDirect3DRMMaterial2Vtbl Direct3DRMMaterial2_Vtbl =
282 /*** IUnknown methods ***/
283 IDirect3DRMMaterial2Impl_QueryInterface,
284 IDirect3DRMMaterial2Impl_AddRef,
285 IDirect3DRMMaterial2Impl_Release,
286 /*** IDirect3DRMObject methods ***/
287 IDirect3DRMMaterial2Impl_Clone,
288 IDirect3DRMMaterial2Impl_AddDestroyCallback,
289 IDirect3DRMMaterial2Impl_DeleteDestroyCallback,
290 IDirect3DRMMaterial2Impl_SetAppData,
291 IDirect3DRMMaterial2Impl_GetAppData,
292 IDirect3DRMMaterial2Impl_SetName,
293 IDirect3DRMMaterial2Impl_GetName,
294 IDirect3DRMMaterial2Impl_GetClassName,
295 /*** IDirect3DRMMaterial methods ***/
296 IDirect3DRMMaterial2Impl_SetPower,
297 IDirect3DRMMaterial2Impl_SetSpecular,
298 IDirect3DRMMaterial2Impl_SetEmissive,
299 IDirect3DRMMaterial2Impl_GetPower,
300 IDirect3DRMMaterial2Impl_GetSpecular,
301 IDirect3DRMMaterial2Impl_GetEmissive,
302 /*** IDirect3DRMMaterial2 methods ***/
303 IDirect3DRMMaterial2Impl_GetAmbient,
304 IDirect3DRMMaterial2Impl_SetAmbient
307 HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2** ret_iface)
309 IDirect3DRMMaterialImpl* object;
311 TRACE("(%p)\n", ret_iface);
313 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMaterialImpl));
316 ERR("Out of memory\n");
317 return E_OUTOFMEMORY;
320 object->IDirect3DRMMaterial2_iface.lpVtbl = &Direct3DRMMaterial2_Vtbl;
323 object->specular.r = 1.0f;
324 object->specular.g = 1.0f;
325 object->specular.b = 1.0f;
327 *ret_iface = &object->IDirect3DRMMaterial2_iface;