ReactOS 0.4.16-dev-197-g92996da
light.c
Go to the documentation of this file.
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
24
25static inline struct d3drm_light *impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
26{
28}
29
30static HRESULT WINAPI d3drm_light_QueryInterface(IDirect3DRMLight *iface, REFIID riid, void **out)
31{
32 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
33
34 if (IsEqualGUID(riid, &IID_IDirect3DRMLight)
35 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
37 {
39 *out = iface;
40 return S_OK;
41 }
42
43 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
44
45 *out = NULL;
46 return E_NOINTERFACE;
47}
48
49static ULONG WINAPI d3drm_light_AddRef(IDirect3DRMLight *iface)
50{
52 ULONG refcount = InterlockedIncrement(&light->ref);
53
54 TRACE("%p increasing refcount to %u.\n", iface, refcount);
55
56 return refcount;
57}
58
59static ULONG WINAPI d3drm_light_Release(IDirect3DRMLight *iface)
60{
62 ULONG refcount = InterlockedDecrement(&light->ref);
63
64 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
65
66 if (!refcount)
67 {
68 d3drm_object_cleanup((IDirect3DRMObject *)iface, &light->obj);
71 }
72
73 return refcount;
74}
75
76static HRESULT WINAPI d3drm_light_Clone(IDirect3DRMLight *iface,
77 IUnknown *outer, REFIID iid, void **out)
78{
79 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
80
81 return E_NOTIMPL;
82}
83
84static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface,
86{
88
89 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
90
92}
93
94static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface,
96{
98
99 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
100
102}
103
104static HRESULT WINAPI d3drm_light_SetAppData(IDirect3DRMLight *iface, DWORD data)
105{
107
108 TRACE("iface %p, data %#x.\n", iface, data);
109
110 light->obj.appdata = data;
111
112 return D3DRM_OK;
113}
114
115static DWORD WINAPI d3drm_light_GetAppData(IDirect3DRMLight *iface)
116{
118
119 TRACE("iface %p.\n", iface);
120
121 return light->obj.appdata;
122}
123
124static HRESULT WINAPI d3drm_light_SetName(IDirect3DRMLight *iface, const char *name)
125{
127
128 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
129
130 return d3drm_object_set_name(&light->obj, name);
131}
132
133static HRESULT WINAPI d3drm_light_GetName(IDirect3DRMLight *iface, DWORD *size, char *name)
134{
136
137 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
138
139 return d3drm_object_get_name(&light->obj, size, name);
140}
141
142static HRESULT WINAPI d3drm_light_GetClassName(IDirect3DRMLight *iface, DWORD *size, char *name)
143{
145
146 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
147
149}
150
151static HRESULT WINAPI d3drm_light_SetType(IDirect3DRMLight *iface, D3DRMLIGHTTYPE type)
152{
154
155 TRACE("iface %p, type %#x.\n", iface, type);
156
157 light->type = type;
158
159 return D3DRM_OK;
160}
161
162static HRESULT WINAPI d3drm_light_SetColor(IDirect3DRMLight *iface, D3DCOLOR color)
163{
165
166 TRACE("iface %p, color 0x%08x.\n", iface, color);
167
168 light->color = color;
169
170 return D3DRM_OK;
171}
172
173static HRESULT WINAPI d3drm_light_SetColorRGB(IDirect3DRMLight *iface,
175{
177
178 TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
179
180 d3drm_set_color(&light->color, red, green, blue, 1.0f);
181
182 return D3DRM_OK;
183}
184
185static HRESULT WINAPI d3drm_light_SetRange(IDirect3DRMLight *iface, D3DVALUE range)
186{
188
189 TRACE("iface %p, range %.8e.\n", iface, range);
190
191 light->range = range;
192
193 return D3DRM_OK;
194}
195
196static HRESULT WINAPI d3drm_light_SetUmbra(IDirect3DRMLight *iface, D3DVALUE umbra)
197{
199
200 TRACE("iface %p, umbra %.8e.\n", iface, umbra);
201
202 light->umbra = umbra;
203
204 return D3DRM_OK;
205}
206
208{
210
211 TRACE("iface %p, penumbra %.8e.\n", iface, penumbra);
212
213 light->penumbra = penumbra;
214
215 return D3DRM_OK;
216}
217
218static HRESULT WINAPI d3drm_light_SetConstantAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
219{
221
222 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
223
224 light->cattenuation = attenuation;
225
226 return D3DRM_OK;
227}
228
229static HRESULT WINAPI d3drm_light_SetLinearAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
230{
232
233 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
234
235 light->lattenuation = attenuation;
236
237 return D3DRM_OK;
238}
239
240static HRESULT WINAPI d3drm_light_SetQuadraticAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
241{
243
244 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
245
246 light->qattenuation = attenuation;
247
248 return D3DRM_OK;
249}
250
251static D3DVALUE WINAPI d3drm_light_GetRange(IDirect3DRMLight *iface)
252{
254
255 TRACE("iface %p.\n", iface);
256
257 return light->range;
258}
259
260static D3DVALUE WINAPI d3drm_light_GetUmbra(IDirect3DRMLight *iface)
261{
263
264 TRACE("iface %p.\n", light);
265
266 return light->umbra;
267}
268
269static D3DVALUE WINAPI d3drm_light_GetPenumbra(IDirect3DRMLight *iface)
270{
272
273 TRACE("iface %p.\n", iface);
274
275 return light->penumbra;
276}
277
279{
281
282 TRACE("iface %p.\n", iface);
283
284 return light->cattenuation;
285}
286
287static D3DVALUE WINAPI d3drm_light_GetLinearAttenuation(IDirect3DRMLight *iface)
288{
290
291 TRACE("iface %p.\n", iface);
292
293 return light->lattenuation;
294}
295
297{
299
300 TRACE("iface %p.\n", iface);
301
302 return light->qattenuation;
303}
304
305static D3DCOLOR WINAPI d3drm_light_GetColor(IDirect3DRMLight *iface)
306{
308
309 TRACE("iface %p.\n", iface);
310
311 return light->color;
312}
313
314static D3DRMLIGHTTYPE WINAPI d3drm_light_GetType(IDirect3DRMLight *iface)
315{
317
318 TRACE("iface %p.\n", iface);
319
320 return light->type;
321}
322
323static HRESULT WINAPI d3drm_light_SetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame *frame)
324{
325 FIXME("iface %p, frame %p stub!\n", iface, frame);
326
327 return E_NOTIMPL;
328}
329
330static HRESULT WINAPI d3drm_light_GetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame **frame)
331{
332 FIXME("iface %p, frame %p stub!\n", iface, frame);
333
334 return E_NOTIMPL;
335}
336
337static const struct IDirect3DRMLightVtbl d3drm_light_vtbl =
338{
369};
370
372{
373 static const char classname[] = "Light";
374 struct d3drm_light *object;
375
376 TRACE("light %p.\n", light);
377
378 if (!(object = heap_alloc_zero(sizeof(*object))))
379 return E_OUTOFMEMORY;
380
381 object->IDirect3DRMLight_iface.lpVtbl = &d3drm_light_vtbl;
382 object->ref = 1;
383 object->d3drm = d3drm;
385
387
388 *light = object;
389
390 return S_OK;
391}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
#define D3DRM_OK
Definition: d3drm.h:486
#define IDirect3DRM_Release(p)
Definition: d3drm.h:111
#define IDirect3DRM_AddRef(p)
Definition: d3drm.h:110
void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object)
Definition: d3drm_main.c:153
void d3drm_object_init(struct d3drm_object *object, const char *classname)
Definition: d3drm_main.c:39
HRESULT d3drm_object_get_name(struct d3drm_object *object, DWORD *size, char *name)
Definition: d3drm_main.c:111
HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx)
Definition: d3drm_main.c:72
HRESULT d3drm_object_add_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx)
Definition: d3drm_main.c:55
HRESULT d3drm_object_set_name(struct d3drm_object *object, const char *name)
Definition: d3drm_main.c:135
HRESULT d3drm_object_get_class_name(struct d3drm_object *object, DWORD *size, char *name)
Definition: d3drm_main.c:92
static void d3drm_set_color(D3DCOLOR *color, float r, float g, float b, float a)
enum _D3DRMLIGHTTYPE D3DRMLIGHTTYPE
#define IDirect3DRMLight_AddRef(p)
Definition: d3drmobj.h:3119
void(__cdecl * D3DRMOBJECTCALLBACK)(struct IDirect3DRMObject *obj, void *arg)
Definition: d3drmobj.h:157
float D3DVALUE
Definition: d3dtypes.h:89
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
static HRESULT WINAPI d3drm_light_SetQuadraticAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
Definition: light.c:240
static HRESULT WINAPI d3drm_light_Clone(IDirect3DRMLight *iface, IUnknown *outer, REFIID iid, void **out)
Definition: light.c:76
static D3DVALUE WINAPI d3drm_light_GetRange(IDirect3DRMLight *iface)
Definition: light.c:251
static HRESULT WINAPI d3drm_light_SetAppData(IDirect3DRMLight *iface, DWORD data)
Definition: light.c:104
static HRESULT WINAPI d3drm_light_SetPenumbra(IDirect3DRMLight *iface, D3DVALUE penumbra)
Definition: light.c:207
static struct d3drm_light * impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
Definition: light.c:25
static HRESULT WINAPI d3drm_light_GetClassName(IDirect3DRMLight *iface, DWORD *size, char *name)
Definition: light.c:142
static const struct IDirect3DRMLightVtbl d3drm_light_vtbl
Definition: light.c:337
HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm)
Definition: light.c:371
static D3DVALUE WINAPI d3drm_light_GetQuadraticAttenuation(IDirect3DRMLight *iface)
Definition: light.c:296
static HRESULT WINAPI d3drm_light_SetName(IDirect3DRMLight *iface, const char *name)
Definition: light.c:124
static ULONG WINAPI d3drm_light_Release(IDirect3DRMLight *iface)
Definition: light.c:59
static HRESULT WINAPI d3drm_light_QueryInterface(IDirect3DRMLight *iface, REFIID riid, void **out)
Definition: light.c:30
static ULONG WINAPI d3drm_light_AddRef(IDirect3DRMLight *iface)
Definition: light.c:49
static D3DVALUE WINAPI d3drm_light_GetPenumbra(IDirect3DRMLight *iface)
Definition: light.c:269
static HRESULT WINAPI d3drm_light_SetColor(IDirect3DRMLight *iface, D3DCOLOR color)
Definition: light.c:162
static HRESULT WINAPI d3drm_light_SetUmbra(IDirect3DRMLight *iface, D3DVALUE umbra)
Definition: light.c:196
static HRESULT WINAPI d3drm_light_GetName(IDirect3DRMLight *iface, DWORD *size, char *name)
Definition: light.c:133
static HRESULT WINAPI d3drm_light_SetLinearAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
Definition: light.c:229
static HRESULT WINAPI d3drm_light_SetType(IDirect3DRMLight *iface, D3DRMLIGHTTYPE type)
Definition: light.c:151
static D3DVALUE WINAPI d3drm_light_GetUmbra(IDirect3DRMLight *iface)
Definition: light.c:260
static D3DRMLIGHTTYPE WINAPI d3drm_light_GetType(IDirect3DRMLight *iface)
Definition: light.c:314
static DWORD WINAPI d3drm_light_GetAppData(IDirect3DRMLight *iface)
Definition: light.c:115
static D3DVALUE WINAPI d3drm_light_GetConstantAttenuation(IDirect3DRMLight *iface)
Definition: light.c:278
static HRESULT WINAPI d3drm_light_GetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame **frame)
Definition: light.c:330
static D3DCOLOR WINAPI d3drm_light_GetColor(IDirect3DRMLight *iface)
Definition: light.c:305
static HRESULT WINAPI d3drm_light_SetColorRGB(IDirect3DRMLight *iface, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
Definition: light.c:173
static HRESULT WINAPI d3drm_light_SetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame *frame)
Definition: light.c:323
static HRESULT WINAPI d3drm_light_SetConstantAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
Definition: light.c:218
static D3DVALUE WINAPI d3drm_light_GetLinearAttenuation(IDirect3DRMLight *iface)
Definition: light.c:287
static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface, D3DRMOBJECTCALLBACK cb, void *ctx)
Definition: light.c:94
static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface, D3DRMOBJECTCALLBACK cb, void *ctx)
Definition: light.c:84
static HRESULT WINAPI d3drm_light_SetRange(IDirect3DRMLight *iface, D3DVALUE range)
Definition: light.c:185
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
GLclampf green
Definition: gl.h:1740
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLclampf GLclampf blue
Definition: gl.h:1740
GLsizeiptr size
Definition: glext.h:5919
GLuint color
Definition: glext.h:6243
GLenum GLint * range
Definition: glext.h:7539
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum light
Definition: glfuncs.h:170
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_a
Definition: kernel32.h:31
#define red
Definition: linetest.c:67
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
static FILE * out
Definition: regtests2xml.c:44
WCHAR classname[128]
Definition: startup.c:15
#define TRACE(s)
Definition: solgame.cpp:4
IDirect3DRM * d3drm
IDirect3DRMLight IDirect3DRMLight_iface
D3DVALUE penumbra
D3DVALUE umbra
Definition: d3drm.c:189
Definition: name.c:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364