ReactOS  0.4.14-dev-342-gdc047f9
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 
25 static inline struct d3drm_light *impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
26 {
28 }
29 
30 static 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 
49 static 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 
59 static 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);
69  IDirect3DRM_Release(light->d3drm);
71  }
72 
73  return refcount;
74 }
75 
76 static 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 
84 static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface,
85  D3DRMOBJECTCALLBACK cb, void *ctx)
86 {
88 
89  TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
90 
91  return d3drm_object_add_destroy_callback(&light->obj, cb, ctx);
92 }
93 
94 static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface,
95  D3DRMOBJECTCALLBACK cb, void *ctx)
96 {
98 
99  TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
100 
101  return d3drm_object_delete_destroy_callback(&light->obj, cb, ctx);
102 }
103 
104 static 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 
115 static DWORD WINAPI d3drm_light_GetAppData(IDirect3DRMLight *iface)
116 {
118 
119  TRACE("iface %p.\n", iface);
120 
121  return light->obj.appdata;
122 }
123 
124 static 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 
133 static 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 
142 static 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 
148  return d3drm_object_get_class_name(&light->obj, size, name);
149 }
150 
151 static 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 
162 static 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 
173 static 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 
185 static 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 
196 static 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 
207 static HRESULT WINAPI d3drm_light_SetPenumbra(IDirect3DRMLight *iface, D3DVALUE penumbra)
208 {
210 
211  TRACE("iface %p, penumbra %.8e.\n", iface, penumbra);
212 
213  light->penumbra = penumbra;
214 
215  return D3DRM_OK;
216 }
217 
218 static 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 
229 static 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 
240 static 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 
251 static D3DVALUE WINAPI d3drm_light_GetRange(IDirect3DRMLight *iface)
252 {
254 
255  TRACE("iface %p.\n", iface);
256 
257  return light->range;
258 }
259 
260 static D3DVALUE WINAPI d3drm_light_GetUmbra(IDirect3DRMLight *iface)
261 {
263 
264  TRACE("iface %p.\n", light);
265 
266  return light->umbra;
267 }
268 
269 static D3DVALUE WINAPI d3drm_light_GetPenumbra(IDirect3DRMLight *iface)
270 {
272 
273  TRACE("iface %p.\n", iface);
274 
275  return light->penumbra;
276 }
277 
278 static D3DVALUE WINAPI d3drm_light_GetConstantAttenuation(IDirect3DRMLight *iface)
279 {
281 
282  TRACE("iface %p.\n", iface);
283 
284  return light->cattenuation;
285 }
286 
287 static D3DVALUE WINAPI d3drm_light_GetLinearAttenuation(IDirect3DRMLight *iface)
288 {
290 
291  TRACE("iface %p.\n", iface);
292 
293  return light->lattenuation;
294 }
295 
296 static D3DVALUE WINAPI d3drm_light_GetQuadraticAttenuation(IDirect3DRMLight *iface)
297 {
299 
300  TRACE("iface %p.\n", iface);
301 
302  return light->qattenuation;
303 }
304 
305 static D3DCOLOR WINAPI d3drm_light_GetColor(IDirect3DRMLight *iface)
306 {
308 
309  TRACE("iface %p.\n", iface);
310 
311  return light->color;
312 }
313 
314 static D3DRMLIGHTTYPE WINAPI d3drm_light_GetType(IDirect3DRMLight *iface)
315 {
317 
318  TRACE("iface %p.\n", iface);
319 
320  return light->type;
321 }
322 
323 static 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 
330 static 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 
337 static 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;
384  IDirect3DRM_AddRef(object->d3drm);
385 
387 
388  *light = object;
389 
390  return S_OK;
391 }
void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object)
Definition: d3drm_main.c:153
static HRESULT WINAPI d3drm_light_SetRange(IDirect3DRMLight *iface, D3DVALUE range)
Definition: light.c:185
#define REFIID
Definition: guiddef.h:118
static HRESULT WINAPI d3drm_light_SetName(IDirect3DRMLight *iface, const char *name)
Definition: light.c:124
static D3DCOLOR WINAPI d3drm_light_GetColor(IDirect3DRMLight *iface)
Definition: light.c:305
static D3DRMLIGHTTYPE WINAPI d3drm_light_GetType(IDirect3DRMLight *iface)
Definition: light.c:314
#define E_NOINTERFACE
Definition: winerror.h:2364
static HRESULT WINAPI d3drm_light_GetClassName(IDirect3DRMLight *iface, DWORD *size, char *name)
Definition: light.c:142
IDirect3DRMLight IDirect3DRMLight_iface
static HRESULT WINAPI d3drm_light_SetConstantAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
Definition: light.c:218
static HRESULT WINAPI d3drm_light_GetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame **frame)
Definition: light.c:330
static D3DVALUE WINAPI d3drm_light_GetRange(IDirect3DRMLight *iface)
Definition: light.c:251
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:111
static HRESULT WINAPI d3drm_light_SetType(IDirect3DRMLight *iface, D3DRMLIGHTTYPE type)
Definition: light.c:151
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
HRESULT d3drm_object_add_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx)
Definition: d3drm_main.c:55
static struct d3drm_light * impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
Definition: light.c:25
WCHAR classname[128]
Definition: startup.c:15
static DWORD WINAPI d3drm_light_GetAppData(IDirect3DRMLight *iface)
Definition: light.c:115
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
static HRESULT WINAPI d3drm_light_GetName(IDirect3DRMLight *iface, DWORD *size, char *name)
Definition: light.c:133
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define IDirect3DRM_AddRef(p)
Definition: d3drm.h:110
static D3DVALUE WINAPI d3drm_light_GetUmbra(IDirect3DRMLight *iface)
Definition: light.c:260
GLuint color
Definition: glext.h:6243
#define FIXME(fmt,...)
Definition: debug.h:110
float D3DVALUE
Definition: d3dtypes.h:89
smooth NULL
Definition: ftsmooth.c:416
HRESULT d3drm_object_get_name(struct d3drm_object *object, DWORD *size, char *name)
Definition: d3drm_main.c:111
#define debugstr_guid
Definition: kernel32.h:35
GLclampf GLclampf blue
Definition: gl.h:1740
HRESULT d3drm_object_get_class_name(struct d3drm_object *object, DWORD *size, char *name)
Definition: d3drm_main.c:92
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static HRESULT WINAPI d3drm_light_SetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame *frame)
Definition: light.c:323
static HRESULT WINAPI d3drm_light_SetQuadraticAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
Definition: light.c:240
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface, D3DRMOBJECTCALLBACK cb, void *ctx)
Definition: light.c:84
static HRESULT WINAPI d3drm_light_SetColor(IDirect3DRMLight *iface, D3DCOLOR color)
Definition: light.c:162
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
#define D3DRM_OK
Definition: d3drm.h:486
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
static D3DVALUE WINAPI d3drm_light_GetPenumbra(IDirect3DRMLight *iface)
Definition: light.c:269
static FILE * out
Definition: regtests2xml.c:44
GLclampf green
Definition: gl.h:1740
unsigned long DWORD
Definition: ntddk_ex.h:95
#define red
Definition: linetest.c:67
static HRESULT WINAPI d3drm_light_SetAppData(IDirect3DRMLight *iface, DWORD data)
Definition: light.c:104
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static HRESULT WINAPI d3drm_light_SetColorRGB(IDirect3DRMLight *iface, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
Definition: light.c:173
void(__cdecl * D3DRMOBJECTCALLBACK)(struct IDirect3DRMObject *obj, void *arg)
Definition: d3drmobj.h:157
HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx)
Definition: d3drm_main.c:72
#define InterlockedDecrement
Definition: armddk.h:52
static const struct IDirect3DRMLightVtbl d3drm_light_vtbl
Definition: light.c:337
Definition: d3drm.c:188
GLenum GLint * range
Definition: glext.h:7539
WINE_DEFAULT_DEBUG_CHANNEL(d3drm)
static ULONG WINAPI d3drm_light_AddRef(IDirect3DRMLight *iface)
Definition: light.c:49
#define S_OK
Definition: intsafe.h:59
static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface, D3DRMOBJECTCALLBACK cb, void *ctx)
Definition: light.c:94
#define InterlockedIncrement
Definition: armddk.h:53
IDirect3DRM * d3drm
#define E_NOTIMPL
Definition: ddrawi.h:99
static void d3drm_set_color(D3DCOLOR *color, float r, float g, float b, float a)
#define IDirect3DRMLight_AddRef(p)
Definition: d3drmobj.h:3119
static HRESULT WINAPI d3drm_light_SetUmbra(IDirect3DRMLight *iface, D3DVALUE umbra)
Definition: light.c:196
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static D3DVALUE WINAPI d3drm_light_GetLinearAttenuation(IDirect3DRMLight *iface)
Definition: light.c:287
void d3drm_object_init(struct d3drm_object *object, const char *classname)
Definition: d3drm_main.c:39
static HRESULT WINAPI d3drm_light_SetLinearAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
Definition: light.c:229
D3DVALUE penumbra
static D3DVALUE WINAPI d3drm_light_GetConstantAttenuation(IDirect3DRMLight *iface)
Definition: light.c:278
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
static HRESULT WINAPI d3drm_light_Clone(IDirect3DRMLight *iface, IUnknown *outer, REFIID iid, void **out)
Definition: light.c:76
Definition: name.c:36
static D3DVALUE WINAPI d3drm_light_GetQuadraticAttenuation(IDirect3DRMLight *iface)
Definition: light.c:296
unsigned int ULONG
Definition: retypes.h:1
#define IDirect3DRM_Release(p)
Definition: d3drm.h:111
static HRESULT WINAPI d3drm_light_QueryInterface(IDirect3DRMLight *iface, REFIID riid, void **out)
Definition: light.c:30
static ULONG WINAPI d3drm_light_Release(IDirect3DRMLight *iface)
Definition: light.c:59
HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm)
Definition: light.c:371
void * object
Definition: jmemsys.h:48
enum _D3DRMLIGHTTYPE D3DRMLIGHTTYPE
static HRESULT WINAPI d3drm_light_SetPenumbra(IDirect3DRMLight *iface, D3DVALUE penumbra)
Definition: light.c:207
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
HRESULT d3drm_object_set_name(struct d3drm_object *object, const char *name)
Definition: d3drm_main.c:135
D3DVALUE umbra