ReactOS  0.4.14-dev-342-gdc047f9
viewport.c File Reference
#include "config.h"
#include "wine/port.h"
#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)
 
static void _dump_D3DVIEWPORT (const D3DVIEWPORT *lpvp)
 
static void _dump_D3DVIEWPORT2 (const D3DVIEWPORT2 *lpvp)
 
static struct d3d_viewportimpl_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 *lpData)
 
static HRESULT WINAPI d3d_viewport_SetViewport (IDirect3DViewport3 *iface, D3DVIEWPORT *lpData)
 
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 *iface, IDirect3DLight *lpDirect3DLight)
 
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 *lpData)
 
static HRESULT WINAPI d3d_viewport_SetViewport2 (IDirect3DViewport3 *iface, D3DVIEWPORT2 *lpData)
 
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_viewportunsafe_impl_from_IDirect3DViewport3 (IDirect3DViewport3 *iface)
 
struct d3d_viewportunsafe_impl_from_IDirect3DViewport2 (IDirect3DViewport2 *iface)
 
struct d3d_viewportunsafe_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 115 of file viewport.c.

116 {
117  TRACE(" - dwSize = %d dwX = %d dwY = %d\n",
118  lpvp->dwSize, lpvp->dwX, lpvp->dwY);
119  TRACE(" - dwWidth = %d dwHeight = %d\n",
120  lpvp->dwWidth, lpvp->dwHeight);
121  TRACE(" - dvScaleX = %f dvScaleY = %f\n",
122  lpvp->dvScaleX, lpvp->dvScaleY);
123  TRACE(" - dvMaxX = %f dvMaxY = %f\n",
124  lpvp->dvMaxX, lpvp->dvMaxY);
125  TRACE(" - dvMinZ = %f dvMaxZ = %f\n",
126  lpvp->dvMinZ, lpvp->dvMaxZ);
127 }
D3DVALUE dvMinZ
Definition: d3dtypes.h:372
DWORD dwY
Definition: d3dtypes.h:365
D3DVALUE dvMaxX
Definition: d3dtypes.h:370
D3DVALUE dvMaxZ
Definition: d3dtypes.h:373
DWORD dwHeight
Definition: d3dtypes.h:367
D3DVALUE dvMaxY
Definition: d3dtypes.h:371
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwWidth
Definition: d3dtypes.h:366
DWORD dwSize
Definition: d3dtypes.h:363
D3DVALUE dvScaleX
Definition: d3dtypes.h:368
D3DVALUE dvScaleY
Definition: d3dtypes.h:369
DWORD dwX
Definition: d3dtypes.h:364

Referenced by d3d_viewport_GetViewport(), and d3d_viewport_SetViewport().

◆ _dump_D3DVIEWPORT2()

static void _dump_D3DVIEWPORT2 ( const D3DVIEWPORT2 lpvp)
static

Definition at line 129 of file viewport.c.

130 {
131  TRACE(" - dwSize = %d dwX = %d dwY = %d\n",
132  lpvp->dwSize, lpvp->dwX, lpvp->dwY);
133  TRACE(" - dwWidth = %d dwHeight = %d\n",
134  lpvp->dwWidth, lpvp->dwHeight);
135  TRACE(" - dvClipX = %f dvClipY = %f\n",
136  lpvp->dvClipX, lpvp->dvClipY);
137  TRACE(" - dvClipWidth = %f dvClipHeight = %f\n",
138  lpvp->dvClipWidth, lpvp->dvClipHeight);
139  TRACE(" - dvMinZ = %f dvMaxZ = %f\n",
140  lpvp->dvMinZ, lpvp->dvMaxZ);
141 }
D3DVALUE dvClipWidth
Definition: d3dtypes.h:384
D3DVALUE dvMinZ
Definition: d3dtypes.h:386
DWORD dwSize
Definition: d3dtypes.h:377
D3DVALUE dvMaxZ
Definition: d3dtypes.h:387
D3DVALUE dvClipX
Definition: d3dtypes.h:382
#define TRACE(s)
Definition: solgame.cpp:4
D3DVALUE dvClipY
Definition: d3dtypes.h:383
DWORD dwWidth
Definition: d3dtypes.h:380
D3DVALUE dvClipHeight
Definition: d3dtypes.h:385
DWORD dwHeight
Definition: d3dtypes.h:381

Referenced by d3d_viewport_GetViewport2(), and d3d_viewport_SetViewport2().

◆ d3d_viewport_AddLight()

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

Definition at line 720 of file viewport.c.

721 {
723  struct d3d_light *light_impl = unsafe_impl_from_IDirect3DLight(lpDirect3DLight);
724  DWORD i = 0;
725  DWORD map = This->map_lights;
726 
727  TRACE("iface %p, light %p.\n", iface, lpDirect3DLight);
728 
730 
731  if (This->num_lights >= 8)
732  {
734  return DDERR_INVALIDPARAMS;
735  }
736 
737  /* Find a light number and update both light and viewports objects accordingly */
738  while (map & 1)
739  {
740  map >>= 1;
741  ++i;
742  }
743  light_impl->dwLightIndex = i;
744  This->num_lights++;
745  This->map_lights |= 1<<i;
746 
747  /* Add the light in the 'linked' chain */
748  list_add_head(&This->light_list, &light_impl->entry);
749  IDirect3DLight_AddRef(lpDirect3DLight);
750 
751  /* Attach the light to the viewport */
752  light_impl->active_viewport = This;
753 
754  /* If active, activate the light */
755  if (This->active_device && light_impl->light.dwFlags & D3DLIGHT_ACTIVE)
756  {
757  /* Disable the flag so that light_activate actually does its job. */
758  light_impl->light.dwFlags &= ~D3DLIGHT_ACTIVE;
759  light_activate(light_impl);
760  }
761 
763 
764  return D3D_OK;
765 }
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
D3DLIGHT2 light
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
struct list entry
DWORD dwLightIndex
#define TRACE(s)
Definition: solgame.cpp:4
struct d3d_light * unsafe_impl_from_IDirect3DLight(IDirect3DLight *iface) DECLSPEC_HIDDEN
Definition: light.c:254
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: _map.h:44
#define IDirect3DLight_AddRef(p)
Definition: d3d.h:422
void light_activate(struct d3d_light *light) DECLSPEC_HIDDEN
Definition: light.c:51
#define D3D_OK
Definition: d3d.h:106
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
#define D3DLIGHT_ACTIVE
Definition: d3dtypes.h:596
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
DWORD dwFlags
Definition: d3dtypes.h:615
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
struct d3d_viewport * active_viewport

