Skip to content

Commit

Permalink
Merge pull request #80 from elishacloud/master
Browse files Browse the repository at this point in the history
  • Loading branch information
crosire authored May 17, 2018
2 parents 100f6b5 + 007c3d2 commit 25c6edc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions source/d3d8to9.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class Direct3DDevice8 : public IUnknown
INT CurrentBaseVertexIndex = 0;
const BOOL ZBufferDiscarding = FALSE;
DWORD CurrentVertexShaderHandle = 0, CurrentPixelShaderHandle = 0;
IDirect3DSurface9 *pCurrentRenderTarget = nullptr;
bool PaletteFlag = false;

static constexpr size_t MAX_CLIP_PLANES = 6;
Expand Down
18 changes: 17 additions & 1 deletion source/d3d8to9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateTexture(UINT Width, UINT Height
{
Usage |= D3DUSAGE_RENDERTARGET;
}
else
else if (Usage != D3DUSAGE_DEPTHSTENCIL)
{
Usage |= D3DUSAGE_DYNAMIC;
}
Expand Down Expand Up @@ -410,6 +410,8 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateRenderTarget(UINT Width, UINT H
return hr;
}

pCurrentRenderTarget = SurfaceInterface;

*ppSurface = new Direct3DSurface8(this, SurfaceInterface);

return D3D_OK;
Expand Down Expand Up @@ -621,6 +623,8 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::SetRenderTarget(Direct3DSurface8 *pRe
{
return hr;
}

pCurrentRenderTarget = pRenderTarget->GetProxyInterface();
}

if (pNewZStencil != nullptr)
Expand Down Expand Up @@ -655,6 +659,8 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::GetRenderTarget(Direct3DSurface8 **pp
return hr;
}

pCurrentRenderTarget = SurfaceInterface;

*ppRenderTarget = ProxyAddressLookupTable->FindAddress<Direct3DSurface8>(SurfaceInterface);

return D3D_OK;
Expand Down Expand Up @@ -705,6 +711,16 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::MultiplyTransform(D3DTRANSFORMSTATETY
}
HRESULT STDMETHODCALLTYPE Direct3DDevice8::SetViewport(const D3DVIEWPORT8 *pViewport)
{
if (pCurrentRenderTarget != nullptr)
{
D3DSURFACE_DESC Desc;
HRESULT hr = pCurrentRenderTarget->GetDesc(&Desc);
if (SUCCEEDED(hr) && (pViewport->Height > Desc.Height || pViewport->Width > Desc.Width))
{
return D3DERR_INVALIDCALL;
}
}

return ProxyInterface->SetViewport(pViewport);
}
HRESULT STDMETHODCALLTYPE Direct3DDevice8::GetViewport(D3DVIEWPORT8 *pViewport)
Expand Down

0 comments on commit 25c6edc

Please sign in to comment.