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 "d3drm_private.h"
23 static inline struct d3drm_light
*impl_from_IDirect3DRMLight(IDirect3DRMLight
*iface
)
25 return CONTAINING_RECORD(iface
, struct d3drm_light
, IDirect3DRMLight_iface
);
28 static HRESULT WINAPI
d3drm_light_QueryInterface(IDirect3DRMLight
*iface
, REFIID riid
, void **out
)
30 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
32 if (IsEqualGUID(riid
, &IID_IDirect3DRMLight
)
33 || IsEqualGUID(riid
, &IID_IDirect3DRMObject
)
34 || IsEqualGUID(riid
, &IID_IUnknown
))
36 IDirect3DRMLight_AddRef(iface
);
41 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
47 static ULONG WINAPI
d3drm_light_AddRef(IDirect3DRMLight
*iface
)
49 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
50 ULONG refcount
= InterlockedIncrement(&light
->ref
);
52 TRACE("%p increasing refcount to %u.\n", iface
, refcount
);
57 static ULONG WINAPI
d3drm_light_Release(IDirect3DRMLight
*iface
)
59 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
60 ULONG refcount
= InterlockedDecrement(&light
->ref
);
62 TRACE("%p decreasing refcount to %u.\n", iface
, refcount
);
66 d3drm_object_cleanup((IDirect3DRMObject
*)iface
, &light
->obj
);
67 IDirect3DRM_Release(light
->d3drm
);
68 HeapFree(GetProcessHeap(), 0, light
);
74 static HRESULT WINAPI
d3drm_light_Clone(IDirect3DRMLight
*iface
,
75 IUnknown
*outer
, REFIID iid
, void **out
)
77 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface
, outer
, debugstr_guid(iid
), out
);
82 static HRESULT WINAPI
d3drm_light_AddDestroyCallback(IDirect3DRMLight
*iface
,
83 D3DRMOBJECTCALLBACK cb
, void *ctx
)
85 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
87 TRACE("iface %p, cb %p, ctx %p.\n", iface
, cb
, ctx
);
89 return d3drm_object_add_destroy_callback(&light
->obj
, cb
, ctx
);
92 static HRESULT WINAPI
d3drm_light_DeleteDestroyCallback(IDirect3DRMLight
*iface
,
93 D3DRMOBJECTCALLBACK cb
, void *ctx
)
95 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
97 TRACE("iface %p, cb %p, ctx %p.\n", iface
, cb
, ctx
);
99 return d3drm_object_delete_destroy_callback(&light
->obj
, cb
, ctx
);
102 static HRESULT WINAPI
d3drm_light_SetAppData(IDirect3DRMLight
*iface
, DWORD data
)
104 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
106 TRACE("iface %p, data %#x.\n", iface
, data
);
108 light
->obj
.appdata
= data
;
113 static DWORD WINAPI
d3drm_light_GetAppData(IDirect3DRMLight
*iface
)
115 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
117 TRACE("iface %p.\n", iface
);
119 return light
->obj
.appdata
;
122 static HRESULT WINAPI
d3drm_light_SetName(IDirect3DRMLight
*iface
, const char *name
)
124 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
126 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
128 return d3drm_object_set_name(&light
->obj
, name
);
131 static HRESULT WINAPI
d3drm_light_GetName(IDirect3DRMLight
*iface
, DWORD
*size
, char *name
)
133 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
135 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
137 return d3drm_object_get_name(&light
->obj
, size
, name
);
140 static HRESULT WINAPI
d3drm_light_GetClassName(IDirect3DRMLight
*iface
, DWORD
*size
, char *name
)
142 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
144 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
146 return d3drm_object_get_class_name(&light
->obj
, size
, name
);
149 static HRESULT WINAPI
d3drm_light_SetType(IDirect3DRMLight
*iface
, D3DRMLIGHTTYPE type
)
151 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
153 TRACE("iface %p, type %#x.\n", iface
, type
);
160 static HRESULT WINAPI
d3drm_light_SetColor(IDirect3DRMLight
*iface
, D3DCOLOR color
)
162 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
164 TRACE("iface %p, color 0x%08x.\n", iface
, color
);
166 light
->color
= color
;
171 static HRESULT WINAPI
d3drm_light_SetColorRGB(IDirect3DRMLight
*iface
,
172 D3DVALUE red
, D3DVALUE green
, D3DVALUE blue
)
174 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
176 TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface
, red
, green
, blue
);
178 d3drm_set_color(&light
->color
, red
, green
, blue
, 1.0f
);
183 static HRESULT WINAPI
d3drm_light_SetRange(IDirect3DRMLight
*iface
, D3DVALUE range
)
185 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
187 TRACE("iface %p, range %.8e.\n", iface
, range
);
189 light
->range
= range
;
194 static HRESULT WINAPI
d3drm_light_SetUmbra(IDirect3DRMLight
*iface
, D3DVALUE umbra
)
196 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
198 TRACE("iface %p, umbra %.8e.\n", iface
, umbra
);
200 light
->umbra
= umbra
;
205 static HRESULT WINAPI
d3drm_light_SetPenumbra(IDirect3DRMLight
*iface
, D3DVALUE penumbra
)
207 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
209 TRACE("iface %p, penumbra %.8e.\n", iface
, penumbra
);
211 light
->penumbra
= penumbra
;
216 static HRESULT WINAPI
d3drm_light_SetConstantAttenuation(IDirect3DRMLight
*iface
, D3DVALUE attenuation
)
218 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
220 TRACE("iface %p, attenuation %.8e.\n", iface
, attenuation
);
222 light
->cattenuation
= attenuation
;
227 static HRESULT WINAPI
d3drm_light_SetLinearAttenuation(IDirect3DRMLight
*iface
, D3DVALUE attenuation
)
229 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
231 TRACE("iface %p, attenuation %.8e.\n", iface
, attenuation
);
233 light
->lattenuation
= attenuation
;
238 static HRESULT WINAPI
d3drm_light_SetQuadraticAttenuation(IDirect3DRMLight
*iface
, D3DVALUE attenuation
)
240 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
242 TRACE("iface %p, attenuation %.8e.\n", iface
, attenuation
);
244 light
->qattenuation
= attenuation
;
249 static D3DVALUE WINAPI
d3drm_light_GetRange(IDirect3DRMLight
*iface
)
251 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
253 TRACE("iface %p.\n", iface
);
258 static D3DVALUE WINAPI
d3drm_light_GetUmbra(IDirect3DRMLight
*iface
)
260 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
262 TRACE("iface %p.\n", light
);
267 static D3DVALUE WINAPI
d3drm_light_GetPenumbra(IDirect3DRMLight
*iface
)
269 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
271 TRACE("iface %p.\n", iface
);
273 return light
->penumbra
;
276 static D3DVALUE WINAPI
d3drm_light_GetConstantAttenuation(IDirect3DRMLight
*iface
)
278 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
280 TRACE("iface %p.\n", iface
);
282 return light
->cattenuation
;
285 static D3DVALUE WINAPI
d3drm_light_GetLinearAttenuation(IDirect3DRMLight
*iface
)
287 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
289 TRACE("iface %p.\n", iface
);
291 return light
->lattenuation
;
294 static D3DVALUE WINAPI
d3drm_light_GetQuadraticAttenuation(IDirect3DRMLight
*iface
)
296 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
298 TRACE("iface %p.\n", iface
);
300 return light
->qattenuation
;
303 static D3DCOLOR WINAPI
d3drm_light_GetColor(IDirect3DRMLight
*iface
)
305 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
307 TRACE("iface %p.\n", iface
);
312 static D3DRMLIGHTTYPE WINAPI
d3drm_light_GetType(IDirect3DRMLight
*iface
)
314 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
316 TRACE("iface %p.\n", iface
);
321 static HRESULT WINAPI
d3drm_light_SetEnableFrame(IDirect3DRMLight
*iface
, IDirect3DRMFrame
*frame
)
323 FIXME("iface %p, frame %p stub!\n", iface
, frame
);
328 static HRESULT WINAPI
d3drm_light_GetEnableFrame(IDirect3DRMLight
*iface
, IDirect3DRMFrame
**frame
)
330 FIXME("iface %p, frame %p stub!\n", iface
, frame
);
335 static const struct IDirect3DRMLightVtbl d3drm_light_vtbl
=
337 d3drm_light_QueryInterface
,
341 d3drm_light_AddDestroyCallback
,
342 d3drm_light_DeleteDestroyCallback
,
343 d3drm_light_SetAppData
,
344 d3drm_light_GetAppData
,
347 d3drm_light_GetClassName
,
349 d3drm_light_SetColor
,
350 d3drm_light_SetColorRGB
,
351 d3drm_light_SetRange
,
352 d3drm_light_SetUmbra
,
353 d3drm_light_SetPenumbra
,
354 d3drm_light_SetConstantAttenuation
,
355 d3drm_light_SetLinearAttenuation
,
356 d3drm_light_SetQuadraticAttenuation
,
357 d3drm_light_GetRange
,
358 d3drm_light_GetUmbra
,
359 d3drm_light_GetPenumbra
,
360 d3drm_light_GetConstantAttenuation
,
361 d3drm_light_GetLinearAttenuation
,
362 d3drm_light_GetQuadraticAttenuation
,
363 d3drm_light_GetColor
,
365 d3drm_light_SetEnableFrame
,
366 d3drm_light_GetEnableFrame
,
369 HRESULT
d3drm_light_create(struct d3drm_light
**light
, IDirect3DRM
*d3drm
)
371 static const char classname
[] = "Light";
372 struct d3drm_light
*object
;
374 TRACE("light %p.\n", light
);
376 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
377 return E_OUTOFMEMORY
;
379 object
->IDirect3DRMLight_iface
.lpVtbl
= &d3drm_light_vtbl
;
381 object
->d3drm
= d3drm
;
382 IDirect3DRM_AddRef(object
->d3drm
);
384 d3drm_object_init(&object
->obj
, classname
);