forked from metin-server/m2dev-client-src
ported to DX9
This commit is contained in:
@@ -36,7 +36,7 @@ void CMapOutdoor::CreateCharacterShadowTexture()
|
||||
m_ShadowMapViewport.MinZ = 0.0f;
|
||||
m_ShadowMapViewport.MaxZ = 1.0f;
|
||||
|
||||
if (FAILED(ms_lpd3dDevice->CreateTexture(m_wShadowMapSize, m_wShadowMapSize, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &m_lpCharacterShadowMapTexture)))
|
||||
if (FAILED(ms_lpd3dDevice->CreateTexture(m_wShadowMapSize, m_wShadowMapSize, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &m_lpCharacterShadowMapTexture, nullptr)))
|
||||
{
|
||||
TraceError("CMapOutdoor Unable to create Character Shadow render target texture\n");
|
||||
return;
|
||||
@@ -48,7 +48,7 @@ void CMapOutdoor::CreateCharacterShadowTexture()
|
||||
return;
|
||||
}
|
||||
|
||||
if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_wShadowMapSize, m_wShadowMapSize, D3DFMT_D16, D3DMULTISAMPLE_NONE, &m_lpCharacterShadowMapDepthSurface)))
|
||||
if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_wShadowMapSize, m_wShadowMapSize, D3DFMT_D16, D3DMULTISAMPLE_NONE, 0, TRUE, &m_lpCharacterShadowMapDepthSurface, nullptr)))
|
||||
{
|
||||
TraceError("CMapOutdoor Unable to create Character Shadow depth Surface\n");
|
||||
return;
|
||||
@@ -105,53 +105,26 @@ bool CMapOutdoor::BeginRenderCharacterShadowToTexture()
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
|
||||
bool bSuccess = true;
|
||||
ms_lpd3dDevice->GetDepthStencilSurface(&m_lpBackupDepthSurface);
|
||||
ms_lpd3dDevice->GetRenderTarget(0, &m_lpBackupRenderTargetSurface);
|
||||
|
||||
// Backup Device Context
|
||||
if (FAILED(ms_lpd3dDevice->GetRenderTarget(&m_lpBackupRenderTargetSurface)))
|
||||
{
|
||||
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Save Window Render Target\n");
|
||||
bSuccess = false;
|
||||
}
|
||||
ms_lpd3dDevice->SetRenderTarget(0, m_lpCharacterShadowMapRenderTargetSurface);
|
||||
ms_lpd3dDevice->SetDepthStencilSurface(m_lpCharacterShadowMapDepthSurface);
|
||||
|
||||
if (FAILED(ms_lpd3dDevice->GetDepthStencilSurface(&m_lpBackupDepthSurface)))
|
||||
{
|
||||
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Save Window Depth Surface\n");
|
||||
bSuccess = false;
|
||||
}
|
||||
ms_lpd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xFFFFFFFF, 1.0f, 0);
|
||||
|
||||
if (FAILED(ms_lpd3dDevice->SetRenderTarget(m_lpCharacterShadowMapRenderTargetSurface, m_lpCharacterShadowMapDepthSurface)))
|
||||
{
|
||||
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Set Shadow Map Render Target\n");
|
||||
bSuccess = false;
|
||||
}
|
||||
ms_lpd3dDevice->GetViewport(&m_BackupViewport);
|
||||
ms_lpd3dDevice->SetViewport(&m_ShadowMapViewport);
|
||||
|
||||
if (FAILED(ms_lpd3dDevice->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0xFF, 0xFF, 0xFF), 1.0f, 0)))
|
||||
{
|
||||
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Clear Render Target");
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
if (FAILED(ms_lpd3dDevice->GetViewport(&m_BackupViewport)))
|
||||
{
|
||||
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Save Window Viewport\n");
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
if (FAILED(ms_lpd3dDevice->SetViewport(&m_ShadowMapViewport)))
|
||||
{
|
||||
TraceError("CMapOutdoor::BeginRenderCharacterShadowToTexture : Unable to Set Shadow Map viewport\n");
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMapOutdoor::EndRenderCharacterShadowToTexture()
|
||||
{
|
||||
ms_lpd3dDevice->SetViewport(&m_BackupViewport);
|
||||
|
||||
ms_lpd3dDevice->SetRenderTarget(m_lpBackupRenderTargetSurface, m_lpBackupDepthSurface);
|
||||
ms_lpd3dDevice->SetDepthStencilSurface(m_lpBackupDepthSurface);
|
||||
ms_lpd3dDevice->SetRenderTarget(0, m_lpBackupRenderTargetSurface);
|
||||
|
||||
SAFE_RELEASE(m_lpBackupRenderTargetSurface);
|
||||
SAFE_RELEASE(m_lpBackupDepthSurface);
|
||||
|
||||
Reference in New Issue
Block a user