◆ d3d_viewport_AddRef()

static ULONG WINAPI d3d_viewport_AddRef ( IDirect3DViewport3 *  iface)
static

Definition at line 197 of file viewport.c.

198 {
199  struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
200  ULONG ref = InterlockedIncrement(&viewport->ref);
201 
202  TRACE("%p increasing refcount to %u.\n", viewport, ref);
203 
204  return ref;
205 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ d3d_viewport_Clear()

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

Definition at line 651 of file viewport.c.

653 {
655  DWORD color = 0x00000000;
656  HRESULT hr;
657  IDirect3DViewport3 *current_viewport;
658  IDirect3DDevice3 *d3d_device3;
659 
660  TRACE("iface %p, rect_count %u, rects %p, flags %#x.\n", iface, rect_count, rects, flags);
661 
662  if (!rects || !rect_count)
663  {
664  WARN("rect_count = %u, rects = %p, ignoring clear\n", rect_count, rects);
665  return D3D_OK;
666  }
667 
668  if (This->active_device == NULL) {
669  ERR(" Trying to clear a viewport not attached to a device!\n");
671  }
672  d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
673 
675 
676  if (flags & D3DCLEAR_TARGET)
677  {
678  if (!This->background)
679  WARN("No background material set.\n");
680  else
681  color = D3DRGBA(This->background->mat.u.diffuse.u1.r,
682  This->background->mat.u.diffuse.u2.g,
683  This->background->mat.u.diffuse.u3.b,
684  This->background->mat.u.diffuse.u4.a);
685  }
686 
687  /* Need to temporarily activate the viewport to clear it. The previously
688  * active one will be restored afterwards. */
690 
691  hr = IDirect3DDevice7_Clear(&This->active_device->IDirect3DDevice7_iface, rect_count, rects,
692  flags & (D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET), color, 1.0, 0x00000000);
693 
694  if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport)))
695  {
696  struct d3d_viewport *vp = impl_from_IDirect3DViewport3(current_viewport);
697  viewport_activate(vp, TRUE);
698  IDirect3DViewport3_Release(current_viewport);
699  }
700 
702 
703  return hr;
704 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define D3DCLEAR_ZBUFFER
Definition: d3d8types.h:31
GLuint color
Definition: glext.h:6243
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define D3DRGBA
Definition: dx7todx8.h:8
#define IDirect3DDevice3_GetCurrentViewport(p, a)
Definition: d3d.h:1204
#define ERR(fmt,...)
Definition: debug.h:109
#define D3DERR_VIEWPORTHASNODEVICE
Definition: d3d.h:159
#define D3D_OK
Definition: d3d.h:106
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
void viewport_activate(struct d3d_viewport *This, BOOL ignore_lights)
Definition: viewport.c:55
#define IDirect3DDevice7_Clear(p, a, b, c, d, e, f)
Definition: d3d.h:1353
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define IDirect3DViewport3_Release(p)
Definition: d3d.h:827
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define D3DCLEAR_TARGET
Definition: d3d8types.h:30

◆ 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 1046 of file viewport.c.

1048 {
1049  struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
1050  HRESULT hr;
1051  IDirect3DViewport3 *current_viewport;
1052  IDirect3DDevice3 *d3d_device3;
1053 
1054  TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, depth %.8e, stencil %u.\n",
1055  iface, rect_count, rects, flags, color, depth, stencil);
1056 
1057  if (!rects || !rect_count)
1058  {
1059  WARN("rect_count = %u, rects = %p, ignoring clear\n", rect_count, rects);
1060  return D3D_OK;
1061  }
1062 
1064 
1065  if (!viewport->active_device)
1066  {
1067  WARN("Trying to clear a viewport not attached to a device.\n");
1070  }
1071  d3d_device3 = &viewport->active_device->IDirect3DDevice3_iface;
1072  /* Need to temporarily activate viewport to clear it. Previously active
1073  * one will be restored afterwards. */
1074  viewport_activate(viewport, TRUE);
1075 
1076  hr = IDirect3DDevice7_Clear(&viewport->active_device->IDirect3DDevice7_iface,
1077  rect_count, rects, flags, color, depth, stencil);
1078  if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport)))
1079  {
1080  struct d3d_viewport *vp = impl_from_IDirect3DViewport3(current_viewport);
1081  viewport_activate(vp, TRUE);
1082  IDirect3DViewport3_Release(current_viewport);
1083  }
1084 
1086 
1087  return hr;
1088 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
GLint GLfloat GLint stencil
Definition: glext.h:6260
GLuint color
Definition: glext.h:6243
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
struct d3d_device * active_device
GLbitfield flags
Definition: glext.h:7161
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define IDirect3DDevice3_GetCurrentViewport(p, a)
Definition: d3d.h:1204
#define D3DERR_VIEWPORTHASNODEVICE
Definition: d3d.h:159
#define D3D_OK
Definition: d3d.h:106
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
void viewport_activate(struct d3d_viewport *This, BOOL ignore_lights)
Definition: viewport.c:55
#define IDirect3DDevice7_Clear(p, a, b, c, d, e, f)
Definition: d3d.h:1353
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define IDirect3DViewport3_Release(p)
Definition: d3d.h:827
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ d3d_viewport_DeleteLight()

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

