gitlab: Run tests on Debian after the daily commit round.
[wine.git] / dlls / d3drm / material.c
blob2e831b5d25294cbfa890b6acb6eb4917bcee4556
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 "d3drm_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
25 static inline struct d3drm_material *impl_from_IDirect3DRMMaterial2(IDirect3DRMMaterial2 *iface)
27 return CONTAINING_RECORD(iface, struct d3drm_material, IDirect3DRMMaterial2_iface);
30 static HRESULT WINAPI d3drm_material_QueryInterface(IDirect3DRMMaterial2 *iface, REFIID riid, void **out)
32 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
34 if (IsEqualGUID(riid, &IID_IDirect3DRMMaterial2)
35 || IsEqualGUID(riid, &IID_IDirect3DRMMaterial)
36 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
37 || IsEqualGUID(riid, &IID_IUnknown))
39 IDirect3DRMMaterial2_AddRef(iface);
40 *out = iface;
41 return S_OK;
44 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
46 *out = NULL;
47 return E_NOINTERFACE;
50 static ULONG WINAPI d3drm_material_AddRef(IDirect3DRMMaterial2 *iface)
52 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
53 ULONG refcount = InterlockedIncrement(&material->ref);
55 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
57 return refcount;
60 static ULONG WINAPI d3drm_material_Release(IDirect3DRMMaterial2 *iface)
62 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
63 ULONG refcount = InterlockedDecrement(&material->ref);
65 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
67 if (!refcount)
69 d3drm_object_cleanup((IDirect3DRMObject *)iface, &material->obj);
70 IDirect3DRM_Release(material->d3drm);
71 heap_free(material);
74 return refcount;
77 static HRESULT WINAPI d3drm_material_Clone(IDirect3DRMMaterial2 *iface,
78 IUnknown *outer, REFIID iid, void **out)
80 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
82 return E_NOTIMPL;
85 static HRESULT WINAPI d3drm_material_AddDestroyCallback(IDirect3DRMMaterial2 *iface,
86 D3DRMOBJECTCALLBACK cb, void *ctx)
88 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
90 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
92 return d3drm_object_add_destroy_callback(&material->obj, cb, ctx);
95 static HRESULT WINAPI d3drm_material_DeleteDestroyCallback(IDirect3DRMMaterial2 *iface,
96 D3DRMOBJECTCALLBACK cb, void *ctx)
98 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
100 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
102 return d3drm_object_delete_destroy_callback(&material->obj, cb, ctx);
105 static HRESULT WINAPI d3drm_material_SetAppData(IDirect3DRMMaterial2 *iface, DWORD data)
107 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
109 TRACE("iface %p, data %#lx.\n", iface, data);
111 material->obj.appdata = data;
113 return D3DRM_OK;
116 static DWORD WINAPI d3drm_material_GetAppData(IDirect3DRMMaterial2 *iface)
118 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
120 TRACE("iface %p.\n", iface);
122 return material->obj.appdata;
125 static HRESULT WINAPI d3drm_material_SetName(IDirect3DRMMaterial2 *iface, const char *name)
127 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
129 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
131 return d3drm_object_set_name(&material->obj, name);
134 static HRESULT WINAPI d3drm_material_GetName(IDirect3DRMMaterial2 *iface, DWORD *size, char *name)
136 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
138 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
140 return d3drm_object_get_name(&material->obj, size, name);
143 static HRESULT WINAPI d3drm_material_GetClassName(IDirect3DRMMaterial2 *iface, DWORD *size, char *name)
145 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
147 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
149 return d3drm_object_get_class_name(&material->obj, size, name);
152 static HRESULT WINAPI d3drm_material_SetPower(IDirect3DRMMaterial2 *iface, D3DVALUE power)
154 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
156 TRACE("iface %p, power %.8e.\n", iface, power);
158 material->power = power;
160 return D3DRM_OK;
163 static HRESULT WINAPI d3drm_material_SetSpecular(IDirect3DRMMaterial2 *iface,
164 D3DVALUE r, D3DVALUE g, D3DVALUE b)
166 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
168 TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface, r, g, b);
170 material->specular.r = r;
171 material->specular.g = g;
172 material->specular.b = b;
174 return D3DRM_OK;
177 static HRESULT WINAPI d3drm_material_SetEmissive(IDirect3DRMMaterial2 *iface,
178 D3DVALUE r, D3DVALUE g, D3DVALUE b)
180 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
182 TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface, r, g, b);
184 material->emissive.r = r;
185 material->emissive.g = g;
186 material->emissive.b = b;
188 return D3DRM_OK;
191 static D3DVALUE WINAPI d3drm_material_GetPower(IDirect3DRMMaterial2 *iface)
193 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
195 TRACE("iface %p.\n", iface);
197 return material->power;
200 static HRESULT WINAPI d3drm_material_GetSpecular(IDirect3DRMMaterial2 *iface,
201 D3DVALUE *r, D3DVALUE *g, D3DVALUE *b)
203 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
205 TRACE("iface %p, r %p, g %p, b %p.\n", iface, r, g, b);
207 *r = material->specular.r;
208 *g = material->specular.g;
209 *b = material->specular.b;
211 return D3DRM_OK;
214 static HRESULT WINAPI d3drm_material_GetEmissive(IDirect3DRMMaterial2 *iface,
215 D3DVALUE *r, D3DVALUE *g, D3DVALUE *b)
217 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
219 TRACE("iface %p, r %p, g %p, b %p.\n", iface, r, g, b);
221 *r = material->emissive.r;
222 *g = material->emissive.g;
223 *b = material->emissive.b;
225 return D3DRM_OK;
228 static HRESULT WINAPI d3drm_material_GetAmbient(IDirect3DRMMaterial2 *iface,
229 D3DVALUE *r, D3DVALUE *g, D3DVALUE *b)
231 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
233 TRACE("iface %p, r %p, g %p, b %p.\n", iface, r, g, b);
235 *r = material->ambient.r;
236 *g = material->ambient.g;
237 *b = material->ambient.b;
239 return D3DRM_OK;
242 static HRESULT WINAPI d3drm_material_SetAmbient(IDirect3DRMMaterial2 *iface,
243 D3DVALUE r, D3DVALUE g, D3DVALUE b)
245 struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
247 TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface, r, g, b);
249 material->ambient.r = r;
250 material->ambient.g = g;
251 material->ambient.b = b;
253 return D3DRM_OK;
256 static const struct IDirect3DRMMaterial2Vtbl d3drm_material_vtbl =
258 d3drm_material_QueryInterface,
259 d3drm_material_AddRef,
260 d3drm_material_Release,
261 d3drm_material_Clone,
262 d3drm_material_AddDestroyCallback,
263 d3drm_material_DeleteDestroyCallback,
264 d3drm_material_SetAppData,
265 d3drm_material_GetAppData,
266 d3drm_material_SetName,
267 d3drm_material_GetName,
268 d3drm_material_GetClassName,
269 d3drm_material_SetPower,
270 d3drm_material_SetSpecular,
271 d3drm_material_SetEmissive,
272 d3drm_material_GetPower,
273 d3drm_material_GetSpecular,
274 d3drm_material_GetEmissive,
275 d3drm_material_GetAmbient,
276 d3drm_material_SetAmbient,
279 HRESULT d3drm_material_create(struct d3drm_material **material, IDirect3DRM *d3drm)
281 static const char classname[] = "Material";
282 struct d3drm_material *object;
284 TRACE("material %p, d3drm %p.\n", material, d3drm);
286 if (!(object = heap_alloc_zero(sizeof(*object))))
287 return E_OUTOFMEMORY;
289 object->IDirect3DRMMaterial2_iface.lpVtbl = &d3drm_material_vtbl;
290 object->ref = 1;
291 object->d3drm = d3drm;
292 IDirect3DRM_AddRef(object->d3drm);
294 object->specular.r = 1.0f;
295 object->specular.g = 1.0f;
296 object->specular.b = 1.0f;
298 d3drm_object_init(&object->obj, classname);
300 *material = object;
302 return S_OK;