ReactOS 0.4.15-dev-7660-g0086d05
light.c File Reference
#include "config.h"
#include "wine/port.h"
#include "ddraw_private.h"
Include dependency graph for light.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ddraw)
 
static void light_update (struct d3d_light *light)
 
void light_activate (struct d3d_light *light)
 
void light_deactivate (struct d3d_light *light)
 
static struct d3d_lightimpl_from_IDirect3DLight (IDirect3DLight *iface)
 
static HRESULT WINAPI d3d_light_QueryInterface (IDirect3DLight *iface, REFIID riid, void **object)
 
static ULONG WINAPI d3d_light_AddRef (IDirect3DLight *iface)
 
static ULONG WINAPI d3d_light_Release (IDirect3DLight *iface)
 
static HRESULT WINAPI d3d_light_Initialize (IDirect3DLight *iface, IDirect3D *d3d)
 
static HRESULT WINAPI d3d_light_SetLight (IDirect3DLight *iface, D3DLIGHT *data)
 
static HRESULT WINAPI d3d_light_GetLight (IDirect3DLight *iface, D3DLIGHT *lpLight)
 
void d3d_light_init (struct d3d_light *light, struct ddraw *ddraw)
 
struct d3d_lightunsafe_impl_from_IDirect3DLight (IDirect3DLight *iface)
 

Variables

static const struct IDirect3DLightVtbl d3d_light_vtbl
 

Function Documentation

◆ d3d_light_AddRef()

static ULONG WINAPI d3d_light_AddRef ( IDirect3DLight *  iface)
static

Definition at line 117 of file light.c.

118{
121
122 TRACE("%p increasing refcount to %u.\n", light, ref);
123
124 return ref;
125}
#define InterlockedIncrement
Definition: armddk.h:53
static struct d3d_light * impl_from_IDirect3DLight(IDirect3DLight *iface)
Definition: light.c:91
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
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ d3d_light_GetLight()

static HRESULT WINAPI d3d_light_GetLight ( IDirect3DLight *  iface,
D3DLIGHT lpLight 
)
static

Definition at line 222 of file light.c.

223{
225
226 TRACE("iface %p, light %p.\n", iface, lpLight);
227
229 memcpy(lpLight, &light->light, lpLight->dwSize);
231
232 return DD_OK;
233}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define DD_OK
Definition: ddraw.h:186
DWORD dwSize
Definition: d3dtypes.h:566
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368

◆ d3d_light_init()

void d3d_light_init ( struct d3d_light light,
struct ddraw ddraw 
)

Definition at line 247 of file light.c.

248{
249 light->IDirect3DLight_iface.lpVtbl = &d3d_light_vtbl;
250 light->ref = 1;
251 light->ddraw = ddraw;
252}
static const struct IDirect3DLightVtbl d3d_light_vtbl
Definition: light.c:235

Referenced by d3d3_CreateLight().

◆ d3d_light_Initialize()

static HRESULT WINAPI d3d_light_Initialize ( IDirect3DLight *  iface,
IDirect3D *  d3d 
)
static

Definition at line 159 of file light.c.

160{
161 TRACE("iface %p, d3d %p.\n", iface, d3d);
162
163 return D3D_OK;
164}
#define D3D_OK
Definition: d3d.h:106

◆ d3d_light_QueryInterface()

static HRESULT WINAPI d3d_light_QueryInterface ( IDirect3DLight *  iface,
REFIID  riid,
void **  object 
)
static

Definition at line 109 of file light.c.

110{
111 FIXME("iface %p, riid %s, object %p stub!\n", iface, debugstr_guid(riid), object);
112
113 *object = NULL;
114 return E_NOINTERFACE;
115}
#define FIXME(fmt,...)
Definition: debug.h:111
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ d3d_light_Release()

static ULONG WINAPI d3d_light_Release ( IDirect3DLight *  iface)
static

Definition at line 127 of file light.c.

128{
131
132 TRACE("%p decreasing refcount to %u.\n", light, ref);
133
134 if (!ref)
135 {
137 return 0;
138 }
139 return ref;
140}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedDecrement
Definition: armddk.h:52

◆ d3d_light_SetLight()

static HRESULT WINAPI d3d_light_SetLight ( IDirect3DLight *  iface,
D3DLIGHT data 
)
static

Definition at line 166 of file light.c.

167{
168 static const D3DCOLORVALUE zero_value = {{0.0f}, {0.0f}, {0.0f}, {0.0f}};
170 DWORD flags = data->dwSize >= sizeof(D3DLIGHT2) ? ((D3DLIGHT2 *)data)->dwFlags : D3DLIGHT_ACTIVE;
171 D3DLIGHT7 *light7 = &light->light7;
172
173 TRACE("iface %p, data %p.\n", iface, data);
174
175 if ((!data->dltType) || (data->dltType > D3DLIGHT_PARALLELPOINT))
176 return DDERR_INVALIDPARAMS;
177
178 /* Translate D3DLIGHT2 structure to D3DLIGHT7. */
179 light7->dltType = data->dltType;
180 light7->dcvDiffuse = data->dcvColor;
182 light7->dcvSpecular = zero_value;
183 else
184 light7->dcvSpecular = data->dcvColor;
185 light7->dcvAmbient = data->dcvColor;
186 light7->dvPosition = data->dvPosition;
187 light7->dvDirection = data->dvDirection;
188 light7->dvRange = data->dvRange;
189 light7->dvFalloff = data->dvFalloff;
190 light7->dvAttenuation0 = data->dvAttenuation0;
191 light7->dvAttenuation1 = data->dvAttenuation1;
192 light7->dvAttenuation2 = data->dvAttenuation2;
193 light7->dvTheta = data->dvTheta;
194 light7->dvPhi = data->dvPhi;
195
197 memcpy(&light->light, data, sizeof(*data));
198 if (!(light->light.dwFlags & D3DLIGHT_ACTIVE) && flags & D3DLIGHT_ACTIVE)
200 else if (light->light.dwFlags & D3DLIGHT_ACTIVE && !(flags & D3DLIGHT_ACTIVE))
202 else if (flags & D3DLIGHT_ACTIVE)
204 light->light.dwFlags = flags;
206
207 return D3D_OK;
208}
@ D3DLIGHT_PARALLELPOINT
Definition: d3dtypes.h:558
#define D3DLIGHT_NO_SPECULAR
Definition: d3dtypes.h:597
#define D3DLIGHT_ACTIVE
Definition: d3dtypes.h:596
struct _D3DLIGHT2 D3DLIGHT2
void light_activate(struct d3d_light *light)
Definition: light.c:51
void light_deactivate(struct d3d_light *light)
Definition: light.c:75
static void light_update(struct d3d_light *light)
Definition: light.c:33
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
D3DVALUE dvPhi
Definition: d3dtypes.h:593
D3DVALUE dvFalloff
Definition: d3dtypes.h:588
D3DCOLORVALUE dcvDiffuse
Definition: d3dtypes.h:582
D3DCOLORVALUE dcvAmbient
Definition: d3dtypes.h:584
D3DVALUE dvAttenuation2
Definition: d3dtypes.h:591
D3DVALUE dvAttenuation0
Definition: d3dtypes.h:589
D3DVECTOR dvPosition
Definition: d3dtypes.h:585
D3DVALUE dvRange
Definition: d3dtypes.h:587
D3DLIGHTTYPE dltType
Definition: d3dtypes.h:581
D3DVALUE dvTheta
Definition: d3dtypes.h:592
D3DCOLORVALUE dcvSpecular
Definition: d3dtypes.h:583
D3DVALUE dvAttenuation1
Definition: d3dtypes.h:590
D3DVECTOR dvDirection
Definition: d3dtypes.h:586
D3DLIGHT7 light7
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ impl_from_IDirect3DLight()

static struct d3d_light * impl_from_IDirect3DLight ( IDirect3DLight *  iface)
inlinestatic

Definition at line 91 of file light.c.

92{
93 return CONTAINING_RECORD(iface, struct d3d_light, IDirect3DLight_iface);
94}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by d3d_light_AddRef(), d3d_light_GetLight(), d3d_light_Release(), d3d_light_SetLight(), and unsafe_impl_from_IDirect3DLight().

◆ light_activate()

void light_activate ( struct d3d_light light)

Definition at line 51 of file light.c.

52{
53 struct d3d_device *device;
54
55 TRACE("light %p.\n", light);
56
57 if (!light->active_viewport || !light->active_viewport->active_device) return;
58 device = light->active_viewport->active_device;
59
61 if (!(light->light.dwFlags & D3DLIGHT_ACTIVE))
62 {
63 IDirect3DDevice7_LightEnable(&device->IDirect3DDevice7_iface, light->dwLightIndex, TRUE);
64 light->light.dwFlags |= D3DLIGHT_ACTIVE;
65 }
66}
#define IDirect3DDevice7_LightEnable(p, a, b)
Definition: d3d.h:1387
#define TRUE
Definition: types.h:120
Definition: devices.h:37

Referenced by d3d_light_SetLight(), d3d_viewport_AddLight(), and viewport_activate().

◆ light_deactivate()

void light_deactivate ( struct d3d_light light)

Definition at line 75 of file light.c.

76{
77 struct d3d_device *device;
78
79 TRACE("light %p.\n", light);
80
81 if (!light->active_viewport || !light->active_viewport->active_device) return;
82 device = light->active_viewport->active_device;
83
84 if (light->light.dwFlags & D3DLIGHT_ACTIVE)
85 {
86 IDirect3DDevice7_LightEnable(&device->IDirect3DDevice7_iface, light->dwLightIndex, FALSE);
87 light->light.dwFlags &= ~D3DLIGHT_ACTIVE;
88 }
89}
#define FALSE
Definition: types.h:117

Referenced by d3d_light_SetLight(), and d3d_viewport_DeleteLight().

◆ light_update()

static void light_update ( struct d3d_light light)
static

Definition at line 33 of file light.c.

34{
35 struct d3d_device *device;
36
37 TRACE("light %p.\n", light);
38
39 if (!light->active_viewport || !light->active_viewport->active_device) return;
40 device = light->active_viewport->active_device;
41
42 IDirect3DDevice7_SetLight(&device->IDirect3DDevice7_iface, light->dwLightIndex, &light->light7);
43}
#define IDirect3DDevice7_SetLight(p, a, b)
Definition: d3d.h:1361

Referenced by d3d_light_SetLight(), and light_activate().

◆ unsafe_impl_from_IDirect3DLight()

struct d3d_light * unsafe_impl_from_IDirect3DLight ( IDirect3DLight *  iface)

Definition at line 254 of file light.c.

255{
256 if (!iface)
257 return NULL;
258 assert(iface->lpVtbl == &d3d_light_vtbl);
259
260 return impl_from_IDirect3DLight(iface);
261}
#define assert(x)
Definition: debug.h:53

Referenced by d3d_viewport_AddLight(), d3d_viewport_DeleteLight(), and d3d_viewport_NextLight().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ddraw  )

Variable Documentation

◆ d3d_light_vtbl

const struct IDirect3DLightVtbl d3d_light_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI d3d_light_SetLight(IDirect3DLight *iface, D3DLIGHT *data)
Definition: light.c:166
static ULONG WINAPI d3d_light_AddRef(IDirect3DLight *iface)
Definition: light.c:117
static HRESULT WINAPI d3d_light_GetLight(IDirect3DLight *iface, D3DLIGHT *lpLight)
Definition: light.c:222
static HRESULT WINAPI d3d_light_QueryInterface(IDirect3DLight *iface, REFIID riid, void **object)
Definition: light.c:109
static HRESULT WINAPI d3d_light_Initialize(IDirect3DLight *iface, IDirect3D *d3d)
Definition: light.c:159
static ULONG WINAPI d3d_light_Release(IDirect3DLight *iface)
Definition: light.c:127

Definition at line 235 of file light.c.

Referenced by d3d_light_init(), and unsafe_impl_from_IDirect3DLight().