d3drm: Implement object name property.
[wine.git] / dlls / d3drm / light.c
blobf7d259ce8474b29a0aa80d41fd80be024809b989
1 /*
2 * Implementation of IDirect3DRMLight Interface
4 * Copyright 2012 André Hentschel
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 "config.h"
22 #include "wine/port.h"
24 #include "d3drm_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
28 static inline struct d3drm_light *impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
30 return CONTAINING_RECORD(iface, struct d3drm_light, IDirect3DRMLight_iface);
33 static HRESULT WINAPI d3drm_light_QueryInterface(IDirect3DRMLight *iface, REFIID riid, void **out)
35 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
37 if (IsEqualGUID(riid, &IID_IDirect3DRMLight)
38 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
39 || IsEqualGUID(riid, &IID_IUnknown))
41 IDirect3DRMLight_AddRef(iface);
42 *out = iface;
43 return S_OK;
46 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
48 *out = NULL;
49 return E_NOINTERFACE;
52 static ULONG WINAPI d3drm_light_AddRef(IDirect3DRMLight *iface)
54 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
55 ULONG refcount = InterlockedIncrement(&light->ref);
57 TRACE("%p increasing refcount to %u.\n", iface, refcount);
59 return refcount;
62 static ULONG WINAPI d3drm_light_Release(IDirect3DRMLight *iface)
64 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
65 ULONG refcount = InterlockedDecrement(&light->ref);
67 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
69 if (!refcount)
71 d3drm_object_cleanup((IDirect3DRMObject *)iface, &light->obj);
72 IDirect3DRM_Release(light->d3drm);
73 HeapFree(GetProcessHeap(), 0, light);
76 return refcount;
79 static HRESULT WINAPI d3drm_light_Clone(IDirect3DRMLight *iface,
80 IUnknown *outer, REFIID iid, void **out)
82 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
84 return E_NOTIMPL;
87 static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface,
88 D3DRMOBJECTCALLBACK cb, void *ctx)
90 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
92 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
94 return d3drm_object_add_destroy_callback(&light->obj, cb, ctx);
97 static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface,
98 D3DRMOBJECTCALLBACK cb, void *ctx)
100 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
102 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
104 return d3drm_object_delete_destroy_callback(&light->obj, cb, ctx);
107 static HRESULT WINAPI d3drm_light_SetAppData(IDirect3DRMLight *iface, DWORD data)
109 FIXME("iface %p, data %#x stub!\n", iface, data);
111 return E_NOTIMPL;
114 static DWORD WINAPI d3drm_light_GetAppData(IDirect3DRMLight *iface)
116 FIXME("iface %p stub!\n", iface);
118 return 0;
121 static HRESULT WINAPI d3drm_light_SetName(IDirect3DRMLight *iface, const char *name)
123 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
125 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
127 return d3drm_object_set_name(&light->obj, name);
130 static HRESULT WINAPI d3drm_light_GetName(IDirect3DRMLight *iface, DWORD *size, char *name)
132 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
134 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
136 return d3drm_object_get_name(&light->obj, size, name);
139 static HRESULT WINAPI d3drm_light_GetClassName(IDirect3DRMLight *iface, DWORD *size, char *name)
141 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
143 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
145 return d3drm_object_get_class_name(&light->obj, size, name);
148 static HRESULT WINAPI d3drm_light_SetType(IDirect3DRMLight *iface, D3DRMLIGHTTYPE type)
150 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
152 TRACE("iface %p, type %#x.\n", iface, type);
154 light->type = type;
156 return D3DRM_OK;
159 static HRESULT WINAPI d3drm_light_SetColor(IDirect3DRMLight *iface, D3DCOLOR color)
161 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
163 TRACE("iface %p, color 0x%08x.\n", iface, color);
165 light->color = color;
167 return D3DRM_OK;
170 static HRESULT WINAPI d3drm_light_SetColorRGB(IDirect3DRMLight *iface,
171 D3DVALUE red, D3DVALUE green, D3DVALUE blue)
173 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
175 TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
177 d3drm_set_color(&light->color, red, green, blue, 1.0f);
179 return D3DRM_OK;
182 static HRESULT WINAPI d3drm_light_SetRange(IDirect3DRMLight *iface, D3DVALUE range)
184 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
186 TRACE("iface %p, range %.8e.\n", iface, range);
188 light->range = range;
190 return D3DRM_OK;
193 static HRESULT WINAPI d3drm_light_SetUmbra(IDirect3DRMLight *iface, D3DVALUE umbra)
195 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
197 TRACE("iface %p, umbra %.8e.\n", iface, umbra);
199 light->umbra = umbra;
201 return D3DRM_OK;
204 static HRESULT WINAPI d3drm_light_SetPenumbra(IDirect3DRMLight *iface, D3DVALUE penumbra)
206 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
208 TRACE("iface %p, penumbra %.8e.\n", iface, penumbra);
210 light->penumbra = penumbra;
212 return D3DRM_OK;
215 static HRESULT WINAPI d3drm_light_SetConstantAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
217 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
219 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
221 light->cattenuation = attenuation;
223 return D3DRM_OK;
226 static HRESULT WINAPI d3drm_light_SetLinearAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
228 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
230 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
232 light->lattenuation = attenuation;
234 return D3DRM_OK;
237 static HRESULT WINAPI d3drm_light_SetQuadraticAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
239 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
241 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
243 light->qattenuation = attenuation;
245 return D3DRM_OK;
248 static D3DVALUE WINAPI d3drm_light_GetRange(IDirect3DRMLight *iface)
250 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
252 TRACE("iface %p.\n", iface);
254 return light->range;
257 static D3DVALUE WINAPI d3drm_light_GetUmbra(IDirect3DRMLight *iface)
259 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
261 TRACE("iface %p.\n", light);
263 return light->umbra;
266 static D3DVALUE WINAPI d3drm_light_GetPenumbra(IDirect3DRMLight *iface)
268 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
270 TRACE("iface %p.\n", iface);
272 return light->penumbra;
275 static D3DVALUE WINAPI d3drm_light_GetConstantAttenuation(IDirect3DRMLight *iface)
277 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
279 TRACE("iface %p.\n", iface);
281 return light->cattenuation;
284 static D3DVALUE WINAPI d3drm_light_GetLinearAttenuation(IDirect3DRMLight *iface)
286 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
288 TRACE("iface %p.\n", iface);
290 return light->lattenuation;
293 static D3DVALUE WINAPI d3drm_light_GetQuadraticAttenuation(IDirect3DRMLight *iface)
295 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
297 TRACE("iface %p.\n", iface);
299 return light->qattenuation;
302 static D3DCOLOR WINAPI d3drm_light_GetColor(IDirect3DRMLight *iface)
304 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
306 TRACE("iface %p.\n", iface);
308 return light->color;
311 static D3DRMLIGHTTYPE WINAPI d3drm_light_GetType(IDirect3DRMLight *iface)
313 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
315 TRACE("iface %p.\n", iface);
317 return light->type;
320 static HRESULT WINAPI d3drm_light_SetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame *frame)
322 FIXME("iface %p, frame %p stub!\n", iface, frame);
324 return E_NOTIMPL;
327 static HRESULT WINAPI d3drm_light_GetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame **frame)
329 FIXME("iface %p, frame %p stub!\n", iface, frame);
331 return E_NOTIMPL;
334 static const struct IDirect3DRMLightVtbl d3drm_light_vtbl =
336 d3drm_light_QueryInterface,
337 d3drm_light_AddRef,
338 d3drm_light_Release,
339 d3drm_light_Clone,
340 d3drm_light_AddDestroyCallback,
341 d3drm_light_DeleteDestroyCallback,
342 d3drm_light_SetAppData,
343 d3drm_light_GetAppData,
344 d3drm_light_SetName,
345 d3drm_light_GetName,
346 d3drm_light_GetClassName,
347 d3drm_light_SetType,
348 d3drm_light_SetColor,
349 d3drm_light_SetColorRGB,
350 d3drm_light_SetRange,
351 d3drm_light_SetUmbra,
352 d3drm_light_SetPenumbra,
353 d3drm_light_SetConstantAttenuation,
354 d3drm_light_SetLinearAttenuation,
355 d3drm_light_SetQuadraticAttenuation,
356 d3drm_light_GetRange,
357 d3drm_light_GetUmbra,
358 d3drm_light_GetPenumbra,
359 d3drm_light_GetConstantAttenuation,
360 d3drm_light_GetLinearAttenuation,
361 d3drm_light_GetQuadraticAttenuation,
362 d3drm_light_GetColor,
363 d3drm_light_GetType,
364 d3drm_light_SetEnableFrame,
365 d3drm_light_GetEnableFrame,
368 HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm)
370 static const char classname[] = "Light";
371 struct d3drm_light *object;
373 TRACE("light %p.\n", light);
375 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
376 return E_OUTOFMEMORY;
378 object->IDirect3DRMLight_iface.lpVtbl = &d3drm_light_vtbl;
379 object->ref = 1;
380 object->d3drm = d3drm;
381 IDirect3DRM_AddRef(object->d3drm);
383 d3drm_object_init(&object->obj, classname);
385 *light = object;
387 return S_OK;