DragonNest/Common/EternityEngine/EtMRTMng.cpp
Cussrro 47f7895977 Revert "修复编码问题"
This reverts commit 9e69c01767.
2024-12-21 10:04:04 +08:00

90 lines
1.7 KiB
C++

#include "StdAfx.h"
#include "EtMRTMng.h"
#include "EtOptionController.h"
#ifdef _DEBUG
#define new new(_NORMAL_BLOCK,__FILE__,__LINE__)
#endif
CEtMRTMng::CEtMRTMng(void)
{
m_bEnable = true;
m_bInit = false;
m_bClearNeeded = false;
m_pBackupSurface = NULL;
}
CEtMRTMng::~CEtMRTMng(void)
{
SAFE_RELEASE_SPTR( m_hDepthTarget );
SAFE_RELEASE_SPTR( m_hVelocityTarget );
}
void CEtMRTMng::Initialize()
{
SAFE_RELEASE_SPTR( m_hDepthTarget );
m_hDepthTarget = CEtTexture::CreateRenderTargetTexture( -1, -1, FMT_R32F );
if( GetEtOptionController()->IsEnableMotionBlur() )
{
EtFormat Format;
Format = FMT_G16R16F;
if( !GetEtDevice()->CheckDeviceFormat( Format, USAGE_RENDERTARGET ) )
{
Format = FMT_A16B16G16R16F;
if( !GetEtDevice()->CheckDeviceFormat( Format, USAGE_RENDERTARGET ) )
{
Format = FMT_UNKNOWN;
}
}
if( Format != FMT_UNKNOWN )
{
m_hVelocityTarget = CEtTexture::CreateRenderTargetTexture( -1, -1, Format );
}
else
{
SGraphicOption Option;
GetEtOptionController()->GetGraphicOption( Option );
Option.bEnableMotionBlur = false;
GetEtOptionController()->SetGraphicOption( Option );
}
}
m_bInit = true;
}
void CEtMRTMng::ClearDepthTarget()
{
m_bClearNeeded = true;
}
bool CEtMRTMng::BeginDepthTarget()
{
if( !m_bEnable )
{
return true ;
}
if( !m_bInit )
{
Initialize();
}
m_pBackupSurface = GetEtDevice()->GetRenderTarget();
GetEtDevice()->SetRenderTarget( m_hDepthTarget->GetSurfaceLevel() );
if( m_bClearNeeded ) {
GetEtDevice()->ClearBuffer( 0x00000000, 1.0f, 0, true, true, true );
m_bClearNeeded = false;
}
return true;
}
void CEtMRTMng::EndDepthTarget()
{
if( !m_bEnable )
{
return;
}
GetEtDevice()->SetRenderTarget( m_pBackupSurface );
}