Commit 9a0b2a51 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw: device::GetCurrentViewport returns an error if no viewport is set.

parent 07197a19
...@@ -1758,16 +1758,18 @@ static HRESULT WINAPI d3d_device3_GetCurrentViewport(IDirect3DDevice3 *iface, ID ...@@ -1758,16 +1758,18 @@ static HRESULT WINAPI d3d_device3_GetCurrentViewport(IDirect3DDevice3 *iface, ID
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
wined3d_mutex_lock(); wined3d_mutex_lock();
*viewport = &device->current_viewport->IDirect3DViewport3_iface; if (!device->current_viewport)
{
wined3d_mutex_unlock();
WARN("No current viewport, returning D3DERR_NOCURRENTVIEWPORT\n");
return D3DERR_NOCURRENTVIEWPORT;
}
/* AddRef the returned viewport */ *viewport = &device->current_viewport->IDirect3DViewport3_iface;
if (*viewport) IDirect3DViewport3_AddRef(*viewport);
IDirect3DViewport3_AddRef(*viewport);
TRACE("Returning interface %p.\n", *viewport); TRACE("Returning interface %p.\n", *viewport);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
......
...@@ -342,10 +342,10 @@ static HRESULT WINAPI d3d_viewport_SetViewport(IDirect3DViewport3 *iface, D3DVIE ...@@ -342,10 +342,10 @@ static HRESULT WINAPI d3d_viewport_SetViewport(IDirect3DViewport3 *iface, D3DVIE
This->viewports.vp1.dvMinZ = 0.0; This->viewports.vp1.dvMinZ = 0.0;
This->viewports.vp1.dvMaxZ = 1.0; This->viewports.vp1.dvMaxZ = 1.0;
if (This->active_device) { if (This->active_device)
{
IDirect3DDevice3 *d3d_device3 = &This->active_device->IDirect3DDevice3_iface; IDirect3DDevice3 *d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport); if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport)))
if (current_viewport)
{ {
if (current_viewport == iface) viewport_activate(This, FALSE); if (current_viewport == iface) viewport_activate(This, FALSE);
IDirect3DViewport3_Release(current_viewport); IDirect3DViewport3_Release(current_viewport);
...@@ -705,8 +705,7 @@ static HRESULT WINAPI d3d_viewport_Clear(IDirect3DViewport3 *iface, ...@@ -705,8 +705,7 @@ static HRESULT WINAPI d3d_viewport_Clear(IDirect3DViewport3 *iface,
hr = IDirect3DDevice7_Clear(&This->active_device->IDirect3DDevice7_iface, rect_count, rects, hr = IDirect3DDevice7_Clear(&This->active_device->IDirect3DDevice7_iface, rect_count, rects,
flags & (D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET), color, 1.0, 0x00000000); flags & (D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET), color, 1.0, 0x00000000);
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport); if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport)))
if (current_viewport)
{ {
struct d3d_viewport *vp = impl_from_IDirect3DViewport3(current_viewport); struct d3d_viewport *vp = impl_from_IDirect3DViewport3(current_viewport);
viewport_activate(vp, TRUE); viewport_activate(vp, TRUE);
...@@ -979,10 +978,10 @@ static HRESULT WINAPI d3d_viewport_SetViewport2(IDirect3DViewport3 *iface, D3DVI ...@@ -979,10 +978,10 @@ static HRESULT WINAPI d3d_viewport_SetViewport2(IDirect3DViewport3 *iface, D3DVI
memset(&(This->viewports.vp2), 0, sizeof(This->viewports.vp2)); memset(&(This->viewports.vp2), 0, sizeof(This->viewports.vp2));
memcpy(&(This->viewports.vp2), lpData, lpData->dwSize); memcpy(&(This->viewports.vp2), lpData, lpData->dwSize);
if (This->active_device) { if (This->active_device)
{
IDirect3DDevice3 *d3d_device3 = &This->active_device->IDirect3DDevice3_iface; IDirect3DDevice3 *d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport); if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport)))
if (current_viewport)
{ {
if (current_viewport == iface) viewport_activate(This, FALSE); if (current_viewport == iface) viewport_activate(This, FALSE);
IDirect3DViewport3_Release(current_viewport); IDirect3DViewport3_Release(current_viewport);
...@@ -1087,8 +1086,7 @@ static HRESULT WINAPI d3d_viewport_Clear2(IDirect3DViewport3 *iface, DWORD rect_ ...@@ -1087,8 +1086,7 @@ static HRESULT WINAPI d3d_viewport_Clear2(IDirect3DViewport3 *iface, DWORD rect_
hr = IDirect3DDevice7_Clear(&viewport->active_device->IDirect3DDevice7_iface, hr = IDirect3DDevice7_Clear(&viewport->active_device->IDirect3DDevice7_iface,
rect_count, rects, flags, color, depth, stencil); rect_count, rects, flags, color, depth, stencil);
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport); if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport)))
if (current_viewport)
{ {
struct d3d_viewport *vp = impl_from_IDirect3DViewport3(current_viewport); struct d3d_viewport *vp = impl_from_IDirect3DViewport3(current_viewport);
viewport_activate(vp, TRUE); viewport_activate(vp, TRUE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment