dsound: Don't write more than three periods to IAudioClient.
[wine.git] / dlls / d3drm / material.c
blob11f2a2beb1f83808c768fa3fb054eb000304dee5
1 /*
2 * Implementation of IDirect3DRMMaterial2 interface
4 * Copyright 2012 Christian Costa
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
21 #include "config.h"
22 #include "wine/port.h"
24 #include "d3drm_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
28 struct color_rgb
30 D3DVALUE r;
31 D3DVALUE g;
32 D3DVALUE b;
35 struct d3drm_material
37 IDirect3DRMMaterial2 IDirect3DRMMaterial2_iface;
38 LONG ref;
39 struct color_rgb emissive;
40 struct color_rgb specular;
41 D3DVALUE power;
42 struct color_rgb ambient;
45 static inline struct d3drm_material *impl_from_IDirect3DRMMaterial2(IDirect3DRMMaterial2 *iface)
47 return CONTAINING_RECORD(iface, struct d3drm_material, IDirect3DRMMaterial2_iface);
50 static HRESULT WINAPI d3drm_material_QueryInterface(IDirect3DRMMaterial2 *iface, REFIID riid, void **out)
52 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
54 if (IsEqualGUID(riid, &IID_IDirect3DRMMaterial2)
55 || IsEqualGUID(riid, &IID_IDirect3DRMMaterial)
56 || IsEqualGUID(riid, &IID_IUnknown))
58 IDirect3DRMMaterial2_AddRef(iface);
59 *out = iface;
60 return S_OK;
63 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
65 *out = NULL;
66 return E_NOINTERFACE;
69 static ULONG WINAPI d3drm_material_AddRef(IDirect3DRMMaterial2 *iface)
71 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
72 ULONG refcount = InterlockedIncrement(&material->ref);
74 TRACE("%p increasing refcount to %u.\n", iface, refcount);
76 return refcount;
79 static ULONG WINAPI d3drm_material_Release(IDirect3DRMMaterial2 *iface)
81 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
82 ULONG refcount = InterlockedDecrement(&material->ref);
84 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
86 if (!refcount)
87 HeapFree(GetProcessHeap(), 0, material);
89 return refcount;
92 static HRESULT WINAPI d3drm_material_Clone(IDirect3DRMMaterial2 *iface,
93 IUnknown *outer, REFIID iid, void **out)
95 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
97 return E_NOTIMPL;
100 static HRESULT WINAPI d3drm_material_AddDestroyCallback(IDirect3DRMMaterial2 *iface,
101 D3DRMOBJECTCALLBACK cb, void *ctx)
103 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
105 return E_NOTIMPL;
108 static HRESULT WINAPI d3drm_material_DeleteDestroyCallback(IDirect3DRMMaterial2 *iface,
109 D3DRMOBJECTCALLBACK cb, void *ctx)
111 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
113 return E_NOTIMPL;
116 static HRESULT WINAPI d3drm_material_SetAppData(IDirect3DRMMaterial2 *iface, DWORD data)
118 FIXME("iface %p, data %#x stub!\n", iface, data);
120 return E_NOTIMPL;
123 static DWORD WINAPI d3drm_material_GetAppData(IDirect3DRMMaterial2 *iface)
125 FIXME("iface %p stub!\n", iface);
127 return 0;
130 static HRESULT WINAPI d3drm_material_SetName(IDirect3DRMMaterial2 *iface, const char *name)
132 FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
134 return E_NOTIMPL;
137 static HRESULT WINAPI d3drm_material_GetName(IDirect3DRMMaterial2 *iface, DWORD *size, char *name)
139 FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
141 return E_NOTIMPL;
144 static HRESULT WINAPI d3drm_material_GetClassName(IDirect3DRMMaterial2 *iface, DWORD *size, char *name)
146 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
148 if (!size || *size < strlen("Material") || !name)
149 return E_INVALIDARG;
151 strcpy(name, "Material");
152 *size = sizeof("Material");
154 return D3DRM_OK;
157 static HRESULT WINAPI d3drm_material_SetPower(IDirect3DRMMaterial2 *iface, D3DVALUE power)
159 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
161 TRACE("iface %p, power %.8e.\n", iface, power);
163 material->power = power;
165 return D3DRM_OK;
168 static HRESULT WINAPI d3drm_material_SetSpecular(IDirect3DRMMaterial2 *iface,
169 D3DVALUE r, D3DVALUE g, D3DVALUE b)
171 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
173 TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface, r, g, b);
175 material->specular.r = r;
176 material->specular.g = g;
177 material->specular.b = b;
179 return D3DRM_OK;
182 static HRESULT WINAPI d3drm_material_SetEmissive(IDirect3DRMMaterial2 *iface,
183 D3DVALUE r, D3DVALUE g, D3DVALUE b)
185 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
187 TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface, r, g, b);
189 material->emissive.r = r;
190 material->emissive.g = g;
191 material->emissive.b = b;
193 return D3DRM_OK;
196 static D3DVALUE WINAPI d3drm_material_GetPower(IDirect3DRMMaterial2 *iface)
198 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
200 TRACE("iface %p.\n", iface);
202 return material->power;
205 static HRESULT WINAPI d3drm_material_GetSpecular(IDirect3DRMMaterial2 *iface,
206 D3DVALUE *r, D3DVALUE *g, D3DVALUE *b)
208 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
210 TRACE("iface %p, r %p, g %p, b %p.\n", iface, r, g, b);
212 *r = material->specular.r;
213 *g = material->specular.g;
214 *b = material->specular.b;
216 return D3DRM_OK;
219 static HRESULT WINAPI d3drm_material_GetEmissive(IDirect3DRMMaterial2 *iface,
220 D3DVALUE *r, D3DVALUE *g, D3DVALUE *b)
222 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
224 TRACE("iface %p, r %p, g %p, b %p.\n", iface, r, g, b);
226 *r = material->emissive.r;
227 *g = material->emissive.g;
228 *b = material->emissive.b;
230 return D3DRM_OK;
233 static HRESULT WINAPI d3drm_material_GetAmbient(IDirect3DRMMaterial2 *iface,
234 D3DVALUE *r, D3DVALUE *g, D3DVALUE *b)
236 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
238 TRACE("iface %p, r %p, g %p, b %p.\n", iface, r, g, b);
240 *r = material->ambient.r;
241 *g = material->ambient.g;
242 *b = material->ambient.b;
244 return D3DRM_OK;
247 static HRESULT WINAPI d3drm_material_SetAmbient(IDirect3DRMMaterial2 *iface,
248 D3DVALUE r, D3DVALUE g, D3DVALUE b)
250 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
252 TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface, r, g, b);
254 material->ambient.r = r;
255 material->ambient.g = g;
256 material->ambient.b = b;
258 return D3DRM_OK;
261 static const struct IDirect3DRMMaterial2Vtbl d3drm_material_vtbl =
263 d3drm_material_QueryInterface,
264 d3drm_material_AddRef,
265 d3drm_material_Release,
266 d3drm_material_Clone,
267 d3drm_material_AddDestroyCallback,
268 d3drm_material_DeleteDestroyCallback,
269 d3drm_material_SetAppData,
270 d3drm_material_GetAppData,
271 d3drm_material_SetName,
272 d3drm_material_GetName,
273 d3drm_material_GetClassName,
274 d3drm_material_SetPower,
275 d3drm_material_SetSpecular,
276 d3drm_material_SetEmissive,
277 d3drm_material_GetPower,
278 d3drm_material_GetSpecular,
279 d3drm_material_GetEmissive,
280 d3drm_material_GetAmbient,
281 d3drm_material_SetAmbient,
284 HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2 **out)
286 struct d3drm_material *object;
288 TRACE("out %p.\n", out);
290 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
291 return E_OUTOFMEMORY;
293 object->IDirect3DRMMaterial2_iface.lpVtbl = &d3drm_material_vtbl;
294 object->ref = 1;
296 object->specular.r = 1.0f;
297 object->specular.g = 1.0f;
298 object->specular.b = 1.0f;
300 *out = &object->IDirect3DRMMaterial2_iface;
302 return S_OK;