Definition at line 780 of file viewport.c.

781 {
782  struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
783  struct d3d_light *l = unsafe_impl_from_IDirect3DLight(lpDirect3DLight);
784 
785  TRACE("iface %p, light %p.\n", iface, lpDirect3DLight);
786 
788 
789  if (l->active_viewport != viewport)
790  {
791  WARN("Light %p active viewport is %p.\n", l, l->active_viewport);
793  return DDERR_INVALIDPARAMS;
794  }
795 
797  list_remove(&l->entry);
798  l->active_viewport = NULL;
799  IDirect3DLight_Release(lpDirect3DLight);
800  --viewport->num_lights;
801  viewport->map_lights &= ~(1 << l->dwLightIndex);
802 
804 
805  return D3D_OK;
806 }
#define WARN(fmt,...)
Definition: debug.h:111
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
void light_deactivate(struct d3d_light *light) DECLSPEC_HIDDEN
Definition: light.c:75
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
struct d3d_light * unsafe_impl_from_IDirect3DLight(IDirect3DLight *iface) DECLSPEC_HIDDEN
Definition: light.c:254
#define D3D_OK
Definition: d3d.h:106
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
#define IDirect3DLight_Release(p)
Definition: d3d.h:423
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

◆ d3d_viewport_GetBackground()

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

Definition at line 576 of file viewport.c.

578 {
579  struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
580 
581  TRACE("iface %p, material %p, valid %p.\n", iface, material, valid);
582 
584  if (valid)
585  *valid = !!viewport->background;
586  if (material)
587  *material = viewport->background ? viewport->background->Handle : 0;
589 
590  return D3D_OK;
591 }
struct d3d_material * background
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define TRACE(s)
Definition: solgame.cpp:4
#define D3D_OK
Definition: d3d.h:106
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ d3d_viewport_GetBackgroundDepth()

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

Definition at line 626 of file viewport.c.

628 {
629  FIXME("iface %p, surface %p, valid %p stub!\n", iface, surface, valid);
630 
631  return DD_OK;
632 }
#define DD_OK
Definition: ddraw.h:186
#define FIXME(fmt,...)
Definition: debug.h:110

◆ d3d_viewport_GetBackgroundDepth2()

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

Definition at line 1022 of file viewport.c.

