ReactOS 0.4.17-dev-966-gf06eace
viewport.c File Reference
#include "ddraw_private.h"
Include dependency graph for viewport.c:

Go to the source code of this file.

Classes

struct  transform_vertices_vertex
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ddraw)
 
static void update_clip_space (struct d3d_device *device, struct wined3d_vec3 *scale, struct wined3d_vec3 *offset)
 
void viewport_activate (struct d3d_viewport *This, BOOL ignore_lights)
 
void viewport_deactivate (struct d3d_viewport *viewport)
 
void viewport_alloc_active_light_index (struct d3d_light *light)
 
void viewport_free_active_light_index (struct d3d_light *light)
 
static void _dump_D3DVIEWPORT (const D3DVIEWPORT *lpvp)
 
static void _dump_D3DVIEWPORT2 (const D3DVIEWPORT2 *lpvp)
 
static struct d3d_viewport * impl_from_IDirect3DViewport3 (IDirect3DViewport3 *iface)
 
static HRESULT WINAPI d3d_viewport_QueryInterface (IDirect3DViewport3 *iface, REFIID riid, void **object)
 
static ULONG WINAPI d3d_viewport_AddRef (IDirect3DViewport3 *iface)
 
static ULONG WINAPI d3d_viewport_Release (IDirect3DViewport3 *iface)
 
static HRESULT WINAPI d3d_viewport_Initialize (IDirect3DViewport3 *iface, IDirect3D *d3d)
 
static HRESULT WINAPI d3d_viewport_GetViewport (IDirect3DViewport3 *iface, D3DVIEWPORT *vp)
 
static HRESULT WINAPI d3d_viewport_SetViewport (IDirect3DViewport3 *iface, D3DVIEWPORT *vp)
 
static HRESULT WINAPI d3d_viewport_TransformVertices (IDirect3DViewport3 *iface, DWORD dwVertexCount, D3DTRANSFORMDATA *data, DWORD dwFlags, DWORD *offscreen)
 
static HRESULT WINAPI d3d_viewport_LightElements (IDirect3DViewport3 *iface, DWORD element_count, D3DLIGHTDATA *data)
 
static HRESULT WINAPI d3d_viewport_SetBackground (IDirect3DViewport3 *iface, D3DMATERIALHANDLE material)
 
static HRESULT WINAPI d3d_viewport_GetBackground (IDirect3DViewport3 *iface, D3DMATERIALHANDLE *material, BOOL *valid)
 
static HRESULT WINAPI d3d_viewport_SetBackgroundDepth (IDirect3DViewport3 *iface, IDirectDrawSurface *surface)
 
static HRESULT WINAPI d3d_viewport_GetBackgroundDepth (IDirect3DViewport3 *iface, IDirectDrawSurface **surface, BOOL *valid)
 
static HRESULT WINAPI d3d_viewport_Clear (IDirect3DViewport3 *iface, DWORD rect_count, D3DRECT *rects, DWORD flags)
 
static HRESULT WINAPI d3d_viewport_AddLight (IDirect3DViewport3 *viewport, IDirect3DLight *light)
 
static HRESULT WINAPI d3d_viewport_DeleteLight (IDirect3DViewport3 *iface, IDirect3DLight *lpDirect3DLight)
 
static HRESULT WINAPI d3d_viewport_NextLight (IDirect3DViewport3 *iface, IDirect3DLight *lpDirect3DLight, IDirect3DLight **lplpDirect3DLight, DWORD flags)
 
static HRESULT WINAPI d3d_viewport_GetViewport2 (IDirect3DViewport3 *iface, D3DVIEWPORT2 *vp)
 
static HRESULT WINAPI d3d_viewport_SetViewport2 (IDirect3DViewport3 *iface, D3DVIEWPORT2 *vp)
 
static HRESULT WINAPI d3d_viewport_SetBackgroundDepth2 (IDirect3DViewport3 *iface, IDirectDrawSurface4 *surface)
 
static HRESULT WINAPI d3d_viewport_GetBackgroundDepth2 (IDirect3DViewport3 *iface, IDirectDrawSurface4 **surface, BOOL *valid)
 
static HRESULT WINAPI d3d_viewport_Clear2 (IDirect3DViewport3 *iface, DWORD rect_count, D3DRECT *rects, DWORD flags, DWORD color, D3DVALUE depth, DWORD stencil)
 
struct d3d_viewport * unsafe_impl_from_IDirect3DViewport3 (IDirect3DViewport3 *iface)
 
struct d3d_viewport * unsafe_impl_from_IDirect3DViewport2 (IDirect3DViewport2 *iface)
 
struct d3d_viewport * unsafe_impl_from_IDirect3DViewport (IDirect3DViewport *iface)
 
void d3d_viewport_init (struct d3d_viewport *viewport, struct ddraw *ddraw)
 

Variables

static const struct IDirect3DViewport3Vtbl d3d_viewport_vtbl
 

Function Documentation

◆ _dump_D3DVIEWPORT()

static void _dump_D3DVIEWPORT ( const D3DVIEWPORT *  lpvp)
static

Definition at line 182 of file viewport.c.

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}
#define TRACE(s)
Definition: solgame.cpp:4
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

Referenced by d3d_viewport_GetViewport(), and d3d_viewport_SetViewport().

◆ _dump_D3DVIEWPORT2()

static void _dump_D3DVIEWPORT2 ( const D3DVIEWPORT2 *  lpvp)
static

Definition at line 196 of file viewport.c.

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}
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

Referenced by d3d_viewport_GetViewport2(), and d3d_viewport_SetViewport2().

◆ d3d_viewport_AddLight()

static HRESULT WINAPI d3d_viewport_AddLight ( IDirect3DViewport3 *  viewport,
IDirect3DLight *  light 
)
static

Definition at line 805 of file viewport.c.

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}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
#define WARN(fmt,...)
Definition: precomp.h:61
#define IDirect3DLight_AddRef(p)
Definition: d3d.h:422
#define D3DERR_LIGHTHASVIEWPORT
Definition: d3d.h:149
#define D3D_OK
Definition: d3d.h:106
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:210
void light_activate(struct d3d_light *light)
Definition: light.c:48
struct d3d_light * unsafe_impl_from_IDirect3DLight(IDirect3DLight *iface)
Definition: light.c:257
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
struct list entry
struct d3d_viewport * active_viewport
struct list light_list
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539

◆ d3d_viewport_AddRef()

static ULONG WINAPI d3d_viewport_AddRef ( IDirect3DViewport3 *  iface)
static

Definition at line 264 of file viewport.c.

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}
#define InterlockedIncrement
Definition: armddk.h:53
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ d3d_viewport_Clear()

static HRESULT WINAPI d3d_viewport_Clear ( IDirect3DViewport3 *  iface,
DWORD  rect_count,
D3DRECT *  rects,
DWORD  flags 
)
static

Definition at line 736 of file viewport.c.

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}
#define ERR(fmt,...)
Definition: precomp.h:57
#define D3DCLEAR_ZBUFFER
Definition: d3d8types.h:31
#define D3DCLEAR_TARGET
Definition: d3d8types.h:30
#define D3DERR_VIEWPORTHASNODEVICE
Definition: d3d.h:159
#define IDirect3DViewport3_Release(p)
Definition: d3d.h:827
#define IDirect3DDevice7_Clear(p, a, b, c, d, e, f)
Definition: d3d.h:1353
#define IDirect3DDevice3_GetCurrentViewport(p, a)
Definition: d3d.h:1204
void viewport_activate(struct d3d_viewport *This, BOOL ignore_lights)
Definition: viewport.c:51
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define D3DRGBA
Definition: dx7todx8.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint color
Definition: glext.h:6243
GLbitfield flags
Definition: glext.h:7161
#define SUCCEEDED(hr)
Definition: intsafe.h:50

◆ d3d_viewport_Clear2()

