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
22 #include "wine/port.h"
24 #include "d3drm_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3drm
);
30 IDirect3DRMLight IDirect3DRMLight_iface
;
35 D3DVALUE cattenuation
;
36 D3DVALUE lattenuation
;
37 D3DVALUE qattenuation
;
42 static inline struct d3drm_light
*impl_from_IDirect3DRMLight(IDirect3DRMLight
*iface
)
44 return CONTAINING_RECORD(iface
, struct d3drm_light
, IDirect3DRMLight_iface
);
47 static HRESULT WINAPI
d3drm_light_QueryInterface(IDirect3DRMLight
*iface
, REFIID riid
, void **out
)
49 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
51 if (IsEqualGUID(riid
, &IID_IDirect3DRMLight
)
52 || IsEqualGUID(riid
, &IID_IUnknown
))
54 IDirect3DRMLight_AddRef(iface
);
59 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
65 static ULONG WINAPI
d3drm_light_AddRef(IDirect3DRMLight
*iface
)
67 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
68 ULONG refcount
= InterlockedIncrement(&light
->ref
);
70 TRACE("%p increasing refcount to %u.\n", iface
, refcount
);
75 static ULONG WINAPI
d3drm_light_Release(IDirect3DRMLight
*iface
)
77 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
78 ULONG refcount
= InterlockedDecrement(&light
->ref
);
80 TRACE("%p decreasing refcount to %u.\n", iface
, refcount
);
83 HeapFree(GetProcessHeap(), 0, light
);
88 static HRESULT WINAPI
d3drm_light_Clone(IDirect3DRMLight
*iface
,
89 IUnknown
*outer
, REFIID iid
, void **out
)
91 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface
, outer
, debugstr_guid(iid
), out
);
96 static HRESULT WINAPI
d3drm_light_AddDestroyCallback(IDirect3DRMLight
*iface
,
97 D3DRMOBJECTCALLBACK cb
, void *ctx
)
99 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
104 static HRESULT WINAPI
d3drm_light_DeleteDestroyCallback(IDirect3DRMLight
*iface
,
105 D3DRMOBJECTCALLBACK cb
, void *ctx
)
107 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
112 static HRESULT WINAPI
d3drm_light_SetAppData(IDirect3DRMLight
*iface
, DWORD data
)
114 FIXME("iface %p, data %#x stub!\n", iface
, data
);
119 static DWORD WINAPI
d3drm_light_GetAppData(IDirect3DRMLight
*iface
)
121 FIXME("iface %p stub!\n", iface
);
126 static HRESULT WINAPI
d3drm_light_SetName(IDirect3DRMLight
*iface
, const char *name
)
128 FIXME("iface %p, name %s stub!\n", iface
, debugstr_a(name
));
133 static HRESULT WINAPI
d3drm_light_GetName(IDirect3DRMLight
*iface
, DWORD
*size
, char *name
)
135 FIXME("iface %p, size %p, name %p stub!\n", iface
, size
, name
);
140 static HRESULT WINAPI
d3drm_light_GetClassName(IDirect3DRMLight
*iface
, DWORD
*size
, char *name
)
142 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
144 if (!size
|| *size
< strlen("Light") || !name
)
147 strcpy(name
, "Light");
148 *size
= sizeof("Light");
153 static HRESULT WINAPI
d3drm_light_SetType(IDirect3DRMLight
*iface
, D3DRMLIGHTTYPE type
)
155 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
157 TRACE("iface %p, type %#x.\n", iface
, type
);
164 static HRESULT WINAPI
d3drm_light_SetColor(IDirect3DRMLight
*iface
, D3DCOLOR color
)
166 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
168 TRACE("iface %p, color 0x%08x.\n", iface
, color
);
170 light
->color
= color
;
175 static HRESULT WINAPI
d3drm_light_SetColorRGB(IDirect3DRMLight
*iface
,
176 D3DVALUE red
, D3DVALUE green
, D3DVALUE blue
)
178 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
180 TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface
, red
, green
, blue
);
182 d3drm_set_color(&light
->color
, red
, green
, blue
, 1.0f
);
187 static HRESULT WINAPI
d3drm_light_SetRange(IDirect3DRMLight
*iface
, D3DVALUE range
)
189 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
191 TRACE("iface %p, range %.8e.\n", iface
, range
);
193 light
->range
= range
;
198 static HRESULT WINAPI
d3drm_light_SetUmbra(IDirect3DRMLight
*iface
, D3DVALUE umbra
)
200 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
202 TRACE("iface %p, umbra %.8e.\n", iface
, umbra
);
204 light
->umbra
= umbra
;
209 static HRESULT WINAPI
d3drm_light_SetPenumbra(IDirect3DRMLight
*iface
, D3DVALUE penumbra
)
211 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
213 TRACE("iface %p, penumbra %.8e.\n", iface
, penumbra
);
215 light
->penumbra
= penumbra
;
220 static HRESULT WINAPI
d3drm_light_SetConstantAttenuation(IDirect3DRMLight
*iface
, D3DVALUE attenuation
)
222 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
224 TRACE("iface %p, attenuation %.8e.\n", iface
, attenuation
);
226 light
->cattenuation
= attenuation
;
231 static HRESULT WINAPI
d3drm_light_SetLinearAttenuation(IDirect3DRMLight
*iface
, D3DVALUE attenuation
)
233 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
235 TRACE("iface %p, attenuation %.8e.\n", iface
, attenuation
);
237 light
->lattenuation
= attenuation
;
242 static HRESULT WINAPI
d3drm_light_SetQuadraticAttenuation(IDirect3DRMLight
*iface
, D3DVALUE attenuation
)
244 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
246 TRACE("iface %p, attenuation %.8e.\n", iface
, attenuation
);
248 light
->qattenuation
= attenuation
;
253 static D3DVALUE WINAPI
d3drm_light_GetRange(IDirect3DRMLight
*iface
)
255 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
257 TRACE("iface %p.\n", iface
);
262 static D3DVALUE WINAPI
d3drm_light_GetUmbra(IDirect3DRMLight
*iface
)
264 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
266 TRACE("iface %p.\n", light
);
271 static D3DVALUE WINAPI
d3drm_light_GetPenumbra(IDirect3DRMLight
*iface
)
273 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
275 TRACE("iface %p.\n", iface
);
277 return light
->penumbra
;
280 static D3DVALUE WINAPI
d3drm_light_GetConstantAttenuation(IDirect3DRMLight
*iface
)
282 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
284 TRACE("iface %p.\n", iface
);
286 return light
->cattenuation
;
289 static D3DVALUE WINAPI
d3drm_light_GetLinearAttenuation(IDirect3DRMLight
*iface
)
291 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
293 TRACE("iface %p.\n", iface
);
295 return light
->lattenuation
;
298 static D3DVALUE WINAPI
d3drm_light_GetQuadraticAttenuation(IDirect3DRMLight
*iface
)
300 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
302 TRACE("iface %p.\n", iface
);
304 return light
->qattenuation
;
307 static D3DCOLOR WINAPI
d3drm_light_GetColor(IDirect3DRMLight
*iface
)
309 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
311 TRACE("iface %p.\n", iface
);
316 static D3DRMLIGHTTYPE WINAPI
d3drm_light_GetType(IDirect3DRMLight
*iface
)
318 struct d3drm_light
*light
= impl_from_IDirect3DRMLight(iface
);
320 TRACE("iface %p.\n", iface
);
325 static HRESULT WINAPI
d3drm_light_SetEnableFrame(IDirect3DRMLight
*iface
, IDirect3DRMFrame
*frame
)
327 FIXME("iface %p, frame %p stub!\n", iface
, frame
);
332 static HRESULT WINAPI
d3drm_light_GetEnableFrame(IDirect3DRMLight
*iface
, IDirect3DRMFrame
**frame
)
334 FIXME("iface %p, frame %p stub!\n", iface
, frame
);
339 static const struct IDirect3DRMLightVtbl d3drm_light_vtbl
=
341 d3drm_light_QueryInterface
,
345 d3drm_light_AddDestroyCallback
,
346 d3drm_light_DeleteDestroyCallback
,
347 d3drm_light_SetAppData
,
348 d3drm_light_GetAppData
,
351 d3drm_light_GetClassName
,
353 d3drm_light_SetColor
,
354 d3drm_light_SetColorRGB
,
355 d3drm_light_SetRange
,
356 d3drm_light_SetUmbra
,
357 d3drm_light_SetPenumbra
,
358 d3drm_light_SetConstantAttenuation
,
359 d3drm_light_SetLinearAttenuation
,
360 d3drm_light_SetQuadraticAttenuation
,
361 d3drm_light_GetRange
,
362 d3drm_light_GetUmbra
,
363 d3drm_light_GetPenumbra
,
364 d3drm_light_GetConstantAttenuation
,
365 d3drm_light_GetLinearAttenuation
,
366 d3drm_light_GetQuadraticAttenuation
,
367 d3drm_light_GetColor
,
369 d3drm_light_SetEnableFrame
,
370 d3drm_light_GetEnableFrame
,
373 HRESULT
Direct3DRMLight_create(IUnknown
**out
)
375 struct d3drm_light
*object
;
377 TRACE("out %p.\n", out
);
379 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
380 return E_OUTOFMEMORY
;
382 object
->IDirect3DRMLight_iface
.lpVtbl
= &d3drm_light_vtbl
;
385 *out
= (IUnknown
*)&object
->IDirect3DRMLight_iface
;