1024 {
1025  FIXME("iface %p, surface %p, valid %p stub!\n", iface, surface, valid);
1026 
1027  return D3D_OK;
1028 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define D3D_OK
Definition: d3d.h:106

◆ d3d_viewport_GetViewport()

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

Definition at line 265 of file viewport.c.

266 {
268  DWORD dwSize;
269 
270  TRACE("iface %p, data %p.\n", iface, lpData);
271 
273 
274  dwSize = lpData->dwSize;
275  if (!This->use_vp2)
276  memcpy(lpData, &(This->viewports.vp1), dwSize);
277  else {
279  vp1.dwSize = sizeof(vp1);
280  vp1.dwX = This->viewports.vp2.dwX;
281  vp1.dwY = This->viewports.vp2.dwY;
282  vp1.dwWidth = This->viewports.vp2.dwWidth;
283  vp1.dwHeight = This->viewports.vp2.dwHeight;
284  vp1.dvMaxX = 0.0;
285  vp1.dvMaxY = 0.0;
286  vp1.dvScaleX = 0.0;
287  vp1.dvScaleY = 0.0;
288  vp1.dvMinZ = This->viewports.vp2.dvMinZ;
289  vp1.dvMaxZ = This->viewports.vp2.dvMaxZ;
290  memcpy(lpData, &vp1, dwSize);
291  }
292 
293  if (TRACE_ON(ddraw))
294  {
295  TRACE(" returning D3DVIEWPORT :\n");
296  _dump_D3DVIEWPORT(lpData);
297  }
298 
300 
301  return DD_OK;
302 }
D3DVALUE dvMinZ
Definition: d3dtypes.h:372
DWORD dwY
Definition: d3dtypes.h:365
D3DVALUE dvMaxX
Definition: d3dtypes.h:370
D3DVALUE dvMaxZ
Definition: d3dtypes.h:373
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
D3DVIEWPORT vp1
DWORD dwHeight
Definition: d3dtypes.h:367
#define DD_OK
Definition: ddraw.h:186
D3DVALUE dvMaxY
Definition: d3dtypes.h:371
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwWidth
Definition: d3dtypes.h:366
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD dwSize
Definition: d3dtypes.h:363
D3DVALUE dvScaleX
Definition: d3dtypes.h:368
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
D3DVALUE dvScaleY
Definition: d3dtypes.h:369
static void _dump_D3DVIEWPORT(const D3DVIEWPORT *lpvp)
Definition: viewport.c:115
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define TRACE_ON(x)
Definition: compat.h:65
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
DWORD dwX
Definition: d3dtypes.h:364

◆ d3d_viewport_GetViewport2()

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

Definition at line 901 of file viewport.c.

902 {
904  DWORD dwSize;
905 
906  TRACE("iface %p, data %p.\n", iface, lpData);
907 
909  dwSize = lpData->dwSize;
910  if (This->use_vp2)
911  memcpy(lpData, &(This->viewports.vp2), dwSize);
912  else {
914  vp2.dwSize = sizeof(vp2);
915  vp2.dwX = This->viewports.vp1.dwX;
916  vp2.dwY = This->viewports.vp1.dwY;
917  vp2.dwWidth = This->viewports.vp1.dwWidth;
918  vp2.dwHeight = This->viewports.vp1.dwHeight;
919  vp2.dvClipX = 0.0;
920  vp2.dvClipY = 0.0;
921  vp2.dvClipWidth = 0.0;
922  vp2.dvClipHeight = 0.0;
923  vp2.dvMinZ = This->viewports.vp1.dvMinZ;
924  vp2.dvMaxZ = This->viewports.vp1.dvMaxZ;
925  memcpy(lpData, &vp2, dwSize);
926  }
927 
928  if (TRACE_ON(ddraw))
929  {
930  TRACE(" returning D3DVIEWPORT2 :\n");
931  _dump_D3DVIEWPORT2(lpData);
932  }
933 
935 
936  return D3D_OK;
937 }
static void _dump_D3DVIEWPORT2(const D3DVIEWPORT2 *lpvp)
Definition: viewport.c:129
D3DVALUE dvClipWidth
Definition: d3dtypes.h:384
D3DVIEWPORT2 vp2
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
D3DVALUE dvMinZ
Definition: d3dtypes.h:386
DWORD dwSize
Definition: d3dtypes.h:377
D3DVALUE dvMaxZ
Definition: d3dtypes.h:387
D3DVALUE dvClipX
Definition: d3dtypes.h:382
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
D3DVALUE dvClipY
Definition: d3dtypes.h:383
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD dwWidth
Definition: d3dtypes.h:380
#define D3D_OK
Definition: d3d.h:106
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
D3DVALUE dvClipHeight
Definition: d3dtypes.h:385
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define TRACE_ON(x)
Definition: compat.h:65
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
DWORD dwHeight
Definition: d3dtypes.h:381

◆ d3d_viewport_init()

void d3d_viewport_init ( struct d3d_viewport viewport,
struct ddraw ddraw 
)

Definition at line 1146 of file viewport.c.

1147 {
1148  viewport->IDirect3DViewport3_iface.lpVtbl = &d3d_viewport_vtbl;
1149  viewport->ref = 1;
1150  viewport->ddraw = ddraw;
1151  viewport->use_vp2 = 0xff;
1152  list_init(&viewport->light_list);
1153 }
struct list light_list
static const struct IDirect3DViewport3Vtbl d3d_viewport_vtbl
Definition: viewport.c:1094
struct ddraw * ddraw
IDirect3DViewport3 IDirect3DViewport3_iface
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149

Referenced by d3d3_CreateViewport().

◆ d3d_viewport_Initialize()

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

Definition at line 245 of file viewport.c.

246 {
247  TRACE("iface %p, d3d %p.\n", iface, d3d);
248 
250 }
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:67
#define TRACE(s)
Definition: solgame.cpp:4

◆ d3d_viewport_LightElements()

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

Definition at line 529 of file viewport.c.

531 {
532  TRACE("iface %p, element_count %u, data %p.\n", iface, element_count, data);
533 
534  return DDERR_UNSUPPORTED;
535 }
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127
#define TRACE(s)
Definition: solgame.cpp:4
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

◆ d3d_viewport_NextLight()

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

Definition at line 821 of file viewport.c.

823 {
824  struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
825  struct d3d_light *l = unsafe_impl_from_IDirect3DLight(lpDirect3DLight);
826  struct list *entry;
827  HRESULT hr;
828 
829  TRACE("iface %p, light %p, next_light %p, flags %#x.\n",
830  iface, lpDirect3DLight, lplpDirect3DLight, flags);
831 
832  if (!lplpDirect3DLight)
833  return DDERR_INVALIDPARAMS;
834 
836 
837  switch (flags)
838  {
839  case D3DNEXT_NEXT:
840  if (!l || l->active_viewport != viewport)
841  {
842  if (l)
843  WARN("Light %p active viewport is %p.\n", l, l->active_viewport);
844  entry = NULL;
845  }
846  else
847  entry = list_next(&viewport->light_list, &l->entry);
848  break;
849 
850  case D3DNEXT_HEAD:
851  entry = list_head(&viewport->light_list);
852  break;
853 
854  case D3DNEXT_TAIL:
855  entry = list_tail(&viewport->light_list);
856  break;
857 
858  default:
859  entry = NULL;
860  WARN("Invalid flags %#x.\n", flags);
861  break;
862  }
863 
864  if (entry)
865  {
866  *lplpDirect3DLight = (IDirect3DLight *)LIST_ENTRY(entry, struct d3d_light, entry);
867  IDirect3DLight_AddRef(*lplpDirect3DLight);
868  hr = D3D_OK;
869  }
870  else
871  {
872  *lplpDirect3DLight = NULL;
874  }
875 
877 
878  return hr;
879 }
HRESULT hr
Definition: shlfolder.c:183
struct list light_list
#define WARN(fmt,...)
Definition: debug.h:111
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
__WINE_SERVER_LIST_INLINE struct list * list_tail(const struct list *list)
Definition: list.h:137
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
#define TRACE(s)
Definition: solgame.cpp:4
struct d3d_light * unsafe_impl_from_IDirect3DLight(IDirect3DLight *iface) DECLSPEC_HIDDEN
Definition: light.c:254
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
#define IDirect3DLight_AddRef(p)
Definition: d3d.h:422
#define D3DNEXT_TAIL
Definition: d3d.h:194
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
#define D3D_OK
Definition: d3d.h:106
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
#define D3DNEXT_HEAD
Definition: d3d.h:193
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
#define D3DNEXT_NEXT
Definition: d3d.h:192
#define LIST_ENTRY(type)
Definition: queue.h:175
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

◆ d3d_viewport_QueryInterface()

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

Definition at line 168 of file viewport.c.

169 {
170  TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
171 
172  if (IsEqualGUID(&IID_IDirect3DViewport3, riid)
173  || IsEqualGUID(&IID_IDirect3DViewport2, riid)
174  || IsEqualGUID(&IID_IDirect3DViewport, riid)
176  {
178  *object = iface;
179  return S_OK;
180  }
181 
182  WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
183 
184  *object = NULL;
185  return E_NOINTERFACE;
186 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
#define IDirect3DViewport3_AddRef(p)
Definition: d3d.h:826
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ d3d_viewport_Release()

static ULONG WINAPI d3d_viewport_Release ( IDirect3DViewport3 *  iface)
static

Definition at line 216 of file viewport.c.

217 {
218  struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
219  ULONG ref = InterlockedDecrement(&viewport->ref);
220 
221  TRACE("%p decreasing refcount to %u.\n", viewport, ref);
222 
223  if (!ref)
224  heap_free(viewport);
225 
226  return ref;
227 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
unsigned int ULONG
Definition: retypes.h:1
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ d3d_viewport_SetBackground()

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

Definition at line 537 of file viewport.c.

538 {
539  struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
540  struct d3d_material *m;
541 
542  TRACE("iface %p, material %#x.\n", iface, material);
543 
545 
546  if (!(m = ddraw_get_object(&viewport->ddraw->d3ddevice->handle_table, material - 1, DDRAW_HANDLE_MATERIAL)))
547  {
548  WARN("Invalid material handle %#x.\n", material);
550  return DDERR_INVALIDPARAMS;
551  }
552 
553  TRACE("Setting background color : %.8e %.8e %.8e %.8e.\n",
554  m->mat.u.diffuse.u1.r, m->mat.u.diffuse.u2.g,
555  m->mat.u.diffuse.u3.b, m->mat.u.diffuse.u4.a);
556  viewport->background = m;
557 
559 
560  return D3D_OK;
561 }
struct d3d_material * background
#define WARN(fmt,...)
Definition: debug.h:111
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
const GLfloat * m
Definition: glext.h:10848
void * ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN
Definition: main.c:182
#define TRACE(s)
Definition: solgame.cpp:4
struct ddraw * ddraw
#define D3D_OK
Definition: d3d.h:106
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

◆ d3d_viewport_SetBackgroundDepth()

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

Definition at line 605 of file viewport.c.

606 {
607  FIXME("iface %p, surface %p stub!\n", iface, surface);
608 
609  return D3D_OK;
610 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define D3D_OK
Definition: d3d.h:106

◆ d3d_viewport_SetBackgroundDepth2()

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

Definition at line 1001 of file viewport.c.

1003 {
1004  FIXME("iface %p, surface %p stub!\n", iface, surface);
1005 
1006  return D3D_OK;
1007 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define D3D_OK
Definition: d3d.h:106

◆ d3d_viewport_SetViewport()

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

Definition at line 317 of file viewport.c.

318 {
320  IDirect3DViewport3 *current_viewport;
321 
322  TRACE("iface %p, data %p.\n", iface, lpData);
323 
324  if (TRACE_ON(ddraw))
325  {
326  TRACE(" getting D3DVIEWPORT :\n");
327  _dump_D3DVIEWPORT(lpData);
328  }
329 
331 
332  This->use_vp2 = 0;
333  memset(&(This->viewports.vp1), 0, sizeof(This->viewports.vp1));
334  memcpy(&(This->viewports.vp1), lpData, lpData->dwSize);
335 
336  /* Tests on two games show that these values are never used properly so override
337  them with proper ones :-)
338  */
339  This->viewports.vp1.dvMinZ = 0.0;
340  This->viewports.vp1.dvMaxZ = 1.0;
341 
342  if (This->active_device)
343  {
344  IDirect3DDevice3 *d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
345  if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport)))
346  {
347  if (current_viewport == iface) viewport_activate(This, FALSE);
348  IDirect3DViewport3_Release(current_viewport);
349  }
350  }
351 
353 
354  return DD_OK;
355 }
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define DD_OK
Definition: ddraw.h:186
#define TRACE(s)
Definition: solgame.cpp:4
#define IDirect3DDevice3_GetCurrentViewport(p, a)
Definition: d3d.h:1204
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD dwSize
Definition: d3dtypes.h:363
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
static void _dump_D3DVIEWPORT(const D3DVIEWPORT *lpvp)
Definition: viewport.c:115
void viewport_activate(struct d3d_viewport *This, BOOL ignore_lights)
Definition: viewport.c:55
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define IDirect3DViewport3_Release(p)
Definition: d3d.h:827
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE_ON(x)
Definition: compat.h:65
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ d3d_viewport_SetViewport2()

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

Definition at line 951 of file viewport.c.

952 {
954  IDirect3DViewport3 *current_viewport;
955 
956  TRACE("iface %p, data %p.\n", iface, lpData);
957 
958  if (TRACE_ON(ddraw))
959  {
960  TRACE(" getting D3DVIEWPORT2 :\n");
961  _dump_D3DVIEWPORT2(lpData);
962  }
963 
965 
966  This->use_vp2 = 1;
967  memset(&(This->viewports.vp2), 0, sizeof(This->viewports.vp2));
968  memcpy(&(This->viewports.vp2), lpData, lpData->dwSize);
969 
970  if (This->active_device)
971  {
972  IDirect3DDevice3 *d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
973  if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport)))
974  {
975  if (current_viewport == iface) viewport_activate(This, FALSE);
976  IDirect3DViewport3_Release(current_viewport);
977  }
978  }
979 
981 
982  return D3D_OK;
983 }
static void _dump_D3DVIEWPORT2(const D3DVIEWPORT2 *lpvp)
Definition: viewport.c:129
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
DWORD dwSize
Definition: d3dtypes.h:377
#define TRACE(s)
Definition: solgame.cpp:4
#define IDirect3DDevice3_GetCurrentViewport(p, a)
Definition: d3d.h:1204
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define D3D_OK
Definition: d3d.h:106
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
void viewport_activate(struct d3d_viewport *This, BOOL ignore_lights)
Definition: viewport.c:55
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define IDirect3DViewport3_Release(p)
Definition: d3d.h:827
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE_ON(x)
Definition: compat.h:65
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ d3d_viewport_TransformVertices()

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