static HRESULT WINAPI d3d_viewport_Clear2 ( IDirect3DViewport3 *  iface,
DWORD  rect_count,
D3DRECT *  rects,
DWORD  flags,
DWORD  color,
D3DVALUE  depth,
DWORD  stencil 
)
static

Definition at line 1132 of file viewport.c.

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}
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLfloat GLint stencil
Definition: glext.h:6260
struct d3d_device * active_device

◆ d3d_viewport_DeleteLight()

static HRESULT WINAPI d3d_viewport_DeleteLight ( IDirect3DViewport3 *  iface,
IDirect3DLight *  lpDirect3DLight 
)
static

Definition at line 847 of file viewport.c.

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}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
r l[0]
Definition: byte_order.h:168
#define IDirect3DLight_Release(p)
Definition: d3d.h:423
void light_deactivate(struct d3d_light *light)
Definition: light.c:74
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:81

◆ d3d_viewport_GetBackground()

static HRESULT WINAPI d3d_viewport_GetBackground ( IDirect3DViewport3 *  iface,
D3DMATERIALHANDLE *  material,
BOOL *  valid 
)
static

Definition at line 661 of file viewport.c.

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}
BOOLEAN valid
struct d3d_material * background

◆ d3d_viewport_GetBackgroundDepth()

static HRESULT WINAPI d3d_viewport_GetBackgroundDepth ( IDirect3DViewport3 *  iface,
IDirectDrawSurface **  surface,
BOOL *  valid 
)
static

Definition at line 711 of file viewport.c.

713{
714 FIXME("iface %p, surface %p, valid %p stub!\n", iface, surface, valid);
715
716 return DD_OK;
717}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define DD_OK
Definition: ddraw.h:188

◆ d3d_viewport_GetBackgroundDepth2()

static HRESULT WINAPI d3d_viewport_GetBackgroundDepth2 ( IDirect3DViewport3 *  iface,
IDirectDrawSurface4 **  surface,
BOOL *  valid 
)
static

Definition at line 1108 of file viewport.c.

1110{
1111 FIXME("iface %p, surface %p, valid %p stub!\n", iface, surface, valid);
1112
1113 return D3D_OK;
1114}

◆ d3d_viewport_GetViewport()

static HRESULT WINAPI d3d_viewport_GetViewport ( IDirect3DViewport3 *  iface,
D3DVIEWPORT *  vp 
)
static

Definition at line 319 of file viewport.c.

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}
#define D3DERR_VIEWPORTDATANOTSET
Definition: d3d.h:158
static void _dump_D3DVIEWPORT(const D3DVIEWPORT *lpvp)
Definition: viewport.c:182
@ DDRAW_VIEWPORT_VERSION_1
@ DDRAW_VIEWPORT_VERSION_NONE
#define TRACE_ON(x)
Definition: compat.h:75
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
enum ddraw_viewport_version version
union d3d_viewport::@288 viewports
D3DVIEWPORT vp1
D3DVIEWPORT2 vp2

◆ d3d_viewport_GetViewport2()

static HRESULT WINAPI d3d_viewport_GetViewport2 ( IDirect3DViewport3 *  iface,
D3DVIEWPORT2 *  vp 
)
static

Definition at line 950 of file viewport.c.

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}
static void _dump_D3DVIEWPORT2(const D3DVIEWPORT2 *lpvp)
Definition: viewport.c:196
@ DDRAW_VIEWPORT_VERSION_2

◆ d3d_viewport_init()

void d3d_viewport_init ( struct d3d_viewport *  viewport,
struct ddraw *  ddraw 
)

Definition at line 1232 of file viewport.c.

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 void list_init(struct list_entry *head)
Definition: list.h:51
static const struct IDirect3DViewport3Vtbl d3d_viewport_vtbl
Definition: viewport.c:1180
struct ddraw * ddraw
IDirect3DViewport3 IDirect3DViewport3_iface

Referenced by d3d3_CreateViewport().

◆ d3d_viewport_Initialize()

