[D3DRM] Sync with Wine Staging 2.16. CORE-13762
[reactos.git] / reactos / dll / directx / wine / d3drm / light.c
1 /*
2 * Implementation of IDirect3DRMLight Interface
3 *
4 * Copyright 2012 André Hentschel
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #include "d3drm_private.h"
22
23 static inline struct d3drm_light *impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
24 {
25 return CONTAINING_RECORD(iface, struct d3drm_light, IDirect3DRMLight_iface);
26 }
27
28 static HRESULT WINAPI d3drm_light_QueryInterface(IDirect3DRMLight *iface, REFIID riid, void **out)
29 {
30 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
31
32 if (IsEqualGUID(riid, &IID_IDirect3DRMLight)
33 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
34 || IsEqualGUID(riid, &IID_IUnknown))
35 {
36 IDirect3DRMLight_AddRef(iface);
37 *out = iface;
38 return S_OK;
39 }
40
41 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
42
43 *out = NULL;
44 return E_NOINTERFACE;
45 }
46
47 static ULONG WINAPI d3drm_light_AddRef(IDirect3DRMLight *iface)
48 {
49 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
50 ULONG refcount = InterlockedIncrement(&light->ref);
51
52 TRACE("%p increasing refcount to %u.\n", iface, refcount);
53
54 return refcount;
55 }
56
57 static ULONG WINAPI d3drm_light_Release(IDirect3DRMLight *iface)
58 {
59 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
60 ULONG refcount = InterlockedDecrement(&light->ref);
61
62 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
63
64 if (!refcount)
65 {
66 d3drm_object_cleanup((IDirect3DRMObject *)iface, &light->obj);
67 IDirect3DRM_Release(light->d3drm);
68 HeapFree(GetProcessHeap(), 0, light);
69 }
70
71 return refcount;
72 }
73
74 static HRESULT WINAPI d3drm_light_Clone(IDirect3DRMLight *iface,
75 IUnknown *outer, REFIID iid, void **out)
76 {
77 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
78
79 return E_NOTIMPL;
80 }
81
82 static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface,
83 D3DRMOBJECTCALLBACK cb, void *ctx)
84 {
85 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
86
87 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
88
89 return d3drm_object_add_destroy_callback(&light->obj, cb, ctx);
90 }
91
92 static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface,
93 D3DRMOBJECTCALLBACK cb, void *ctx)
94 {
95 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
96
97 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
98
99 return d3drm_object_delete_destroy_callback(&light->obj, cb, ctx);
100 }
101
102 static HRESULT WINAPI d3drm_light_SetAppData(IDirect3DRMLight *iface, DWORD data)
103 {
104 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
105
106 TRACE("iface %p, data %#x.\n", iface, data);
107
108 light->obj.appdata = data;
109
110 return D3DRM_OK;
111 }
112
113 static DWORD WINAPI d3drm_light_GetAppData(IDirect3DRMLight *iface)
114 {
115 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
116
117 TRACE("iface %p.\n", iface);
118
119 return light->obj.appdata;
120 }
121
122 static HRESULT WINAPI d3drm_light_SetName(IDirect3DRMLight *iface, const char *name)
123 {
124 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
125
126 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
127
128 return d3drm_object_set_name(&light->obj, name);
129 }
130
131 static HRESULT WINAPI d3drm_light_GetName(IDirect3DRMLight *iface, DWORD *size, char *name)
132 {
133 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
134
135 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
136
137 return d3drm_object_get_name(&light->obj, size, name);
138 }
139
140 static HRESULT WINAPI d3drm_light_GetClassName(IDirect3DRMLight *iface, DWORD *size, char *name)
141 {
142 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
143
144 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
145
146 return d3drm_object_get_class_name(&light->obj, size, name);
147 }
148
149 static HRESULT WINAPI d3drm_light_SetType(IDirect3DRMLight *iface, D3DRMLIGHTTYPE type)
150 {
151 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
152
153 TRACE("iface %p, type %#x.\n", iface, type);
154
155 light->type = type;
156
157 return D3DRM_OK;
158 }
159
160 static HRESULT WINAPI d3drm_light_SetColor(IDirect3DRMLight *iface, D3DCOLOR color)
161 {
162 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
163
164 TRACE("iface %p, color 0x%08x.\n", iface, color);
165
166 light->color = color;
167
168 return D3DRM_OK;
169 }
170
171 static HRESULT WINAPI d3drm_light_SetColorRGB(IDirect3DRMLight *iface,
172 D3DVALUE red, D3DVALUE green, D3DVALUE blue)
173 {
174 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
175
176 TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
177
178 d3drm_set_color(&light->color, red, green, blue, 1.0f);
179
180 return D3DRM_OK;
181 }
182
183 static HRESULT WINAPI d3drm_light_SetRange(IDirect3DRMLight *iface, D3DVALUE range)
184 {
185 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
186
187 TRACE("iface %p, range %.8e.\n", iface, range);
188
189 light->range = range;
190
191 return D3DRM_OK;
192 }
193
194 static HRESULT WINAPI d3drm_light_SetUmbra(IDirect3DRMLight *iface, D3DVALUE umbra)
195 {
196 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
197
198 TRACE("iface %p, umbra %.8e.\n", iface, umbra);
199
200 light->umbra = umbra;
201
202 return D3DRM_OK;
203 }
204
205 static HRESULT WINAPI d3drm_light_SetPenumbra(IDirect3DRMLight *iface, D3DVALUE penumbra)
206 {
207 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
208
209 TRACE("iface %p, penumbra %.8e.\n", iface, penumbra);
210
211 light->penumbra = penumbra;
212
213 return D3DRM_OK;
214 }
215
216 static HRESULT WINAPI d3drm_light_SetConstantAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
217 {
218 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
219
220 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
221
222 light->cattenuation = attenuation;
223
224 return D3DRM_OK;
225 }
226
227 static HRESULT WINAPI d3drm_light_SetLinearAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
228 {
229 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
230
231 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
232
233 light->lattenuation = attenuation;
234
235 return D3DRM_OK;
236 }
237
238 static HRESULT WINAPI d3drm_light_SetQuadraticAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
239 {
240 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
241
242 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
243
244 light->qattenuation = attenuation;
245
246 return D3DRM_OK;
247 }
248
249 static D3DVALUE WINAPI d3drm_light_GetRange(IDirect3DRMLight *iface)
250 {
251 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
252
253 TRACE("iface %p.\n", iface);
254
255 return light->range;
256 }
257
258 static D3DVALUE WINAPI d3drm_light_GetUmbra(IDirect3DRMLight *iface)
259 {
260 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
261
262 TRACE("iface %p.\n", light);
263
264 return light->umbra;
265 }
266
267 static D3DVALUE WINAPI d3drm_light_GetPenumbra(IDirect3DRMLight *iface)
268 {
269 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
270
271 TRACE("iface %p.\n", iface);
272
273 return light->penumbra;
274 }
275
276 static D3DVALUE WINAPI d3drm_light_GetConstantAttenuation(IDirect3DRMLight *iface)
277 {
278 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
279
280 TRACE("iface %p.\n", iface);
281
282 return light->cattenuation;
283 }
284
285 static D3DVALUE WINAPI d3drm_light_GetLinearAttenuation(IDirect3DRMLight *iface)
286 {
287 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
288
289 TRACE("iface %p.\n", iface);
290
291 return light->lattenuation;
292 }
293
294 static D3DVALUE WINAPI d3drm_light_GetQuadraticAttenuation(IDirect3DRMLight *iface)
295 {
296 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
297
298 TRACE("iface %p.\n", iface);
299
300 return light->qattenuation;
301 }
302
303 static D3DCOLOR WINAPI d3drm_light_GetColor(IDirect3DRMLight *iface)
304 {
305 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
306
307 TRACE("iface %p.\n", iface);
308
309 return light->color;
310 }
311
312 static D3DRMLIGHTTYPE WINAPI d3drm_light_GetType(IDirect3DRMLight *iface)
313 {
314 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
315
316 TRACE("iface %p.\n", iface);
317
318 return light->type;
319 }
320
321 static HRESULT WINAPI d3drm_light_SetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame *frame)
322 {
323 FIXME("iface %p, frame %p stub!\n", iface, frame);
324
325 return E_NOTIMPL;
326 }
327
328 static HRESULT WINAPI d3drm_light_GetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame **frame)
329 {
330 FIXME("iface %p, frame %p stub!\n", iface, frame);
331
332 return E_NOTIMPL;
333 }
334
335 static const struct IDirect3DRMLightVtbl d3drm_light_vtbl =
336 {
337 d3drm_light_QueryInterface,
338 d3drm_light_AddRef,
339 d3drm_light_Release,
340 d3drm_light_Clone,
341 d3drm_light_AddDestroyCallback,
342 d3drm_light_DeleteDestroyCallback,
343 d3drm_light_SetAppData,
344 d3drm_light_GetAppData,
345 d3drm_light_SetName,
346 d3drm_light_GetName,
347 d3drm_light_GetClassName,
348 d3drm_light_SetType,
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,
364 d3drm_light_GetType,
365 d3drm_light_SetEnableFrame,
366 d3drm_light_GetEnableFrame,
367 };
368
369 HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm)
370 {
371 static const char classname[] = "Light";
372 struct d3drm_light *object;
373
374 TRACE("light %p.\n", light);
375
376 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
377 return E_OUTOFMEMORY;
378
379 object->IDirect3DRMLight_iface.lpVtbl = &d3drm_light_vtbl;
380 object->ref = 1;
381 object->d3drm = d3drm;
382 IDirect3DRM_AddRef(object->d3drm);
383
384 d3drm_object_init(&object->obj, classname);
385
386 *light = object;
387
388 return S_OK;
389 }