ReactOS 0.4.17-dev-966-gf06eace
viewport.c
Go to the documentation of this file.
1/* Direct3D Viewport
2 * Copyright (c) 1998 Lionel ULMER
3 * Copyright (c) 2006-2007 Stefan DÖSINGER
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include "ddraw_private.h"
21
23
24/*****************************************************************************
25 * Helper functions
26 *****************************************************************************/
27
29 struct wined3d_vec3 *scale, struct wined3d_vec3 *offset)
30{
31 struct wined3d_matrix clip_space =
32 {
33 scale->x, 0.0f, 0.0f, 0.0f,
34 0.0f, scale->y, 0.0f, 0.0f,
35 0.0f, 0.0f, scale->z, 0.0f,
36 offset->x, offset->y, offset->z, 1.0f,
37 };
38 struct wined3d_matrix projection;
39
40 multiply_matrix(&projection, &clip_space, &device->legacy_projection);
42 device->legacy_clipspace = clip_space;
43}
44
45/*****************************************************************************
46 * viewport_activate
47 *
48 * activates the viewport using IDirect3DDevice7::SetViewport
49 *
50 *****************************************************************************/
51void viewport_activate(struct d3d_viewport *This, BOOL ignore_lights)
52{
54 D3DVIEWPORT7 vp;
55
56 if (!ignore_lights)
57 {
58 struct d3d_light *light;
59
60 /* Activate all the lights associated with this context */
61 LIST_FOR_EACH_ENTRY(light, &This->light_list, struct d3d_light, entry)
62 {
64 }
65 }
66
67 if (This->version == DDRAW_VIEWPORT_VERSION_NONE)
68 {
69 TRACE("Viewport data was not set.\n");
70 return;
71 }
72
73 /* And copy the values in the structure used by the device */
74 if (This->version == DDRAW_VIEWPORT_VERSION_2)
75 {
76 vp.dwX = This->viewports.vp2.dwX;
77 vp.dwY = This->viewports.vp2.dwY;
78 vp.dwHeight = This->viewports.vp2.dwHeight;
79 vp.dwWidth = This->viewports.vp2.dwWidth;
80 vp.dvMinZ = 0.0f;
81 vp.dvMaxZ = 1.0f;
82
83 scale.x = 2.0f / This->viewports.vp2.dvClipWidth;
84 scale.y = 2.0f / This->viewports.vp2.dvClipHeight;
85 scale.z = 1.0f / (This->viewports.vp2.dvMaxZ - This->viewports.vp2.dvMinZ);
86 offset.x = -2.0f * This->viewports.vp2.dvClipX / This->viewports.vp2.dvClipWidth - 1.0f;
87 offset.y = -2.0f * This->viewports.vp2.dvClipY / This->viewports.vp2.dvClipHeight + 1.0f;
88 offset.z = -This->viewports.vp2.dvMinZ / (This->viewports.vp2.dvMaxZ - This->viewports.vp2.dvMinZ);
89 }
90 else
91 {
92 vp.dwX = This->viewports.vp1.dwX;
93 vp.dwY = This->viewports.vp1.dwY;
94 vp.dwHeight = This->viewports.vp1.dwHeight;
95 vp.dwWidth = This->viewports.vp1.dwWidth;
96 vp.dvMinZ = 0.0f;
97 vp.dvMaxZ = 1.0f;
98
99 scale.x = 2.0f * This->viewports.vp1.dvScaleX / This->viewports.vp1.dwWidth;
100 scale.y = 2.0f * This->viewports.vp1.dvScaleY / This->viewports.vp1.dwHeight;
101 scale.z = 1.0f;
102 offset.x = 0.0f;
103 offset.y = 0.0f;
104 offset.z = 0.0f;
105 }
106
107 update_clip_space(This->active_device, &scale, &offset);
108 IDirect3DDevice7_SetViewport(&This->active_device->IDirect3DDevice7_iface, &vp);
109}
110
111void viewport_deactivate(struct d3d_viewport *viewport)
112{
113 struct d3d_light *light;
114
116 {
118 }
119}
120
122{
123 struct d3d_viewport *vp = light->active_viewport;
124 unsigned int i, map;
125
126 TRACE("vp %p, light %p, index %lu, active_lights_count %lu.\n",
127 vp, light, light->active_light_index, vp->active_lights_count);
128
129 if (light->active_light_index)
130 return;
131
133 {
134 struct d3d_light *l;
135
137 {
138 if (l->active_light_index)
139 {
140 WARN("Too many active lights, viewport %p, light %p, deactivating %p.\n", vp, light, l);
142
143 /* Recycle active lights in a FIFO way. */
144 list_remove(&light->entry);
145 list_add_tail(&vp->light_list, &light->entry);
146 break;
147 }
148 }
149 }
150
151 map = ~vp->map_lights;
154 light->active_light_index = i + 1;
156 vp->map_lights |= 1u << i;
157}
158
160{
161 struct d3d_viewport *vp = light->active_viewport;
162
163 TRACE("vp %p, light %p, index %lu, active_lights_count %lu, map_lights %#lx.\n",
164 vp, light, light->active_light_index, vp->active_lights_count, vp->map_lights);
165
166 if (!light->active_light_index)
167 return;
168
169 assert(vp->map_lights & (1u << (light->active_light_index - 1)));
170
172 vp->map_lights &= ~(1u << (light->active_light_index - 1));
173 light->active_light_index = 0;
174}
175
176/*****************************************************************************
177 * _dump_D3DVIEWPORT, _dump_D3DVIEWPORT2
178 *
179 * Writes viewport information to TRACE
180 *
181 *****************************************************************************/
182static void _dump_D3DVIEWPORT(const D3DVIEWPORT *lpvp)
183{
184 TRACE(" - dwSize = %lu dwX = %lu dwY = %lu\n",
185 lpvp->dwSize, lpvp->dwX, lpvp->dwY);
186 TRACE(" - dwWidth = %lu dwHeight = %lu\n",
187 lpvp->dwWidth, lpvp->dwHeight);
188 TRACE(" - dvScaleX = %f dvScaleY = %f\n",
189 lpvp->dvScaleX, lpvp->dvScaleY);
190 TRACE(" - dvMaxX = %f dvMaxY = %f\n",
191 lpvp->dvMaxX, lpvp->dvMaxY);
192 TRACE(" - dvMinZ = %f dvMaxZ = %f\n",
193 lpvp->dvMinZ, lpvp->dvMaxZ);
194}
195
196static void _dump_D3DVIEWPORT2(const D3DVIEWPORT2 *lpvp)
197{
198 TRACE(" - dwSize = %lu dwX = %lu dwY = %lu\n",
199 lpvp->dwSize, lpvp->dwX, lpvp->dwY);
200 TRACE(" - dwWidth = %lu dwHeight = %lu\n",
201 lpvp->dwWidth, lpvp->dwHeight);
202 TRACE(" - dvClipX = %f dvClipY = %f\n",
203 lpvp->dvClipX, lpvp->dvClipY);
204 TRACE(" - dvClipWidth = %f dvClipHeight = %f\n",
205 lpvp->dvClipWidth, lpvp->dvClipHeight);
206 TRACE(" - dvMinZ = %f dvMaxZ = %f\n",
207 lpvp->dvMinZ, lpvp->dvMaxZ);
208}
209
210static inline struct d3d_viewport *impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
211{
213}
214
215/*****************************************************************************
216 * IUnknown Methods.
217 *****************************************************************************/
218
219/*****************************************************************************
220 * IDirect3DViewport3::QueryInterface
221 *
222 * A normal QueryInterface. Can query all interface versions and the
223 * IUnknown interface. The VTables of the different versions
224 * are equal
225 *
226 * Params:
227 * refiid: Interface id queried for
228 * obj: Address to write the interface pointer to
229 *
230 * Returns:
231 * S_OK on success.
232 * E_NOINTERFACE if the requested interface wasn't found
233 *
234 *****************************************************************************/
235static HRESULT WINAPI d3d_viewport_QueryInterface(IDirect3DViewport3 *iface, REFIID riid, void **object)
236{
237 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
238
239 if (IsEqualGUID(&IID_IDirect3DViewport3, riid)
240 || IsEqualGUID(&IID_IDirect3DViewport2, riid)
241 || IsEqualGUID(&IID_IDirect3DViewport, riid)
243 {
245 *object = iface;
246 return S_OK;
247 }
248
249 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
250
251 *object = NULL;
252 return E_NOINTERFACE;
253}
254
255/*****************************************************************************
256 * IDirect3DViewport3::AddRef
257 *
258 * Increases the refcount.
259 *
260 * Returns:
261 * The new refcount
262 *
263 *****************************************************************************/
264static ULONG WINAPI d3d_viewport_AddRef(IDirect3DViewport3 *iface)
265{
266 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
267 ULONG ref = InterlockedIncrement(&viewport->ref);
268
269 TRACE("%p increasing refcount to %lu.\n", viewport, ref);
270
271 return ref;
272}
273
274/*****************************************************************************
275 * IDirect3DViewport3::Release
276 *
277 * Reduces the refcount. If it falls to 0, the interface is released
278 *
279 * Returns:
280 * The new refcount
281 *
282 *****************************************************************************/
283static ULONG WINAPI d3d_viewport_Release(IDirect3DViewport3 *iface)
284{
285 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
286 ULONG ref = InterlockedDecrement(&viewport->ref);
287
288 TRACE("%p decreasing refcount to %lu.\n", viewport, ref);
289
290 if (!ref)
291 free(viewport);
292
293 return ref;
294}
295
296/*****************************************************************************
297 * IDirect3DViewport Methods.
298 *****************************************************************************/
299
300/*****************************************************************************
301 * IDirect3DViewport3::Initialize
302 *
303 * No-op initialization.
304 *
305 * Params:
306 * Direct3D: The direct3D device this viewport is assigned to
307 *
308 * Returns:
309 * DDERR_ALREADYINITIALIZED
310 *
311 *****************************************************************************/
312static HRESULT WINAPI d3d_viewport_Initialize(IDirect3DViewport3 *iface, IDirect3D *d3d)
313{
314 TRACE("iface %p, d3d %p.\n", iface, d3d);
315
317}
318
319static HRESULT WINAPI d3d_viewport_GetViewport(IDirect3DViewport3 *iface, D3DVIEWPORT *vp)
320{
321 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
322 DWORD size;
323
324 TRACE("iface %p, vp %p.\n", iface, vp);
325
326 if (!vp)
327 return DDERR_INVALIDPARAMS;
328
329 if (viewport->version == DDRAW_VIEWPORT_VERSION_NONE)
330 {
331 WARN("Viewport data was not set.\n");
333 }
334
336
337 size = vp->dwSize;
338 if (viewport->version == DDRAW_VIEWPORT_VERSION_1)
339 {
340 memcpy(vp, &viewport->viewports.vp1, size);
341 }
342 else
343 {
345
346 vp1.dwSize = sizeof(vp1);
347 vp1.dwX = viewport->viewports.vp2.dwX;
348 vp1.dwY = viewport->viewports.vp2.dwY;
349 vp1.dwWidth = viewport->viewports.vp2.dwWidth;
350 vp1.dwHeight = viewport->viewports.vp2.dwHeight;
351
354 vp1.dvMaxX = viewport->viewports.vp2.dvClipWidth + viewport->viewports.vp2.dvClipX;
355 vp1.dvMaxY = viewport->viewports.vp2.dvClipY;
356 vp1.dvMinZ = 0.0f;
357 vp1.dvMaxZ = 1.0f;
358 memcpy(vp, &vp1, size);
359 }
360
361 if (TRACE_ON(ddraw))
362 {
363 TRACE(" returning D3DVIEWPORT :\n");
365 }
366
368
369 return D3D_OK;
370}
371
372static HRESULT WINAPI d3d_viewport_SetViewport(IDirect3DViewport3 *iface, D3DVIEWPORT *vp)
373{
374 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
375 struct d3d_device *device = viewport->active_device;
376 struct wined3d_sub_resource_desc rt_desc;
377 struct wined3d_rendertarget_view *rtv;
378 IDirect3DViewport3 *current_viewport;
379 struct ddraw_surface *surface;
380
381 TRACE("iface %p, vp %p.\n", iface, vp);
382
383 if (!vp)
384 return DDERR_INVALIDPARAMS;
385
386 if (vp->dwSize != sizeof(*vp))
387 {
388 WARN("Invalid D3DVIEWPORT size %lu.\n", vp->dwSize);
389 return DDERR_INVALIDPARAMS;
390 }
391
392 if (TRACE_ON(ddraw))
393 {
394 TRACE(" getting D3DVIEWPORT :\n");
396 }
397
398 if (!device)
399 {
400 WARN("Viewport not bound to a device, returning D3DERR_VIEWPORTHASNODEVICE.\n");
402 }
403
405
406 if (device->version > 1)
407 {
408 rtv = device->target ? ddraw_surface_get_rendertarget_view(device->target) : NULL;
409 if (!rtv)
410 {
412 return DDERR_INVALIDCAPS;
413 }
416
417 if (!wined3d_bound_range(vp->dwX, vp->dwWidth, rt_desc.width)
418 || !wined3d_bound_range(vp->dwY, vp->dwHeight, rt_desc.height))
419 {
420 WARN("Invalid viewport, returning DDERR_INVALIDPARAMS.\n");
422 return DDERR_INVALIDPARAMS;
423 }
424 }
425
427 viewport->viewports.vp1 = *vp;
428
429 /* Empirical testing on a couple of d3d1 games showed that these values
430 * should be ignored. */
431 viewport->viewports.vp1.dvMinZ = 0.0f;
432 viewport->viewports.vp1.dvMaxZ = 1.0f;
433
434 if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(&device->IDirect3DDevice3_iface, &current_viewport)))
435 {
436 if (current_viewport == iface)
437 viewport_activate(viewport, FALSE);
438 IDirect3DViewport3_Release(current_viewport);
439 }
440
442
443 return D3D_OK;
444}
445
446/*****************************************************************************
447 * IDirect3DViewport3::TransformVertices
448 *
449 * Transforms vertices by the transformation matrix.
450 *
451 * This function is pretty similar to IDirect3DVertexBuffer7::ProcessVertices,
452 * so it's tempting to forward it to there. However, there are some
453 * tiny differences. First, the lpOffscreen flag that is reported back,
454 * then there is the homogeneous vertex that is generated. Also there's a lack
455 * of FVFs, but still a custom stride. Last, the d3d1 - d3d3 viewport has some
456 * settings (scale) that d3d7 and wined3d do not have. All in all wrapping to
457 * ProcessVertices doesn't pay of in terms of wrapper code needed and code
458 * reused.
459 *
460 * Params:
461 * dwVertexCount: The number of vertices to be transformed
462 * data: Pointer to the vertex input / output data.
463 * dwFlags: D3DTRANSFORM_CLIPPED or D3DTRANSFORM_UNCLIPPED
464 * offscreen: Logical AND of the planes that clipped the vertices if clipping
465 * is on. 0 if clipping is off.
466 *
467 * Returns:
468 * D3D_OK on success
469 * D3DERR_VIEWPORTHASNODEVICE if the viewport is not assigned to a device
470 * DDERR_INVALIDPARAMS if no clipping flag is specified
471 *
472 *****************************************************************************/
474{
475 float x, y, z, w; /* w is unused in input data. */
476 struct
477 {
480};
481
482static HRESULT WINAPI d3d_viewport_TransformVertices(IDirect3DViewport3 *iface,
483 DWORD dwVertexCount, D3DTRANSFORMDATA *data, DWORD dwFlags, DWORD *offscreen)
484{
485 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
486 const struct wined3d_stateblock_state *state;
487 D3DVIEWPORT vp = viewport->viewports.vp1;
489 struct wined3d_matrix mat;
490 float x, y, z, w;
491 unsigned int i;
492 D3DHVERTEX *outH;
493 struct d3d_device *device = viewport->active_device;
494 BOOL activate = device->current_viewport != viewport;
495
496 TRACE("iface %p, vertex_count %lu, data %p, flags %#lx, offscreen %p.\n",
497 iface, dwVertexCount, data, dwFlags, offscreen);
498
499 /* Tests on windows show that Windows crashes when this occurs,
500 * so don't return the (intuitive) return value
501 if (!device)
502 {
503 WARN("No device active, returning D3DERR_VIEWPORTHASNODEVICE\n");
504 return D3DERR_VIEWPORTHASNODEVICE;
505 }
506 */
507
508 if (!data || data->dwSize != sizeof(*data))
509 {
510 WARN("Transform data is NULL or size is incorrect, returning DDERR_INVALIDPARAMS\n");
511 return DDERR_INVALIDPARAMS;
512 }
514 {
515 WARN("No clipping flag passed, returning DDERR_INVALIDPARAMS\n");
516 return DDERR_INVALIDPARAMS;
517 }
518
520 if (activate)
521 viewport_activate(viewport, TRUE);
522
523 state = device->stateblock_state;
524 multiply_matrix(&mat, &state->transforms[WINED3D_TS_VIEW], &state->transforms[WINED3D_TS_WORLD_MATRIX(0)]);
526
527 /* The pointer is not tested against NULL on Windows. */
529 *offscreen = ~0U;
530 else
531 *offscreen = 0;
532
533 outH = data->lpHOut;
534 for(i = 0; i < dwVertexCount; i++)
535 {
536 in = (struct transform_vertices_vertex *)((char *)data->lpIn + data->dwInSize * i);
537 out = (struct transform_vertices_vertex *)((char *)data->lpOut + data->dwOutSize * i);
538
539 x = (in->x * mat._11) + (in->y * mat._21) + (in->z * mat._31) + mat._41;
540 y = (in->x * mat._12) + (in->y * mat._22) + (in->z * mat._32) + mat._42;
541 z = (in->x * mat._13) + (in->y * mat._23) + (in->z * mat._33) + mat._43;
542 w = (in->x * mat._14) + (in->y * mat._24) + (in->z * mat._34) + mat._44;
543
545 {
546 /* If clipping is enabled, Windows assumes that outH is
547 * a valid pointer. */
548 outH[i].hx = (x - device->legacy_clipspace._41 * w) / device->legacy_clipspace._11;
549 outH[i].hy = (y - device->legacy_clipspace._42 * w) / device->legacy_clipspace._22;
550 outH[i].hz = (z - device->legacy_clipspace._43 * w) / device->legacy_clipspace._33;
551
552 outH[i].dwFlags = 0;
553 if (x > w)
554 outH[i].dwFlags |= D3DCLIP_RIGHT;
555 if (x < -w)
556 outH[i].dwFlags |= D3DCLIP_LEFT;
557 if (y > w)
558 outH[i].dwFlags |= D3DCLIP_TOP;
559 if (y < -w)
560 outH[i].dwFlags |= D3DCLIP_BOTTOM;
561 if (z < 0.0f)
562 outH[i].dwFlags |= D3DCLIP_FRONT;
563 if (z > w)
564 outH[i].dwFlags |= D3DCLIP_BACK;
565
566 *offscreen &= outH[i].dwFlags;
567
568 if(outH[i].dwFlags)
569 {
570 /* Looks like native just drops the vertex, leaves whatever data
571 * it has in the output buffer and goes on with the next vertex.
572 * The exact scheme hasn't been figured out yet, but windows
573 * definitely writes something there.
574 */
575 out->x = x;
576 out->y = y;
577 out->z = z;
578 out->w = w;
579 continue;
580 }
581 }
582
583 w = 1 / w;
584 x *= w; y *= w; z *= w;
585
586 out->x = (x + 1.0f) * vp.dwWidth * 0.5 + vp.dwX;
587 out->y = (-y + 1.0f) * vp.dwHeight * 0.5 + vp.dwY;
588 out->z = z;
589 out->w = w;
590 out->payload = in->payload;
591 }
592
593 if (activate && device->current_viewport)
594 viewport_activate(device->current_viewport, TRUE);
595
597
598 TRACE("All done\n");
599 return DD_OK;
600}
601
602/*****************************************************************************
603 * IDirect3DViewport3::LightElements
604 *
605 * The DirectX 5.0 sdk says that it's not implemented
606 *
607 * Params:
608 * ?
609 *
610 * Returns:
611 * DDERR_UNSUPPORTED
612 *
613 *****************************************************************************/
614static HRESULT WINAPI d3d_viewport_LightElements(IDirect3DViewport3 *iface,
616{
617 TRACE("iface %p, element_count %lu, data %p.\n", iface, element_count, data);
618
619 return DDERR_UNSUPPORTED;
620}
621
622static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE material)
623{
624 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
625 struct d3d_material *m;
626
627 TRACE("iface %p, material %#lx.\n", iface, material);
628
630
631 if (!(m = ddraw_get_object(NULL, material - 1, DDRAW_HANDLE_MATERIAL)))
632 {
633 WARN("Invalid material handle %#lx.\n", material);
635 return DDERR_INVALIDPARAMS;
636 }
637
638 TRACE("Setting background color : %.8e %.8e %.8e %.8e.\n",
639 m->mat.diffuse.r, m->mat.diffuse.g,
640 m->mat.diffuse.b, m->mat.diffuse.a);
641 viewport->background = m;
642
644
645 return D3D_OK;
646}
647
648/*****************************************************************************
649 * IDirect3DViewport3::GetBackground
650 *
651 * Returns the material handle assigned to the background of the viewport
652 *
653 * Params:
654 * lphMat: Address to store the handle
655 * lpValid: is set to FALSE if no background is set, TRUE if one is set
656 *
657 * Returns:
658 * D3D_OK
659 *
660 *****************************************************************************/
661static HRESULT WINAPI d3d_viewport_GetBackground(IDirect3DViewport3 *iface,
662 D3DMATERIALHANDLE *material, BOOL *valid)
663{
664 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
665
666 TRACE("iface %p, material %p, valid %p.\n", iface, material, valid);
667
669 if (valid)
670 *valid = !!viewport->background;
671 if (material)
672 *material = viewport->background ? viewport->background->Handle : 0;
674
675 return D3D_OK;
676}
677
678/*****************************************************************************
679 * IDirect3DViewport3::SetBackgroundDepth
680 *
681 * Sets a surface that represents the background depth. Its contents are
682 * used to set the depth buffer in IDirect3DViewport3::Clear
683 *
684 * Params:
685 * lpDDSurface: Surface to set
686 *
687 * Returns: D3D_OK, because it's a stub
688 *
689 *****************************************************************************/
690static HRESULT WINAPI d3d_viewport_SetBackgroundDepth(IDirect3DViewport3 *iface, IDirectDrawSurface *surface)
691{
692 FIXME("iface %p, surface %p stub!\n", iface, surface);
693
694 return D3D_OK;
695}
696
697/*****************************************************************************
698 * IDirect3DViewport3::GetBackgroundDepth
699 *
700 * Returns the surface that represents the depth field
701 *
702 * Params:
703 * lplpDDSurface: Address to store the interface pointer
704 * lpValid: Set to TRUE if a depth is assigned, FALSE otherwise
705 *
706 * Returns:
707 * D3D_OK, because it's a stub
708 * (DDERR_INVALIDPARAMS if DDSurface of Valid is NULL)
709 *
710 *****************************************************************************/
711static HRESULT WINAPI d3d_viewport_GetBackgroundDepth(IDirect3DViewport3 *iface,
712 IDirectDrawSurface **surface, BOOL *valid)
713{
714 FIXME("iface %p, surface %p, valid %p stub!\n", iface, surface, valid);
715
716 return DD_OK;
717}
718
719/*****************************************************************************
720 * IDirect3DViewport3::Clear
721 *
722 * Clears the render target and / or the z buffer
723 *
724 * Params:
725 * dwCount: The amount of rectangles to clear. If 0, the whole buffer is
726 * cleared
727 * lpRects: Pointer to the array of rectangles. If NULL, Count must be 0
728 * dwFlags: D3DCLEAR_ZBUFFER and / or D3DCLEAR_TARGET
729 *
730 * Returns:
731 * D3D_OK on success
732 * D3DERR_VIEWPORTHASNODEVICE if there's no active device
733 * The return value of IDirect3DDevice7::Clear
734 *
735 *****************************************************************************/
736static HRESULT WINAPI d3d_viewport_Clear(IDirect3DViewport3 *iface,
737 DWORD rect_count, D3DRECT *rects, DWORD flags)
738{
740 DWORD color = 0x00000000;
741 HRESULT hr;
742 IDirect3DViewport3 *current_viewport;
743 IDirect3DDevice3 *d3d_device3;
744
745 TRACE("iface %p, rect_count %lu, rects %p, flags %#lx.\n", iface, rect_count, rects, flags);
746
747 if (!rects || !rect_count)
748 {
749 WARN("rect_count = %lu, rects = %p, ignoring clear\n", rect_count, rects);
750 return D3D_OK;
751 }
752
753 if (This->active_device == NULL) {
754 ERR(" Trying to clear a viewport not attached to a device!\n");
756 }
757 d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
758
760
762 {
763 if (!This->background)
764 WARN("No background material set.\n");
765 else
766 color = D3DRGBA(This->background->mat.diffuse.r,
767 This->background->mat.diffuse.g,
768 This->background->mat.diffuse.b,
769 This->background->mat.diffuse.a);
770 }
771
772 /* Need to temporarily activate the viewport to clear it. The previously
773 * active one will be restored afterwards. */
775
776 hr = IDirect3DDevice7_Clear(&This->active_device->IDirect3DDevice7_iface, rect_count, rects,
777 flags & (D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET), color, 1.0, 0x00000000);
778
779 if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport)))
780 {
781 struct d3d_viewport *vp = impl_from_IDirect3DViewport3(current_viewport);
783 IDirect3DViewport3_Release(current_viewport);
784 }
785
787
788 return hr;
789}
790
791/*****************************************************************************
792 * IDirect3DViewport3::AddLight
793 *
794 * Adds an light to the viewport
795 *
796 * Params:
797 * lpDirect3DLight: Interface of the light to add
798 *
799 * Returns:
800 * D3D_OK on success
801 * DDERR_INVALIDPARAMS if Direct3DLight is NULL
802 * DDERR_INVALIDPARAMS if there are 8 lights or more
803 *
804 *****************************************************************************/
805static HRESULT WINAPI d3d_viewport_AddLight(IDirect3DViewport3 *viewport, IDirect3DLight *light)
806{
807 struct d3d_light *light_impl = unsafe_impl_from_IDirect3DLight(light);
808 struct d3d_viewport *vp = impl_from_IDirect3DViewport3(viewport);
809
810 TRACE("viewport %p, light %p.\n", viewport, light);
811
813
814 if (light_impl->active_viewport)
815 {
817 WARN("Light %p is active in viewport %p.\n", light_impl, light_impl->active_viewport);
819 }
820
821 light_impl->active_viewport = vp;
822
823 /* Add the light in the 'linked' chain */
824 list_add_tail(&vp->light_list, &light_impl->entry);
826
827 light_activate(light_impl);
828
830
831 return D3D_OK;
832}
833
834/*****************************************************************************
835 * IDirect3DViewport3::DeleteLight
836 *
837 * Deletes a light from the viewports' light list
838 *
839 * Params:
840 * lpDirect3DLight: Light to delete
841 *
842 * Returns:
843 * D3D_OK on success
844 * DDERR_INVALIDPARAMS if the light wasn't found
845 *
846 *****************************************************************************/
847static HRESULT WINAPI d3d_viewport_DeleteLight(IDirect3DViewport3 *iface, IDirect3DLight *lpDirect3DLight)
848{
849 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
850 struct d3d_light *l = unsafe_impl_from_IDirect3DLight(lpDirect3DLight);
851
852 TRACE("iface %p, light %p.\n", iface, lpDirect3DLight);
853
855
856 if (l->active_viewport != viewport)
857 {
858 WARN("Light %p active viewport is %p.\n", l, l->active_viewport);
860 return DDERR_INVALIDPARAMS;
861 }
862
864 list_remove(&l->entry);
865 l->active_viewport = NULL;
866 IDirect3DLight_Release(lpDirect3DLight);
867
869
870 return D3D_OK;
871}
872
873/*****************************************************************************
874 * IDirect3DViewport::NextLight
875 *
876 * Enumerates the lights associated with the viewport
877 *
878 * Params:
879 * lpDirect3DLight: Light to start with
880 * lplpDirect3DLight: Address to store the successor to
881 *
882 * Returns:
883 * D3D_OK, because it's a stub
884 *
885 *****************************************************************************/
886static HRESULT WINAPI d3d_viewport_NextLight(IDirect3DViewport3 *iface,
887 IDirect3DLight *lpDirect3DLight, IDirect3DLight **lplpDirect3DLight, DWORD flags)
888{
889 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
890 struct d3d_light *l = unsafe_impl_from_IDirect3DLight(lpDirect3DLight);
891 struct list *entry;
892 HRESULT hr;
893
894 TRACE("iface %p, light %p, next_light %p, flags %#lx.\n",
895 iface, lpDirect3DLight, lplpDirect3DLight, flags);
896
897 if (!lplpDirect3DLight)
898 return DDERR_INVALIDPARAMS;
899
901
902 switch (flags)
903 {
904 case D3DNEXT_NEXT:
905 if (!l || l->active_viewport != viewport)
906 {
907 if (l)
908 WARN("Light %p active viewport is %p.\n", l, l->active_viewport);
909 entry = NULL;
910 }
911 else
912 entry = list_next(&viewport->light_list, &l->entry);
913 break;
914
915 case D3DNEXT_HEAD:
916 entry = list_head(&viewport->light_list);
917 break;
918
919 case D3DNEXT_TAIL:
920 entry = list_tail(&viewport->light_list);
921 break;
922
923 default:
924 entry = NULL;
925 WARN("Invalid flags %#lx.\n", flags);
926 break;
927 }
928
929 if (entry)
930 {
931 *lplpDirect3DLight = (IDirect3DLight *)LIST_ENTRY(entry, struct d3d_light, entry);
932 IDirect3DLight_AddRef(*lplpDirect3DLight);
933 hr = D3D_OK;
934 }
935 else
936 {
937 *lplpDirect3DLight = NULL;
939 }
940
942
943 return hr;
944}
945
946/*****************************************************************************
947 * IDirect3DViewport2 Methods.
948 *****************************************************************************/
949
950static HRESULT WINAPI d3d_viewport_GetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *vp)
951{
952 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
953 DWORD size;
954
955 TRACE("iface %p, vp %p.\n", iface, vp);
956
957 if (!vp)
958 return DDERR_INVALIDPARAMS;
959
960 if (viewport->version == DDRAW_VIEWPORT_VERSION_NONE)
961 {
962 WARN("Viewport data was not set.\n");
964 }
965
967 size = vp->dwSize;
968 if (viewport->version == DDRAW_VIEWPORT_VERSION_2)
969 {
970 memcpy(vp, &viewport->viewports.vp2, size);
971 }
972 else
973 {
975
976 vp2.dwSize = sizeof(vp2);
977 vp2.dwX = viewport->viewports.vp1.dwX;
978 vp2.dwY = viewport->viewports.vp1.dwY;
979 vp2.dwWidth = viewport->viewports.vp1.dwWidth;
980 vp2.dwHeight = viewport->viewports.vp1.dwHeight;
981
982 vp2.dvClipWidth = viewport->viewports.vp1.dwWidth / viewport->viewports.vp1.dvScaleX;
983 vp2.dvClipHeight = viewport->viewports.vp1.dwHeight / viewport->viewports.vp1.dvScaleY;
984 vp2.dvClipX = -vp2.dvClipWidth / 2.0f;
985 vp2.dvClipY = vp2.dvClipHeight / 2.0f;
986 vp2.dvMinZ = 0.0f;
987 vp2.dvMaxZ = 1.0f;
988 memcpy(vp, &vp2, size);
989 }
990
991 if (TRACE_ON(ddraw))
992 {
993 TRACE(" returning D3DVIEWPORT2 :\n");
995 }
996
998
999 return D3D_OK;
1000}
1001
1002static HRESULT WINAPI d3d_viewport_SetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *vp)
1003{
1004 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
1005 struct d3d_device *device = viewport->active_device;
1006 struct wined3d_sub_resource_desc rt_desc;
1007 struct wined3d_rendertarget_view *rtv;
1008 IDirect3DViewport3 *current_viewport;
1009 struct ddraw_surface *surface;
1010
1011 TRACE("iface %p, vp %p.\n", iface, vp);
1012
1013 if (!vp)
1014 return DDERR_INVALIDPARAMS;
1015
1016 if (vp->dwSize != sizeof(*vp))
1017 {
1018 WARN("Invalid D3DVIEWPORT2 size %lu.\n", vp->dwSize);
1019 return DDERR_INVALIDPARAMS;
1020 }
1021
1022 if (TRACE_ON(ddraw))
1023 {
1024 TRACE(" getting D3DVIEWPORT2 :\n");
1026 }
1027
1028 if (!device)
1029 {
1030 WARN("Viewport not bound to a device, returning D3DERR_VIEWPORTHASNODEVICE.\n");
1032 }
1033
1035
1036 if (device->version > 1)
1037 {
1038 rtv = device->target ? ddraw_surface_get_rendertarget_view(device->target) : NULL;
1039 if (!rtv)
1040 {
1042 return DDERR_INVALIDCAPS;
1043 }
1046
1047 if (!wined3d_bound_range(vp->dwX, vp->dwWidth, rt_desc.width)
1048 || !wined3d_bound_range(vp->dwY, vp->dwHeight, rt_desc.height))
1049 {
1050 WARN("Invalid viewport, returning DDERR_INVALIDPARAMS.\n");
1052 return DDERR_INVALIDPARAMS;
1053 }
1054 }
1055
1057 viewport->viewports.vp2 = *vp;
1058
1059 if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(&device->IDirect3DDevice3_iface, &current_viewport)))
1060 {
1061 if (current_viewport == iface)
1062 viewport_activate(viewport, FALSE);
1063 IDirect3DViewport3_Release(current_viewport);
1064 }
1065
1067
1068 return D3D_OK;
1069}
1070
1071/*****************************************************************************
1072 * IDirect3DViewport3 Methods.
1073 *****************************************************************************/
1074
1075/*****************************************************************************
1076 * IDirect3DViewport3::SetBackgroundDepth2
1077 *
1078 * Sets a IDirectDrawSurface4 surface as the background depth surface
1079 *
1080 * Params:
1081 * lpDDS: Surface to set
1082 *
1083 * Returns:
1084 * D3D_OK, because it's stub
1085 *
1086 *****************************************************************************/
1087static HRESULT WINAPI d3d_viewport_SetBackgroundDepth2(IDirect3DViewport3 *iface,
1088 IDirectDrawSurface4 *surface)
1089{
1090 FIXME("iface %p, surface %p stub!\n", iface, surface);
1091
1092 return D3D_OK;
1093}
1094
1095/*****************************************************************************
1096 * IDirect3DViewport3::GetBackgroundDepth2
1097 *
1098 * Returns the IDirect3DSurface4 interface to the background depth surface
1099 *
1100 * Params:
1101 * lplpDDS: Address to store the interface pointer at
1102 * lpValid: Set to true if a surface is assigned
1103 *
1104 * Returns:
1105 * D3D_OK because it's a stub
1106 *
1107 *****************************************************************************/
1108static HRESULT WINAPI d3d_viewport_GetBackgroundDepth2(IDirect3DViewport3 *iface,
1109 IDirectDrawSurface4 **surface, BOOL *valid)
1110{
1111 FIXME("iface %p, surface %p, valid %p stub!\n", iface, surface, valid);
1112
1113 return D3D_OK;
1114}
1115
1116/*****************************************************************************
1117 * IDirect3DViewport3::Clear2
1118 *
1119 * Another clearing method
1120 *
1121 * Params:
1122 * Count: Number of rectangles to clear
1123 * Rects: Rectangle array to clear
1124 * Flags: Some flags :)
1125 * Color: Color to fill the render target with
1126 * Z: Value to fill the depth buffer with
1127 * Stencil: Value to fill the stencil bits with
1128 *
1129 * Returns:
1130 *
1131 *****************************************************************************/
1132static HRESULT WINAPI d3d_viewport_Clear2(IDirect3DViewport3 *iface, DWORD rect_count,
1134{
1135 struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
1136 HRESULT hr;
1137 IDirect3DViewport3 *current_viewport;
1138 IDirect3DDevice3 *d3d_device3;
1139
1140 TRACE("iface %p, rect_count %lu, rects %p, flags %#lx, color 0x%08lx, depth %.8e, stencil %lu.\n",
1141 iface, rect_count, rects, flags, color, depth, stencil);
1142
1143 if (!rects || !rect_count)
1144 {
1145 WARN("rect_count = %lu, rects = %p, ignoring clear\n", rect_count, rects);
1146 return D3D_OK;
1147 }
1148
1150
1151 if (!viewport->active_device)
1152 {
1153 WARN("Trying to clear a viewport not attached to a device.\n");
1156 }
1157 d3d_device3 = &viewport->active_device->IDirect3DDevice3_iface;
1158 /* Need to temporarily activate viewport to clear it. Previously active
1159 * one will be restored afterwards. */
1160 viewport_activate(viewport, TRUE);
1161
1162 hr = IDirect3DDevice7_Clear(&viewport->active_device->IDirect3DDevice7_iface,
1163 rect_count, rects, flags, color, depth, stencil);
1164 if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport)))
1165 {
1166 struct d3d_viewport *vp = impl_from_IDirect3DViewport3(current_viewport);
1168 IDirect3DViewport3_Release(current_viewport);
1169 }
1170
1172
1173 return hr;
1174}
1175
1176/*****************************************************************************
1177 * The VTable
1178 *****************************************************************************/
1179
1180static const struct IDirect3DViewport3Vtbl d3d_viewport_vtbl =
1181{
1182 /*** IUnknown Methods ***/
1186 /*** IDirect3DViewport Methods */
1200 /*** IDirect3DViewport2 Methods ***/
1203 /*** IDirect3DViewport3 Methods ***/
1207};
1208
1209struct d3d_viewport *unsafe_impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
1210{
1211 if (!iface) return NULL;
1212 assert(iface->lpVtbl == &d3d_viewport_vtbl);
1214}
1215
1216struct d3d_viewport *unsafe_impl_from_IDirect3DViewport2(IDirect3DViewport2 *iface)
1217{
1218 /* IDirect3DViewport and IDirect3DViewport3 use the same iface. */
1219 if (!iface) return NULL;
1220 assert(iface->lpVtbl == (IDirect3DViewport2Vtbl *)&d3d_viewport_vtbl);
1222}
1223
1224struct d3d_viewport *unsafe_impl_from_IDirect3DViewport(IDirect3DViewport *iface)
1225{
1226 /* IDirect3DViewport and IDirect3DViewport3 use the same iface. */
1227 if (!iface) return NULL;
1228 assert(iface->lpVtbl == (IDirect3DViewportVtbl *)&d3d_viewport_vtbl);
1230}
1231
1232void d3d_viewport_init(struct d3d_viewport *viewport, struct ddraw *ddraw)
1233{
1234 viewport->IDirect3DViewport3_iface.lpVtbl = &d3d_viewport_vtbl;
1235 viewport->ref = 1;
1236 viewport->ddraw = ddraw;
1238 list_init(&viewport->light_list);
1239}
static int state
Definition: maze.c:121
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define U(x)
Definition: wordpad.c:45
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
r l[0]
Definition: byte_order.h:168
Definition: list.h:39
Definition: _map.h:48
#define D3DCLEAR_ZBUFFER
Definition: d3d8types.h:31
#define D3DCLEAR_TARGET
Definition: d3d8types.h:30
#define IDirect3DLight_AddRef(p)
Definition: d3d.h:422
#define D3DERR_VIEWPORTHASNODEVICE
Definition: d3d.h:159
#define IDirect3DLight_Release(p)
Definition: d3d.h:423
#define IDirect3DViewport3_Release(p)
Definition: d3d.h:827
#define D3DNEXT_NEXT
Definition: d3d.h:192
#define D3DERR_LIGHTHASVIEWPORT
Definition: d3d.h:149
#define IDirect3DViewport3_AddRef(p)
Definition: d3d.h:826
#define IDirect3DDevice7_Clear(p, a, b, c, d, e, f)
Definition: d3d.h:1353
#define D3DERR_VIEWPORTDATANOTSET
Definition: d3d.h:158
#define D3D_OK
Definition: d3d.h:106
#define D3DNEXT_TAIL
Definition: d3d.h:194
#define IDirect3DDevice3_GetCurrentViewport(p, a)
Definition: d3d.h:1204
#define IDirect3DDevice7_SetViewport(p, a)
Definition: d3d.h:1356
#define D3DNEXT_HEAD
Definition: d3d.h:193
#define D3DTRANSFORM_UNCLIPPED
Definition: d3dtypes.h:483
#define D3DCLIP_BOTTOM
Definition: d3dtypes.h:411
#define D3DCLIP_BACK
Definition: d3dtypes.h:413
float D3DVALUE
Definition: d3dtypes.h:89
#define D3DCLIP_LEFT
Definition: d3dtypes.h:408
#define D3DTRANSFORM_CLIPPED
Definition: d3dtypes.h:482
#define D3DCLIP_RIGHT
Definition: d3dtypes.h:409
DWORD D3DMATERIALHANDLE
Definition: d3dtypes.h:154
#define D3DCLIP_FRONT
Definition: d3dtypes.h:412
#define D3DCLIP_TOP
Definition: d3dtypes.h:410
static HRESULT WINAPI d3d_viewport_Initialize(IDirect3DViewport3 *iface, IDirect3D *d3d)
Definition: viewport.c:312
static HRESULT WINAPI d3d_viewport_GetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE *material, BOOL *valid)
Definition: viewport.c:661
void viewport_alloc_active_light_index(struct d3d_light *light)
Definition: viewport.c:121
static HRESULT WINAPI d3d_viewport_SetViewport(IDirect3DViewport3 *iface, D3DVIEWPORT *vp)
Definition: viewport.c:372
void viewport_deactivate(struct d3d_viewport *viewport)
Definition: viewport.c:111
static const struct IDirect3DViewport3Vtbl d3d_viewport_vtbl
Definition: viewport.c:1180
struct d3d_viewport * unsafe_impl_from_IDirect3DViewport(IDirect3DViewport *iface)
Definition: viewport.c:1224
static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE material)
Definition: viewport.c:622
void d3d_viewport_init(struct d3d_viewport *viewport, struct ddraw *ddraw)
Definition: viewport.c:1232
static HRESULT WINAPI d3d_viewport_Clear2(IDirect3DViewport3 *iface, DWORD rect_count, D3DRECT *rects, DWORD flags, DWORD color, D3DVALUE depth, DWORD stencil)
Definition: viewport.c:1132
static ULONG WINAPI d3d_viewport_Release(IDirect3DViewport3 *iface)
Definition: viewport.c:283
static HRESULT WINAPI d3d_viewport_GetBackgroundDepth2(IDirect3DViewport3 *iface, IDirectDrawSurface4 **surface, BOOL *valid)
Definition: viewport.c:1108
static ULONG WINAPI d3d_viewport_AddRef(IDirect3DViewport3 *iface)
Definition: viewport.c:264
struct d3d_viewport * unsafe_impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:1209
static HRESULT WINAPI d3d_viewport_NextLight(IDirect3DViewport3 *iface, IDirect3DLight *lpDirect3DLight, IDirect3DLight **lplpDirect3DLight, DWORD flags)
Definition: viewport.c:886
static void _dump_D3DVIEWPORT(const D3DVIEWPORT *lpvp)
Definition: viewport.c:182
static HRESULT WINAPI d3d_viewport_TransformVertices(IDirect3DViewport3 *iface, DWORD dwVertexCount, D3DTRANSFORMDATA *data, DWORD dwFlags, DWORD *offscreen)
Definition: viewport.c:482
static HRESULT WINAPI d3d_viewport_GetViewport(IDirect3DViewport3 *iface, D3DVIEWPORT *vp)
Definition: viewport.c:319
static HRESULT WINAPI d3d_viewport_Clear(IDirect3DViewport3 *iface, DWORD rect_count, D3DRECT *rects, DWORD flags)
Definition: viewport.c:736
struct d3d_viewport * unsafe_impl_from_IDirect3DViewport2(IDirect3DViewport2 *iface)
Definition: viewport.c:1216
static HRESULT WINAPI d3d_viewport_SetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *vp)
Definition: viewport.c:1002
static HRESULT WINAPI d3d_viewport_QueryInterface(IDirect3DViewport3 *iface, REFIID riid, void **object)
Definition: viewport.c:235
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:210
static HRESULT WINAPI d3d_viewport_SetBackgroundDepth2(IDirect3DViewport3 *iface, IDirectDrawSurface4 *surface)
Definition: viewport.c:1087
static HRESULT WINAPI d3d_viewport_LightElements(IDirect3DViewport3 *iface, DWORD element_count, D3DLIGHTDATA *data)
Definition: viewport.c:614
static HRESULT WINAPI d3d_viewport_GetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *vp)
Definition: viewport.c:950
static void update_clip_space(struct d3d_device *device, struct wined3d_vec3 *scale, struct wined3d_vec3 *offset)
Definition: viewport.c:28
static HRESULT WINAPI d3d_viewport_AddLight(IDirect3DViewport3 *viewport, IDirect3DLight *light)
Definition: viewport.c:805
void viewport_activate(struct d3d_viewport *This, BOOL ignore_lights)
Definition: viewport.c:51
static HRESULT WINAPI d3d_viewport_GetBackgroundDepth(IDirect3DViewport3 *iface, IDirectDrawSurface **surface, BOOL *valid)
Definition: viewport.c:711
static void _dump_D3DVIEWPORT2(const D3DVIEWPORT2 *lpvp)
Definition: viewport.c:196
static HRESULT WINAPI d3d_viewport_SetBackgroundDepth(IDirect3DViewport3 *iface, IDirectDrawSurface *surface)
Definition: viewport.c:690
static HRESULT WINAPI d3d_viewport_DeleteLight(IDirect3DViewport3 *iface, IDirect3DLight *lpDirect3DLight)
Definition: viewport.c:847
void viewport_free_active_light_index(struct d3d_light *light)
Definition: viewport.c:159
#define DDRAW_MAX_ACTIVE_LIGHTS
Definition: ddraw_private.h:70
void light_activate(struct d3d_light *light)
Definition: light.c:48
void multiply_matrix(struct wined3d_matrix *dst, const struct wined3d_matrix *src1, const struct wined3d_matrix *src2)
Definition: utils.c:1153
void light_deactivate(struct d3d_light *light)
Definition: light.c:74
void * ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type)
Definition: main.c:213
struct wined3d_rendertarget_view * ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface)
Definition: surface.c:7053
struct d3d_light * unsafe_impl_from_IDirect3DLight(IDirect3DLight *iface)
Definition: light.c:257
@ DDRAW_HANDLE_MATERIAL
@ DDRAW_VIEWPORT_VERSION_1
@ DDRAW_VIEWPORT_VERSION_NONE
@ DDRAW_VIEWPORT_VERSION_2
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT CDECL wined3d_texture_get_sub_resource_desc(const struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_sub_resource_desc *desc)
Definition: texture.c:4055
void *CDECL wined3d_rendertarget_view_get_sub_resource_parent(const struct wined3d_rendertarget_view *view)
Definition: view.c:407
#define TRACE_ON(x)
Definition: compat.h:75
#define assert(_expr)
Definition: assert.h:32
#define D3DRGBA
Definition: dx7todx8.h:8
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOLEAN valid
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLuint color
Definition: glext.h:6243
GLuint in
Definition: glext.h:9616
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLint GLfloat GLint stencil
Definition: glext.h:6260
GLdouble GLdouble z
Definition: glext.h:5874
const GLfloat * m
Definition: glext.h:10848
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 GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
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
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_guid
Definition: kernel32.h:35
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const MAT2 mat
Definition: font.c:51
static ULONG ** element_count
Definition: exception.c:124
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define DDERR_INVALIDCAPS
Definition: ddraw.h:77
#define DD_OK
Definition: ddraw.h:188
#define DDERR_UNSUPPORTED
Definition: ddraw.h:129
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:81
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:69
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:117
__WINE_SERVER_LIST_INLINE struct list * list_tail(const struct list *list)
Definition: list.h:139
#define TRACE(s)
Definition: solgame.cpp:4
D3DVALUE hy
Definition: d3dtypes.h:208
D3DVALUE hx
Definition: d3dtypes.h:204
DWORD dwFlags
Definition: d3dtypes.h:202
D3DVALUE hz
Definition: d3dtypes.h:212
D3DVALUE dvMaxZ
Definition: d3dtypes.h:387
DWORD dwSize
Definition: d3dtypes.h:377
D3DVALUE dvClipHeight
Definition: d3dtypes.h:385
D3DVALUE dvClipY
Definition: d3dtypes.h:383
D3DVALUE dvMinZ
Definition: d3dtypes.h:386
D3DVALUE dvClipX
Definition: d3dtypes.h:382
DWORD dwHeight
Definition: d3dtypes.h:381
DWORD dwWidth
Definition: d3dtypes.h:380
D3DVALUE dvClipWidth
Definition: d3dtypes.h:384
DWORD dwHeight
Definition: d3dtypes.h:367
D3DVALUE dvMaxX
Definition: d3dtypes.h:370
D3DVALUE dvMaxZ
Definition: d3dtypes.h:373
D3DVALUE dvScaleY
Definition: d3dtypes.h:369
DWORD dwSize
Definition: d3dtypes.h:363
DWORD dwWidth
Definition: d3dtypes.h:366
DWORD dwX
Definition: d3dtypes.h:364
D3DVALUE dvMaxY
Definition: d3dtypes.h:371
DWORD dwY
Definition: d3dtypes.h:365
D3DVALUE dvScaleX
Definition: d3dtypes.h:368
D3DVALUE dvMinZ
Definition: d3dtypes.h:372
struct list entry
struct d3d_viewport * active_viewport
struct list light_list
enum ddraw_viewport_version version
struct ddraw * ddraw
struct d3d_device * active_device
struct d3d_material * background
IDirect3DViewport3 IDirect3DViewport3_iface
DWORD active_lights_count
union d3d_viewport::@288 viewports
D3DVIEWPORT vp1
D3DVIEWPORT2 vp2
unsigned int sub_resource_idx
struct wined3d_texture * wined3d_texture
Definition: devices.h:37
Definition: list.h:15
Definition: send.c:48
struct transform_vertices_vertex::@290 payload
struct wined3d_viewport viewport
Definition: wined3d.h:2195
#define LIST_ENTRY(type)
Definition: queue.h:175
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define WINAPI
Definition: msvc.h:6
void CDECL wined3d_stateblock_set_transform(struct wined3d_stateblock *stateblock, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
Definition: stateblock.c:1840
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:683
static int wined3d_bit_scan(unsigned int *x)
Definition: wined3d.h:2982
static bool wined3d_bound_range(unsigned int start, unsigned int count, unsigned int limit)
Definition: wined3d.h:2995
@ WINED3D_TS_PROJECTION
Definition: wined3d.h:668
@ WINED3D_TS_VIEW
Definition: wined3d.h:667
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539
#define E_NOINTERFACE
Definition: winerror.h:3479