static HRESULT WINAPI d3d_viewport_Initialize ( IDirect3DViewport3 *  iface,
IDirect3D *  d3d 
)
static

Definition at line 312 of file viewport.c.

313{
314 TRACE("iface %p, d3d %p.\n", iface, d3d);
315
317}
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:69

◆ d3d_viewport_LightElements()

static HRESULT WINAPI d3d_viewport_LightElements ( IDirect3DViewport3 *  iface,
DWORD  element_count,
D3DLIGHTDATA *  data 
)
static

Definition at line 614 of file viewport.c.

616{
617 TRACE("iface %p, element_count %lu, data %p.\n", iface, element_count, data);
618
619 return DDERR_UNSUPPORTED;
620}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static ULONG ** element_count
Definition: exception.c:124
#define DDERR_UNSUPPORTED
Definition: ddraw.h:129

◆ d3d_viewport_NextLight()

static HRESULT WINAPI d3d_viewport_NextLight ( IDirect3DViewport3 *  iface,
IDirect3DLight *  lpDirect3DLight,
IDirect3DLight **  lplpDirect3DLight,
DWORD  flags 
)
static

Definition at line 886 of file viewport.c.

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}
Definition: list.h:39
#define D3DNEXT_NEXT
Definition: d3d.h:192
#define D3DNEXT_TAIL
Definition: d3d.h:194
#define D3DNEXT_HEAD
Definition: d3d.h:193
uint32_t entry
Definition: isohybrid.c:63
__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
Definition: list.h:15
#define LIST_ENTRY(type)
Definition: queue.h:175

◆ d3d_viewport_QueryInterface()

static HRESULT WINAPI d3d_viewport_QueryInterface ( IDirect3DViewport3 *  iface,
REFIID  riid,
void **  object 
)
static

Definition at line 235 of file viewport.c.

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}
const GUID IID_IUnknown
#define IDirect3DViewport3_AddRef(p)
Definition: d3d.h:826
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ d3d_viewport_Release()

static ULONG WINAPI d3d_viewport_Release ( IDirect3DViewport3 *  iface)
static

Definition at line 283 of file viewport.c.

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}
#define InterlockedDecrement
Definition: armddk.h:52
#define free
Definition: debug_ros.c:5

◆ d3d_viewport_SetBackground()

static HRESULT WINAPI d3d_viewport_SetBackground ( IDirect3DViewport3 *  iface,
D3DMATERIALHANDLE  material 
)
static

Definition at line 622 of file viewport.c.

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}
void * ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type)
Definition: main.c:213
@ DDRAW_HANDLE_MATERIAL
const GLfloat * m
Definition: glext.h:10848

◆ d3d_viewport_SetBackgroundDepth()

static HRESULT WINAPI d3d_viewport_SetBackgroundDepth ( IDirect3DViewport3 *  iface,
IDirectDrawSurface *  surface 
)
static

Definition at line 690 of file viewport.c.

691{
692 FIXME("iface %p, surface %p stub!\n", iface, surface);
693
694 return D3D_OK;
695}

◆ d3d_viewport_SetBackgroundDepth2()

static HRESULT WINAPI d3d_viewport_SetBackgroundDepth2 ( IDirect3DViewport3 *  iface,
IDirectDrawSurface4 *  surface 
)
static

Definition at line 1087 of file viewport.c.

1089{
1090 FIXME("iface %p, surface %p stub!\n", iface, surface);
1091
1092 return D3D_OK;
1093}

◆ d3d_viewport_SetViewport()

static HRESULT WINAPI d3d_viewport_SetViewport ( IDirect3DViewport3 *  iface,
D3DVIEWPORT *  vp 
)
static

Definition at line 372 of file viewport.c.

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}
struct wined3d_rendertarget_view * ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface)
Definition: surface.c:7053
#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 DDERR_INVALIDCAPS
Definition: ddraw.h:77
unsigned int sub_resource_idx
struct wined3d_texture * wined3d_texture
Definition: devices.h:37
static bool wined3d_bound_range(unsigned int start, unsigned int count, unsigned int limit)
Definition: wined3d.h:2995

