mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2024-12-23 01:59:43 +08:00
81 lines
3.2 KiB
C++
81 lines
3.2 KiB
C++
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
|
//
|
|
// Purpose: Implementation for CBaseClientRenderTargets class.
|
|
// Provides Init functions for common render textures used by the engine.
|
|
// Mod makers can inherit from this class, and call the Create functions for
|
|
// only the render textures the want for their mod.
|
|
//
|
|
// $NoKeywords: $
|
|
//=============================================================================//
|
|
#include "cbase.h"
|
|
#include "baseclientrendertargets.h" // header
|
|
#include "materialsystem/imaterialsystemhardwareconfig.h" // Hardware config checks
|
|
|
|
|
|
ITexture* CBaseClientRenderTargets::CreateWaterReflectionTexture( IMaterialSystem* pMaterialSystem )
|
|
{
|
|
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
|
|
"_rt_WaterReflection",
|
|
1024, 1024, RT_SIZE_PICMIP,
|
|
pMaterialSystem->GetBackBufferFormat(),
|
|
MATERIAL_RT_DEPTH_SHARED,
|
|
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
|
|
CREATERENDERTARGETFLAGS_HDR );
|
|
}
|
|
|
|
|
|
ITexture* CBaseClientRenderTargets::CreateWaterRefractionTexture( IMaterialSystem* pMaterialSystem )
|
|
{
|
|
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
|
|
"_rt_WaterRefraction",
|
|
1024, 1024, RT_SIZE_PICMIP,
|
|
// This is different than reflection because it has to have alpha for fog factor.
|
|
IMAGE_FORMAT_RGBA8888,
|
|
MATERIAL_RT_DEPTH_SHARED,
|
|
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
|
|
CREATERENDERTARGETFLAGS_HDR );
|
|
}
|
|
|
|
|
|
ITexture* CBaseClientRenderTargets::CreateCameraTexture( IMaterialSystem* pMaterialSystem )
|
|
{
|
|
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
|
|
"_rt_Camera",
|
|
256, 256, RT_SIZE_DEFAULT,
|
|
pMaterialSystem->GetBackBufferFormat(),
|
|
MATERIAL_RT_DEPTH_SHARED,
|
|
0,
|
|
CREATERENDERTARGETFLAGS_HDR );
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Called by the engine in material system init and shutdown.
|
|
// Clients should override this in their inherited version, but the base
|
|
// is to init all standard render targets for use.
|
|
// Input : pMaterialSystem - the engine's material system (our singleton is not yet inited at the time this is called)
|
|
// pHardwareConfig - the user hardware config, useful for conditional render target setup
|
|
//-----------------------------------------------------------------------------
|
|
void CBaseClientRenderTargets::InitClientRenderTargets( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig )
|
|
{
|
|
// Water effects
|
|
m_WaterReflectionTexture.Init( CreateWaterReflectionTexture( pMaterialSystem ) );
|
|
m_WaterRefractionTexture.Init ( CreateWaterRefractionTexture( pMaterialSystem ) );
|
|
|
|
// Monitors
|
|
m_CameraTexture.Init ( CreateCameraTexture( pMaterialSystem ) );
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Shut down each CTextureReference we created in InitClientRenderTargets.
|
|
// Called by the engine in material system shutdown.
|
|
// Input : -
|
|
//-----------------------------------------------------------------------------
|
|
void CBaseClientRenderTargets::ShutdownClientRenderTargets()
|
|
{
|
|
// Water effects
|
|
m_WaterReflectionTexture.Shutdown();
|
|
m_WaterRefractionTexture.Shutdown();
|
|
|
|
// Monitors
|
|
m_CameraTexture.Shutdown();
|
|
} |