Definition at line 393 of file viewport.c.

395 {
396  struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
397  D3DVIEWPORT vp = viewport->viewports.vp1;
398  D3DMATRIX view_mat, world_mat, proj_mat, mat;
399  struct transform_vertices_vertex *in, *out;
400  float x, y, z, w;
401  unsigned int i;
402  D3DHVERTEX *outH;
403  struct d3d_device *device = viewport->active_device;
404  BOOL activate = device->current_viewport != viewport;
405 
406  TRACE("iface %p, vertex_count %u, data %p, flags %#x, offscreen %p.\n",
407  iface, dwVertexCount, data, dwFlags, offscreen);
408 
409  /* Tests on windows show that Windows crashes when this occurs,
410  * so don't return the (intuitive) return value
411  if (!device)
412  {
413  WARN("No device active, returning D3DERR_VIEWPORTHASNODEVICE\n");
414  return D3DERR_VIEWPORTHASNODEVICE;
415  }
416  */
417 
418  if (!data || data->dwSize != sizeof(*data))
419  {
420  WARN("Transform data is NULL or size is incorrect, returning DDERR_INVALIDPARAMS\n");
421  return DDERR_INVALIDPARAMS;
422  }
424  {
425  WARN("No clipping flag passed, returning DDERR_INVALIDPARAMS\n");
426  return DDERR_INVALIDPARAMS;
427  }
428 
430  if (activate)
431  viewport_activate(viewport, TRUE);
432 
433  wined3d_device_get_transform(device->wined3d_device,
434  D3DTRANSFORMSTATE_VIEW, (struct wined3d_matrix *)&view_mat);
435  wined3d_device_get_transform(device->wined3d_device,
436  WINED3D_TS_WORLD_MATRIX(0), (struct wined3d_matrix *)&world_mat);
437  wined3d_device_get_transform(device->wined3d_device,
438  WINED3D_TS_PROJECTION, (struct wined3d_matrix *)&proj_mat);
439  multiply_matrix(&mat, &view_mat, &world_mat);
440  multiply_matrix(&mat, &proj_mat, &mat);
441 
442  /* The pointer is not tested against NULL on Windows. */
444  *offscreen = ~0U;
445  else
446  *offscreen = 0;
447 
448  outH = data->lpHOut;
449  for(i = 0; i < dwVertexCount; i++)
450  {
451  in = (struct transform_vertices_vertex *)((char *)data->lpIn + data->dwInSize * i);
452  out = (struct transform_vertices_vertex *)((char *)data->lpOut + data->dwOutSize * i);
453 
454  x = (in->x * mat._11) + (in->y * mat._21) + (in->z * mat._31) + mat._41;
455  y = (in->x * mat._12) + (in->y * mat._22) + (in->z * mat._32) + mat._42;
456  z = (in->x * mat._13) + (in->y * mat._23) + (in->z * mat._33) + mat._43;
457  w = (in->x * mat._14) + (in->y * mat._24) + (in->z * mat._34) + mat._44;
458 
460  {
461  /* If clipping is enabled, Windows assumes that outH is
462  * a valid pointer. */
463  outH[i].u1.hx = (x - device->legacy_clipspace._41 * w) / device->legacy_clipspace._11;
464  outH[i].u2.hy = (y - device->legacy_clipspace._42 * w) / device->legacy_clipspace._22;
465  outH[i].u3.hz = (z - device->legacy_clipspace._43 * w) / device->legacy_clipspace._33;
466 
467  outH[i].dwFlags = 0;
468  if (x > w)
469  outH[i].dwFlags |= D3DCLIP_RIGHT;
470  if (x < -w)
471  outH[i].dwFlags |= D3DCLIP_LEFT;
472  if (y > w)
473  outH[i].dwFlags |= D3DCLIP_TOP;
474  if (y < -w)
475  outH[i].dwFlags |= D3DCLIP_BOTTOM;
476  if (z < 0.0f)
477  outH[i].dwFlags |= D3DCLIP_FRONT;
478  if (z > w)
479  outH[i].dwFlags |= D3DCLIP_BACK;
480 
481  *offscreen &= outH[i].dwFlags;
482 
483  if(outH[i].dwFlags)
484  {
485  /* Looks like native just drops the vertex, leaves whatever data
486  * it has in the output buffer and goes on with the next vertex.
487  * The exact scheme hasn't been figured out yet, but windows
488  * definitely writes something there.
489  */
490  out->x = x;
491  out->y = y;
492  out->z = z;
493  out->w = w;
494  continue;
495  }
496  }
497 
498  w = 1 / w;
499  x *= w; y *= w; z *= w;
500 
501  out->x = (x + 1.0f) * vp.dwWidth * 0.5 + vp.dwX;
502  out->y = (-y + 1.0f) * vp.dwHeight * 0.5 + vp.dwY;
503  out->z = z;
504  out->w = w;
505  out->payload = in->payload;
506  }
507 
508  if (activate && device->current_viewport)
509  viewport_activate(device->current_viewport, TRUE);
510 
512 
513  TRACE("All done\n");
514  return DD_OK;
515 }
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:664
#define TRUE
Definition: types.h:120
DWORD dwY
Definition: d3dtypes.h:365
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define D3DTRANSFORM_UNCLIPPED
Definition: d3dtypes.h:483
void CDECL wined3d_device_get_transform(const struct wined3d_device *device, enum wined3d_transform_state state, struct wined3d_matrix *matrix)
Definition: device.c:1540
#define D3DCLIP_TOP
Definition: d3dtypes.h:410
#define WARN(fmt,...)
Definition: debug.h:111
#define U(x)
Definition: wordpad.c:44
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define D3DCLIP_BOTTOM
Definition: d3dtypes.h:411
D3DVIEWPORT vp1
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static const MAT2 mat
Definition: font.c:66
#define D3DTRANSFORM_CLIPPED
Definition: d3dtypes.h:482
DWORD dwHeight
Definition: d3dtypes.h:367
#define DD_OK
Definition: ddraw.h:186
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
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
GLdouble GLdouble z
Definition: glext.h:5874
DWORD dwFlags
Definition: d3dtypes.h:202
union d3d_viewport::@248 viewports
#define D3DCLIP_RIGHT
Definition: d3dtypes.h:409
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define D3DCLIP_FRONT
Definition: d3dtypes.h:412
static FILE * out
Definition: regtests2xml.c:44
struct d3d_device * active_device
DWORD dwWidth
Definition: d3dtypes.h:366
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static struct d3d_viewport * impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface)
Definition: viewport.c:143
GLuint in
Definition: glext.h:9616
void viewport_activate(struct d3d_viewport *This, BOOL ignore_lights)
Definition: viewport.c:55
void multiply_matrix(D3DMATRIX *dst, const D3DMATRIX *src1, const D3DMATRIX *src2) DECLSPEC_HIDDEN
Definition: utils.c:1173
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define D3DCLIP_BACK
Definition: d3dtypes.h:413
D3DVALUE hz
Definition: d3dtypes.h:212
#define D3DCLIP_LEFT
Definition: d3dtypes.h:408
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
D3DVALUE hx
Definition: d3dtypes.h:204
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
DWORD dwX
Definition: d3dtypes.h:364