◆ d3d_viewport_SetViewport2()

static HRESULT WINAPI d3d_viewport_SetViewport2 ( IDirect3DViewport3 *  iface,
D3DVIEWPORT2 *  vp 
)
static

Definition at line 1002 of file viewport.c.

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}

◆ d3d_viewport_TransformVertices()

static HRESULT WINAPI d3d_viewport_TransformVertices ( IDirect3DViewport3 *  iface,
DWORD  dwVertexCount,
D3DTRANSFORMDATA *  data,
DWORD  dwFlags,
DWORD *  offscreen 
)
static

Definition at line 482 of file viewport.c.

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}
static int state
Definition: maze.c:121
#define U(x)
Definition: wordpad.c:45
#define D3DTRANSFORM_UNCLIPPED
Definition: d3dtypes.h:483
#define D3DCLIP_BOTTOM
Definition: d3dtypes.h:411
#define D3DCLIP_BACK
Definition: d3dtypes.h:413
#define D3DCLIP_LEFT
Definition: d3dtypes.h:408
#define D3DTRANSFORM_CLIPPED
Definition: d3dtypes.h:482
#define D3DCLIP_RIGHT
Definition: d3dtypes.h:409
#define D3DCLIP_FRONT
Definition: d3dtypes.h:412
#define D3DCLIP_TOP
Definition: d3dtypes.h:410
void multiply_matrix(struct wined3d_matrix *dst, const struct wined3d_matrix *src1, const struct wined3d_matrix *src2)
Definition: utils.c:1153
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint in
Definition: glext.h:9616
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble z
Definition: glext.h:5874
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
if(dx< 0)
Definition: linetemp.h:194
static const MAT2 mat
Definition: font.c:51
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
D3DVALUE hx
Definition: d3dtypes.h:204
DWORD dwFlags
Definition: d3dtypes.h:202
D3DVALUE hz
Definition: d3dtypes.h:212
struct wined3d_viewport viewport
Definition: wined3d.h:2195
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:683
@ WINED3D_TS_PROJECTION
Definition: wined3d.h:668
@ WINED3D_TS_VIEW
Definition: wined3d.h:667

◆ impl_from_IDirect3DViewport3()

◆ unsafe_impl_from_IDirect3DViewport()

struct d3d_viewport * unsafe_impl_from_IDirect3DViewport ( IDirect3DViewport *  iface)

Definition at line 1224 of file viewport.c.

1225{
1226 /* IDirect3DViewport and IDirect3DViewport3 use the same iface. */
1227 if (!iface) return NULL;
1228 assert(iface->lpVtbl == (IDirect3DViewportVtbl *)&d3d_viewport_vtbl);
1229 return CONTAINING_RECORD(iface, struct d3d_viewport, IDirect3DViewport3_iface);
1230}
#define assert(_expr)
Definition: assert.h:32

Referenced by d3d_device1_AddViewport(), d3d_device1_DeleteViewport(), d3d_device1_Execute(), and d3d_device1_NextViewport().

◆ unsafe_impl_from_IDirect3DViewport2()

struct d3d_viewport * unsafe_impl_from_IDirect3DViewport2 ( IDirect3DViewport2 *  iface)

Definition at line 1216 of file viewport.c.

1217{
1218 /* IDirect3DViewport and IDirect3DViewport3 use the same iface. */
1219 if (!iface) return NULL;
1220 assert(iface->lpVtbl == (IDirect3DViewport2Vtbl *)&d3d_viewport_vtbl);
1221 return CONTAINING_RECORD(iface, struct d3d_viewport, IDirect3DViewport3_iface);
1222}

Referenced by d3d_device2_AddViewport(), d3d_device2_DeleteViewport(), d3d_device2_NextViewport(), and d3d_device2_SetCurrentViewport().

◆ unsafe_impl_from_IDirect3DViewport3()

