[D3DRM]
[reactos.git] / reactos / dll / directx / wine / d3drm / face.c
1 /*
2 * Implementation of IDirect3DRMFace Interface
3 *
4 * Copyright 2013 André Hentschel
5 *
6 * This file contains the (internal) driver registration functions,
7 * driver enumeration APIs and DirectDraw creation functions.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24 #include "d3drm_private.h"
25
26 struct d3drm_face
27 {
28 IDirect3DRMFace IDirect3DRMFace_iface;
29 IDirect3DRMFace2 IDirect3DRMFace2_iface;
30 LONG ref;
31 };
32
33 static inline struct d3drm_face *impl_from_IDirect3DRMFace(IDirect3DRMFace *iface)
34 {
35 return CONTAINING_RECORD(iface, struct d3drm_face, IDirect3DRMFace_iface);
36 }
37
38 static inline struct d3drm_face *impl_from_IDirect3DRMFace2(IDirect3DRMFace2 *iface)
39 {
40 return CONTAINING_RECORD(iface, struct d3drm_face, IDirect3DRMFace2_iface);
41 }
42
43 static HRESULT WINAPI d3drm_face1_QueryInterface(IDirect3DRMFace *iface, REFIID riid, void **out)
44 {
45 struct d3drm_face *face = impl_from_IDirect3DRMFace(iface);
46
47 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
48
49
50 if (IsEqualGUID(riid, &IID_IDirect3DRMFace)
51 || IsEqualGUID(riid, &IID_IUnknown))
52 {
53 *out = &face->IDirect3DRMFace_iface;
54 }
55 else if(IsEqualGUID(riid, &IID_IDirect3DRMFace2))
56 {
57 *out = &face->IDirect3DRMFace2_iface;
58 }
59 else
60 {
61 *out = NULL;
62 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
63 return E_NOINTERFACE;
64 }
65
66 IUnknown_AddRef((IUnknown *)*out);
67 return S_OK;
68 }
69
70 static ULONG WINAPI d3drm_face1_AddRef(IDirect3DRMFace *iface)
71 {
72 struct d3drm_face *face = impl_from_IDirect3DRMFace(iface);
73 ULONG refcount = InterlockedIncrement(&face->ref);
74
75 TRACE("%p increasing refcount to %u.\n", iface, refcount);
76
77 return refcount;
78 }
79
80 static ULONG WINAPI d3drm_face1_Release(IDirect3DRMFace *iface)
81 {
82 struct d3drm_face *face = impl_from_IDirect3DRMFace(iface);
83 ULONG refcount = InterlockedDecrement(&face->ref);
84
85 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
86
87 if (!refcount)
88 HeapFree(GetProcessHeap(), 0, face);
89
90 return refcount;
91 }
92
93 static HRESULT WINAPI d3drm_face1_Clone(IDirect3DRMFace *iface,
94 IUnknown *outer, REFIID iid, void **out)
95 {
96 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
97
98 return E_NOTIMPL;
99 }
100
101 static HRESULT WINAPI d3drm_face1_AddDestroyCallback(IDirect3DRMFace *iface,
102 D3DRMOBJECTCALLBACK cb, void *ctx)
103 {
104 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
105
106 return E_NOTIMPL;
107 }
108
109 static HRESULT WINAPI d3drm_face1_DeleteDestroyCallback(IDirect3DRMFace *iface,
110 D3DRMOBJECTCALLBACK cb, void *ctx)
111 {
112 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
113
114 return E_NOTIMPL;
115 }
116
117 static HRESULT WINAPI d3drm_face1_SetAppData(IDirect3DRMFace *iface, DWORD data)
118 {
119 FIXME("iface %p, data %#x stub!\n", iface, data);
120
121 return E_NOTIMPL;
122 }
123
124 static DWORD WINAPI d3drm_face1_GetAppData(IDirect3DRMFace *iface)
125 {
126 FIXME("iface %p stub!\n", iface);
127
128 return 0;
129 }
130
131 static HRESULT WINAPI d3drm_face1_SetName(IDirect3DRMFace *iface, const char *name)
132 {
133 FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
134
135 return E_NOTIMPL;
136 }
137
138 static HRESULT WINAPI d3drm_face1_GetName(IDirect3DRMFace *iface, DWORD *size, char *name)
139 {
140 FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
141
142 return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI d3drm_face1_GetClassName(IDirect3DRMFace *iface, DWORD *size, char *name)
146 {
147 struct d3drm_face *face = impl_from_IDirect3DRMFace(iface);
148
149 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
150
151 return IDirect3DRMFace2_GetClassName(&face->IDirect3DRMFace2_iface, size, name);
152 }
153
154 static HRESULT WINAPI d3drm_face1_AddVertex(IDirect3DRMFace *iface, D3DVALUE x, D3DVALUE y, D3DVALUE z)
155 {
156 FIXME("iface %p, x %.8e, y %.8e, z %.8e stub!\n", iface, x, y, z);
157
158 return E_NOTIMPL;
159 }
160
161 static HRESULT WINAPI d3drm_face1_AddVertexAndNormalIndexed(IDirect3DRMFace *iface,
162 DWORD vertex, DWORD normal)
163 {
164 FIXME("iface %p, vertex %u, normal %u stub!\n", iface, vertex, normal);
165
166 return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI d3drm_face1_SetColorRGB(IDirect3DRMFace *iface,
170 D3DVALUE r, D3DVALUE g, D3DVALUE b)
171 {
172 FIXME("iface %p, r %.8e, g %.8e, b %.8e stub!\n", iface, r, g, b);
173
174 return E_NOTIMPL;
175 }
176
177 static HRESULT WINAPI d3drm_face1_SetColor(IDirect3DRMFace *iface, D3DCOLOR color)
178 {
179 FIXME("iface %p, color 0x%08x stub!\n", iface, color);
180
181 return E_NOTIMPL;
182 }
183
184 static HRESULT WINAPI d3drm_face1_SetTexture(IDirect3DRMFace *iface, IDirect3DRMTexture *texture)
185 {
186 FIXME("iface %p, texture %p stub!\n", iface, texture);
187
188 return E_NOTIMPL;
189 }
190
191 static HRESULT WINAPI d3drm_face1_SetTextureCoordinates(IDirect3DRMFace *iface,
192 DWORD vertex, D3DVALUE u, D3DVALUE v)
193 {
194 FIXME("iface %p, vertex %u, u %.8e, v %.8e stub!\n", iface, vertex, u, v);
195
196 return E_NOTIMPL;
197 }
198
199 static HRESULT WINAPI d3drm_face1_SetMaterial(IDirect3DRMFace *iface, IDirect3DRMMaterial *material)
200 {
201 FIXME("iface %p, material %p stub!\n", iface, material);
202
203 return E_NOTIMPL;
204 }
205
206 static HRESULT WINAPI d3drm_face1_SetTextureTopology(IDirect3DRMFace *iface, BOOL wrap_u, BOOL wrap_v)
207 {
208 FIXME("iface %p, wrap_u %#x, wrap_v %#x stub!\n", iface, wrap_u, wrap_v);
209
210 return E_NOTIMPL;
211 }
212
213 static HRESULT WINAPI d3drm_face1_GetVertex(IDirect3DRMFace *iface,
214 DWORD index, D3DVECTOR *vertex, D3DVECTOR *normal)
215 {
216 FIXME("iface %p, index %u, vertex %p, normal %p stub!\n", iface, index, vertex, normal);
217
218 return E_NOTIMPL;
219 }
220
221 static HRESULT WINAPI d3drm_face1_GetVertices(IDirect3DRMFace *iface,
222 DWORD *vertex_count, D3DVECTOR *coords, D3DVECTOR *normals)
223 {
224 FIXME("iface %p, vertex_count %p, coords %p, normals %p stub!\n",
225 iface, vertex_count, coords, normals);
226
227 return E_NOTIMPL;
228 }
229
230 static HRESULT WINAPI d3drm_face1_GetTextureCoordinates(IDirect3DRMFace *iface,
231 DWORD vertex, D3DVALUE *u, D3DVALUE *v)
232 {
233 FIXME("iface %p, vertex %u, u %p, v %p stub!\n", iface, vertex, u, v);
234
235 return E_NOTIMPL;
236 }
237
238 static HRESULT WINAPI d3drm_face1_GetTextureTopology(IDirect3DRMFace *iface, BOOL *wrap_u, BOOL *wrap_v)
239 {
240 FIXME("iface %p, wrap_u %p, wrap_v %p stub!\n", iface, wrap_u, wrap_v);
241
242 return E_NOTIMPL;
243 }
244
245 static HRESULT WINAPI d3drm_face1_GetNormal(IDirect3DRMFace *iface, D3DVECTOR *normal)
246 {
247 FIXME("iface %p, normal %p stub!\n", iface, normal);
248
249 return E_NOTIMPL;
250 }
251
252 static HRESULT WINAPI d3drm_face1_GetTexture(IDirect3DRMFace *iface, IDirect3DRMTexture **texture)
253 {
254 FIXME("iface %p, texture %p stub!\n", iface, texture);
255
256 return E_NOTIMPL;
257 }
258
259 static HRESULT WINAPI d3drm_face1_GetMaterial(IDirect3DRMFace *iface, IDirect3DRMMaterial **material)
260 {
261 FIXME("iface %p, material %p stub!\n", iface, material);
262
263 return E_NOTIMPL;
264 }
265
266 static int WINAPI d3drm_face1_GetVertexCount(IDirect3DRMFace *iface)
267 {
268 FIXME("iface %p stub!\n", iface);
269
270 return 0;
271 }
272
273 static int WINAPI d3drm_face1_GetVertexIndex(IDirect3DRMFace *iface, DWORD which)
274 {
275 FIXME("iface %p, which %u stub!\n", iface, which);
276
277 return 0;
278 }
279
280 static int WINAPI d3drm_face1_GetTextureCoordinateIndex(IDirect3DRMFace *iface, DWORD which)
281 {
282 FIXME("iface %p, which %u stub!\n", iface, which);
283
284 return 0;
285 }
286
287 static D3DCOLOR WINAPI d3drm_face1_GetColor(IDirect3DRMFace *iface)
288 {
289 FIXME("iface %p stub!\n", iface);
290
291 return 0;
292 }
293
294 static const struct IDirect3DRMFaceVtbl d3drm_face1_vtbl =
295 {
296 d3drm_face1_QueryInterface,
297 d3drm_face1_AddRef,
298 d3drm_face1_Release,
299 d3drm_face1_Clone,
300 d3drm_face1_AddDestroyCallback,
301 d3drm_face1_DeleteDestroyCallback,
302 d3drm_face1_SetAppData,
303 d3drm_face1_GetAppData,
304 d3drm_face1_SetName,
305 d3drm_face1_GetName,
306 d3drm_face1_GetClassName,
307 d3drm_face1_AddVertex,
308 d3drm_face1_AddVertexAndNormalIndexed,
309 d3drm_face1_SetColorRGB,
310 d3drm_face1_SetColor,
311 d3drm_face1_SetTexture,
312 d3drm_face1_SetTextureCoordinates,
313 d3drm_face1_SetMaterial,
314 d3drm_face1_SetTextureTopology,
315 d3drm_face1_GetVertex,
316 d3drm_face1_GetVertices,
317 d3drm_face1_GetTextureCoordinates,
318 d3drm_face1_GetTextureTopology,
319 d3drm_face1_GetNormal,
320 d3drm_face1_GetTexture,
321 d3drm_face1_GetMaterial,
322 d3drm_face1_GetVertexCount,
323 d3drm_face1_GetVertexIndex,
324 d3drm_face1_GetTextureCoordinateIndex,
325 d3drm_face1_GetColor,
326 };
327
328 static HRESULT WINAPI d3drm_face2_QueryInterface(IDirect3DRMFace2 *iface, REFIID riid, void **out)
329 {
330 struct d3drm_face *face = impl_from_IDirect3DRMFace2(iface);
331
332 return d3drm_face1_QueryInterface(&face->IDirect3DRMFace_iface, riid, out);
333 }
334
335 static ULONG WINAPI d3drm_face2_AddRef(IDirect3DRMFace2 *iface)
336 {
337 struct d3drm_face *face = impl_from_IDirect3DRMFace2(iface);
338
339 return d3drm_face1_AddRef(&face->IDirect3DRMFace_iface);
340 }
341
342 static ULONG WINAPI d3drm_face2_Release(IDirect3DRMFace2 *iface)
343 {
344 struct d3drm_face *face = impl_from_IDirect3DRMFace2(iface);
345
346 return d3drm_face1_Release(&face->IDirect3DRMFace_iface);
347 }
348
349 static HRESULT WINAPI d3drm_face2_Clone(IDirect3DRMFace2 *iface,
350 IUnknown *outer, REFIID iid, void **out)
351 {
352 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
353
354 return E_NOTIMPL;
355 }
356
357 static HRESULT WINAPI d3drm_face2_AddDestroyCallback(IDirect3DRMFace2 *iface,
358 D3DRMOBJECTCALLBACK cb, void *ctx)
359 {
360 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
361
362 return E_NOTIMPL;
363 }
364
365 static HRESULT WINAPI d3drm_face2_DeleteDestroyCallback(IDirect3DRMFace2 *iface,
366 D3DRMOBJECTCALLBACK cb, void *ctx)
367 {
368 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
369
370 return E_NOTIMPL;
371 }
372
373 static HRESULT WINAPI d3drm_face2_SetAppData(IDirect3DRMFace2 *iface, DWORD data)
374 {
375 FIXME("iface %p, data %#x stub!\n", iface, data);
376
377 return E_NOTIMPL;
378 }
379
380 static DWORD WINAPI d3drm_face2_GetAppData(IDirect3DRMFace2 *iface)
381 {
382 FIXME("iface %p stub!\n", iface);
383
384 return 0;
385 }
386
387 static HRESULT WINAPI d3drm_face2_SetName(IDirect3DRMFace2 *iface, const char *name)
388 {
389 FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
390
391 return E_NOTIMPL;
392 }
393
394 static HRESULT WINAPI d3drm_face2_GetName(IDirect3DRMFace2 *iface, DWORD *size, char *name)
395 {
396 FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
397
398 return E_NOTIMPL;
399 }
400
401 static HRESULT WINAPI d3drm_face2_GetClassName(IDirect3DRMFace2 *iface, DWORD *size, char *name)
402 {
403 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
404
405 if (!size || *size < strlen("Face") || !name)
406 return E_INVALIDARG;
407
408 strcpy(name, "Face");
409 *size = sizeof("Face");
410
411 return D3DRM_OK;
412 }
413
414 static HRESULT WINAPI d3drm_face2_AddVertex(IDirect3DRMFace2 *iface, D3DVALUE x, D3DVALUE y, D3DVALUE z)
415 {
416 FIXME("iface %p, x %.8e, y %.8e, z %.8e stub!\n", iface, x, y, z);
417
418 return E_NOTIMPL;
419 }
420
421 static HRESULT WINAPI d3drm_face2_AddVertexAndNormalIndexed(IDirect3DRMFace2 *iface,
422 DWORD vertex, DWORD normal)
423 {
424 FIXME("iface %p, vertex %u, normal %u stub!\n", iface, vertex, normal);
425
426 return E_NOTIMPL;
427 }
428
429 static HRESULT WINAPI d3drm_face2_SetColorRGB(IDirect3DRMFace2 *iface, D3DVALUE r, D3DVALUE g, D3DVALUE b)
430 {
431 FIXME("iface %p, r %.8e, g %.8e, b %.8e stub!\n", iface, r, g, b);
432
433 return E_NOTIMPL;
434 }
435
436 static HRESULT WINAPI d3drm_face2_SetColor(IDirect3DRMFace2 *iface, D3DCOLOR color)
437 {
438 FIXME("iface %p, color 0x%08x stub!\n", iface, color);
439
440 return E_NOTIMPL;
441 }
442
443 static HRESULT WINAPI d3drm_face2_SetTexture(IDirect3DRMFace2 *iface, IDirect3DRMTexture3 *texture)
444 {
445 FIXME("iface %p, texture %p stub!\n", iface, texture);
446
447 return E_NOTIMPL;
448 }
449
450 static HRESULT WINAPI d3drm_face2_SetTextureCoordinates(IDirect3DRMFace2 *iface,
451 DWORD vertex, D3DVALUE u, D3DVALUE v)
452 {
453 FIXME("iface %p, vertex %u, u %.8e, v %.8e stub!\n", iface, vertex, u, v);
454
455 return E_NOTIMPL;
456 }
457
458 static HRESULT WINAPI d3drm_face2_SetMaterial(IDirect3DRMFace2 *iface, IDirect3DRMMaterial2 *material)
459 {
460 FIXME("iface %p, material %p stub!\n", iface, material);
461
462 return E_NOTIMPL;
463 }
464
465 static HRESULT WINAPI d3drm_face2_SetTextureTopology(IDirect3DRMFace2 *iface, BOOL wrap_u, BOOL wrap_v)
466 {
467 FIXME("iface %p, wrap_u %#x, wrap_v %#x stub!\n", iface, wrap_u, wrap_v);
468
469 return E_NOTIMPL;
470 }
471
472 static HRESULT WINAPI d3drm_face2_GetVertex(IDirect3DRMFace2 *iface,
473 DWORD index, D3DVECTOR *vertex, D3DVECTOR *normal)
474 {
475 FIXME("iface %p, index %u, vertex %p, normal %p stub!\n", iface, index, vertex, normal);
476
477 return E_NOTIMPL;
478 }
479
480 static HRESULT WINAPI d3drm_face2_GetVertices(IDirect3DRMFace2 *iface,
481 DWORD *vertex_count, D3DVECTOR *coords, D3DVECTOR *normals)
482 {
483 FIXME("iface %p, vertex_count %p, coords %p, normals %p stub!\n",
484 iface, vertex_count, coords, normals);
485
486 return E_NOTIMPL;
487 }
488
489 static HRESULT WINAPI d3drm_face2_GetTextureCoordinates(IDirect3DRMFace2 *iface,
490 DWORD vertex, D3DVALUE *u, D3DVALUE *v)
491 {
492 FIXME("iface %p, vertex %u, u %p, v %p stub!\n", iface, vertex, u, v);
493
494 return E_NOTIMPL;
495 }
496
497 static HRESULT WINAPI d3drm_face2_GetTextureTopology(IDirect3DRMFace2 *iface, BOOL *wrap_u, BOOL *wrap_v)
498 {
499 FIXME("iface %p, wrap_u %p, wrap_v %p stub!\n", iface, wrap_u, wrap_v);
500
501 return E_NOTIMPL;
502 }
503
504 static HRESULT WINAPI d3drm_face2_GetNormal(IDirect3DRMFace2 *iface, D3DVECTOR *normal)
505 {
506 FIXME("iface %p, normal %p stub!\n", iface, normal);
507
508 return E_NOTIMPL;
509 }
510
511 static HRESULT WINAPI d3drm_face2_GetTexture(IDirect3DRMFace2 *iface, IDirect3DRMTexture3 **texture)
512 {
513 FIXME("iface %p, texture %p stub!\n", iface, texture);
514
515 return E_NOTIMPL;
516 }
517
518 static HRESULT WINAPI d3drm_face2_GetMaterial(IDirect3DRMFace2 *iface, IDirect3DRMMaterial2 **material)
519 {
520 FIXME("iface %p, material %p stub!\n", iface, material);
521
522 return E_NOTIMPL;
523 }
524
525 static int WINAPI d3drm_face2_GetVertexCount(IDirect3DRMFace2 *iface)
526 {
527 FIXME("iface %p stub!\n", iface);
528
529 return 0;
530 }
531
532 static int WINAPI d3drm_face2_GetVertexIndex(IDirect3DRMFace2 *iface, DWORD which)
533 {
534 FIXME("iface %p, which %u stub!\n", iface, which);
535
536 return 0;
537 }
538
539 static int WINAPI d3drm_face2_GetTextureCoordinateIndex(IDirect3DRMFace2 *iface, DWORD which)
540 {
541 FIXME("iface %p, which %u stub!\n", iface, which);
542
543 return 0;
544 }
545
546 static D3DCOLOR WINAPI d3drm_face2_GetColor(IDirect3DRMFace2 *iface)
547 {
548 FIXME("iface %p stub!\n", iface);
549
550 return 0;
551 }
552
553 static const struct IDirect3DRMFace2Vtbl d3drm_face2_vtbl =
554 {
555 d3drm_face2_QueryInterface,
556 d3drm_face2_AddRef,
557 d3drm_face2_Release,
558 d3drm_face2_Clone,
559 d3drm_face2_AddDestroyCallback,
560 d3drm_face2_DeleteDestroyCallback,
561 d3drm_face2_SetAppData,
562 d3drm_face2_GetAppData,
563 d3drm_face2_SetName,
564 d3drm_face2_GetName,
565 d3drm_face2_GetClassName,
566 d3drm_face2_AddVertex,
567 d3drm_face2_AddVertexAndNormalIndexed,
568 d3drm_face2_SetColorRGB,
569 d3drm_face2_SetColor,
570 d3drm_face2_SetTexture,
571 d3drm_face2_SetTextureCoordinates,
572 d3drm_face2_SetMaterial,
573 d3drm_face2_SetTextureTopology,
574 d3drm_face2_GetVertex,
575 d3drm_face2_GetVertices,
576 d3drm_face2_GetTextureCoordinates,
577 d3drm_face2_GetTextureTopology,
578 d3drm_face2_GetNormal,
579 d3drm_face2_GetTexture,
580 d3drm_face2_GetMaterial,
581 d3drm_face2_GetVertexCount,
582 d3drm_face2_GetVertexIndex,
583 d3drm_face2_GetTextureCoordinateIndex,
584 d3drm_face2_GetColor,
585 };
586
587 HRESULT Direct3DRMFace_create(REFIID riid, IUnknown **out)
588 {
589 struct d3drm_face *object;
590
591 TRACE("riid %s, out %p.\n", debugstr_guid(riid), out);
592
593 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
594 return E_OUTOFMEMORY;
595
596 object->IDirect3DRMFace_iface.lpVtbl = &d3drm_face1_vtbl;
597 object->IDirect3DRMFace2_iface.lpVtbl = &d3drm_face2_vtbl;
598 object->ref = 1;
599
600 if (IsEqualGUID(riid, &IID_IDirect3DRMFace2))
601 *out = (IUnknown*)&object->IDirect3DRMFace2_iface;
602 else
603 *out = (IUnknown*)&object->IDirect3DRMFace_iface;
604
605 return S_OK;
606 }