◆ impl_from_IDirect3DViewport3()

static struct d3d_viewport* impl_from_IDirect3DViewport3 ( IDirect3DViewport3 *  iface)
inlinestatic

Definition at line 143 of file viewport.c.

144 {
145  return CONTAINING_RECORD(iface, struct d3d_viewport, IDirect3DViewport3_iface);
146 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by d3d_viewport_AddLight(), d3d_viewport_AddRef(), d3d_viewport_Clear(), d3d_viewport_Clear2(), d3d_viewport_DeleteLight(), d3d_viewport_GetBackground(), d3d_viewport_GetViewport(), d3d_viewport_GetViewport2(), d3d_viewport_NextLight(), d3d_viewport_Release(), d3d_viewport_SetBackground(), d3d_viewport_SetViewport(), d3d_viewport_SetViewport2(), and d3d_viewport_TransformVertices().

◆ unsafe_impl_from_IDirect3DViewport()

struct d3d_viewport* unsafe_impl_from_IDirect3DViewport ( IDirect3DViewport *  iface)

Definition at line 1138 of file viewport.c.

1139 {
1140  /* IDirect3DViewport and IDirect3DViewport3 use the same iface. */
1141  if (!iface) return NULL;
1142  assert(iface->lpVtbl == (IDirect3DViewportVtbl *)&d3d_viewport_vtbl);
1143  return CONTAINING_RECORD((IDirect3DViewport3 *)iface, struct d3d_viewport, IDirect3DViewport3_iface);
1144 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
static const struct IDirect3DViewport3Vtbl d3d_viewport_vtbl
Definition: viewport.c:1094
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

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 1130 of file viewport.c.

1131 {
1132  /* IDirect3DViewport and IDirect3DViewport3 use the same iface. */
1133  if (!iface) return NULL;
1134  assert(iface->lpVtbl == (IDirect3DViewport2Vtbl *)&d3d_viewport_vtbl);
1135  return CONTAINING_RECORD((IDirect3DViewport3 *)iface, struct d3d_viewport, IDirect3DViewport3_iface);
1136 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
static const struct IDirect3DViewport3Vtbl d3d_viewport_vtbl
Definition: viewport.c:1094
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

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 1123 of file viewport.c.

1124 {
1125  if (!iface) return NULL;
1126  assert(iface->lpVtbl == &d3d_viewport_vtbl);
1127  return CONTAINING_RECORD(iface, struct d3d_viewport, IDirect3DViewport3_iface);
1128 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
static const struct IDirect3DViewport3Vtbl d3d_viewport_vtbl
Definition: viewport.c:1094
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

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 31 of file viewport.c.

33 {
34  D3DMATRIX clip_space =
35  {
36  scale->x, 0.0f, 0.0f, 0.0f,
37  0.0f, scale->y, 0.0f, 0.0f,
38  0.0f, 0.0f, scale->z, 0.0f,
39  offset->x, offset->y, offset->z, 1.0f,
40  };
41  D3DMATRIX projection;
42 
43  multiply_matrix(&projection, &clip_space, &device->legacy_projection);
44  wined3d_device_set_transform(device->wined3d_device,
45  WINED3D_TS_PROJECTION, (struct wined3d_matrix *)&projection);
46  device->legacy_clipspace = clip_space;
47 }
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLintptr offset
Definition: glext.h:5920
Definition: devices.h:37
void CDECL wined3d_device_set_transform(struct wined3d_device *device, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
Definition: device.c:1505
void multiply_matrix(D3DMATRIX *dst, const D3DMATRIX *src1, const D3DMATRIX *src2) DECLSPEC_HIDDEN
Definition: utils.c:1173

Referenced by viewport_activate().

◆ viewport_activate()

void viewport_activate ( struct d3d_viewport This,
BOOL  ignore_lights 
)

Definition at line 55 of file viewport.c.

56 {
57  struct wined3d_vec3 scale, offset;
58  D3DVIEWPORT7 vp;
59 
60  if (!ignore_lights)
61  {
62  struct d3d_light *light;
63 
64  /* Activate all the lights associated with this context */
65  LIST_FOR_EACH_ENTRY(light, &This->light_list, struct d3d_light, entry)
66  {
68  }
69  }
70 
71  /* And copy the values in the structure used by the device */
72  if (This->use_vp2)
73  {
74  vp.dwX = This->viewports.vp2.dwX;
75  vp.dwY = This->viewports.vp2.dwY;
76  vp.dwHeight = This->viewports.vp2.dwHeight;
77  vp.dwWidth = This->viewports.vp2.dwWidth;
78  vp.dvMinZ = 0.0f;
79  vp.dvMaxZ = 1.0f;
80 
81  scale.x = 2.0f / This->viewports.vp2.dvClipWidth;
82  scale.y = 2.0f / This->viewports.vp2.dvClipHeight;
83  scale.z = 1.0f / (This->viewports.vp2.dvMaxZ - This->viewports.vp2.dvMinZ);
84  offset.x = -2.0f * This->viewports.vp2.dvClipX / This->viewports.vp2.dvClipWidth - 1.0f;
85  offset.y = -2.0f * This->viewports.vp2.dvClipY / This->viewports.vp2.dvClipHeight + 1.0f;
86  offset.z = -This->viewports.vp2.dvMinZ / (This->viewports.vp2.dvMaxZ - This->viewports.vp2.dvMinZ);
87  }
88  else
89  {
90  vp.dwX = This->viewports.vp1.dwX;
91  vp.dwY = This->viewports.vp1.dwY;
92  vp.dwHeight = This->viewports.vp1.dwHeight;
93  vp.dwWidth = This->viewports.vp1.dwWidth;
94  vp.dvMinZ = 0.0f;
95  vp.dvMaxZ = 1.0f;
96 
97  scale.x = 2.0f * This->viewports.vp1.dvScaleX / This->viewports.vp1.dwWidth;
98  scale.y = 2.0f * This->viewports.vp1.dvScaleY / This->viewports.vp1.dwHeight;
99  scale.z = 1.0f;
100  offset.x = 0.0f;
101  offset.y = 0.0f;
102  offset.z = 0.0f;
103  }
104 
105  update_clip_space(This->active_device, &scale, &offset);
106  IDirect3DDevice7_SetViewport(&This->active_device->IDirect3DDevice7_iface, &vp);
107 }
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLintptr offset
Definition: glext.h:5920
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
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static void update_clip_space(struct d3d_device *device, struct wined3d_vec3 *scale, struct wined3d_vec3 *offset)
Definition: viewport.c:31
void light_activate(struct d3d_light *light) DECLSPEC_HIDDEN
Definition: light.c:51
uint32_t entry
Definition: isohybrid.c:63
#define IDirect3DDevice7_SetViewport(p, a)
Definition: d3d.h:1356

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

◆ 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_Clear(IDirect3DViewport3 *iface, DWORD rect_count, D3DRECT *rects, DWORD flags)
Definition: viewport.c:651
static HRESULT WINAPI d3d_viewport_GetViewport(IDirect3DViewport3 *iface, D3DVIEWPORT *lpData)
Definition: viewport.c:265
static HRESULT WINAPI d3d_viewport_LightElements(IDirect3DViewport3 *iface, DWORD element_count, D3DLIGHTDATA *data)
Definition: viewport.c:529
static HRESULT WINAPI d3d_viewport_QueryInterface(IDirect3DViewport3 *iface, REFIID riid, void **object)
Definition: viewport.c:168
static HRESULT WINAPI d3d_viewport_Initialize(IDirect3DViewport3 *iface, IDirect3D *d3d)
Definition: viewport.c:245
static HRESULT WINAPI d3d_viewport_NextLight(IDirect3DViewport3 *iface, IDirect3DLight *lpDirect3DLight, IDirect3DLight **lplpDirect3DLight, DWORD flags)
Definition: viewport.c:821
static HRESULT WINAPI d3d_viewport_SetBackgroundDepth(IDirect3DViewport3 *iface, IDirectDrawSurface *surface)
Definition: viewport.c:605
static HRESULT WINAPI d3d_viewport_GetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE *material, BOOL *valid)
Definition: viewport.c:576
static HRESULT WINAPI d3d_viewport_SetViewport(IDirect3DViewport3 *iface, D3DVIEWPORT *lpData)
Definition: viewport.c:317
static HRESULT WINAPI d3d_viewport_GetBackgroundDepth(IDirect3DViewport3 *iface, IDirectDrawSurface **surface, BOOL *valid)
Definition: viewport.c:626
static HRESULT WINAPI d3d_viewport_GetBackgroundDepth2(IDirect3DViewport3 *iface, IDirectDrawSurface4 **surface, BOOL *valid)
Definition: viewport.c:1022
static HRESULT WINAPI d3d_viewport_SetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *lpData)
Definition: viewport.c:951
static ULONG WINAPI d3d_viewport_Release(IDirect3DViewport3 *iface)
Definition: viewport.c:216
static HRESULT WINAPI d3d_viewport_GetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *lpData)
Definition: viewport.c:901
static HRESULT WINAPI d3d_viewport_AddLight(IDirect3DViewport3 *iface, IDirect3DLight *lpDirect3DLight)
Definition: viewport.c:720
static HRESULT WINAPI d3d_viewport_TransformVertices(IDirect3DViewport3 *iface, DWORD dwVertexCount, D3DTRANSFORMDATA *data, DWORD dwFlags, DWORD *offscreen)
Definition: viewport.c:393
static HRESULT WINAPI d3d_viewport_DeleteLight(IDirect3DViewport3 *iface, IDirect3DLight *lpDirect3DLight)
Definition: viewport.c:780
static HRESULT WINAPI d3d_viewport_SetBackgroundDepth2(IDirect3DViewport3 *iface, IDirectDrawSurface4 *surface)
Definition: viewport.c:1001
static HRESULT WINAPI d3d_viewport_Clear2(IDirect3DViewport3 *iface, DWORD rect_count, D3DRECT *rects, DWORD flags, DWORD color, D3DVALUE depth, DWORD stencil)
Definition: viewport.c:1046
static ULONG WINAPI d3d_viewport_AddRef(IDirect3DViewport3 *iface)
Definition: viewport.c:197
static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE material)
Definition: viewport.c:537

Definition at line 1094 of file viewport.c.

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