struct d3d_viewport * unsafe_impl_from_IDirect3DViewport3 ( IDirect3DViewport3 *  iface)

Definition at line 1209 of file viewport.c.

1210{
1211 if (!iface) return NULL;
1212 assert(iface->lpVtbl == &d3d_viewport_vtbl);
1213 return CONTAINING_RECORD(iface, struct d3d_viewport, IDirect3DViewport3_iface);
1214}

Referenced by d3d_device3_AddViewport(), d3d_device3_DeleteViewport(), d3d_device3_NextViewport(), and d3d_device3_SetCurrentViewport().

◆ update_clip_space()

static void update_clip_space ( struct d3d_device *  device,
struct wined3d_vec3 *  scale,
struct wined3d_vec3 *  offset 
)
static

Definition at line 28 of file viewport.c.

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}
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLintptr offset
Definition: glext.h:5920
void CDECL wined3d_stateblock_set_transform(struct wined3d_stateblock *stateblock, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
Definition: stateblock.c:1840

Referenced by viewport_activate().

◆ viewport_activate()

void viewport_activate ( struct d3d_viewport *  This,
BOOL  ignore_lights 
)

Definition at line 51 of file viewport.c.

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}
#define IDirect3DDevice7_SetViewport(p, a)
Definition: d3d.h:1356
static void update_clip_space(struct d3d_device *device, struct wined3d_vec3 *scale, struct wined3d_vec3 *offset)
Definition: viewport.c:28
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236

Referenced by d3d_device3_SetCurrentViewport(), d3d_viewport_Clear(), d3d_viewport_Clear2(), d3d_viewport_SetViewport(), d3d_viewport_SetViewport2(), and d3d_viewport_TransformVertices().

◆ viewport_alloc_active_light_index()

void viewport_alloc_active_light_index ( struct d3d_light *  light)

Definition at line 121 of file viewport.c.

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}
Definition: _map.h:48
#define DDRAW_MAX_ACTIVE_LIGHTS
Definition: ddraw_private.h:70
DWORD active_lights_count
static int wined3d_bit_scan(unsigned int *x)
Definition: wined3d.h:2982

Referenced by light_activate().

◆ viewport_deactivate()

void viewport_deactivate ( struct d3d_viewport *  viewport)

Definition at line 111 of file viewport.c.

112{
113 struct d3d_light *light;
114
116 {
118 }
119}

Referenced by d3d_device3_DeleteViewport(), and d3d_device3_SetCurrentViewport().

◆ viewport_free_active_light_index()

void viewport_free_active_light_index ( struct d3d_light *  light)

Definition at line 159 of file viewport.c.

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}

Referenced by light_deactivate().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ddraw  )

Variable Documentation

◆ d3d_viewport_vtbl

const struct IDirect3DViewport3Vtbl d3d_viewport_vtbl
static
Initial value:
=
{
}
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
static HRESULT WINAPI d3d_viewport_SetViewport(IDirect3DViewport3 *iface, D3DVIEWPORT *vp)
Definition: viewport.c:372
static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE material)
Definition: viewport.c:622
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
static HRESULT WINAPI d3d_viewport_NextLight(IDirect3DViewport3 *iface, IDirect3DLight *lpDirect3DLight, IDirect3DLight **lplpDirect3DLight, DWORD flags)
Definition: viewport.c:886
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
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 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 HRESULT WINAPI d3d_viewport_AddLight(IDirect3DViewport3 *viewport, IDirect3DLight *light)
Definition: viewport.c:805
static HRESULT WINAPI d3d_viewport_GetBackgroundDepth(IDirect3DViewport3 *iface, IDirectDrawSurface **surface, BOOL *valid)
Definition: viewport.c:711
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

Definition at line 1180 of file viewport.c.

Referenced by d3d_viewport_init(), unsafe_impl_from_IDirect3DViewport(), unsafe_impl_from_IDirect3DViewport2(), and unsafe_impl_from_IDirect3DViewport3().