hl2_src-leak-2017/src/game/client/tf/tf_rendertargets.cpp
BotoX 60f625f414 import hl2_src from full.7z
source: magnet:?xt=urn:btih:21DDA6847DDE983F2F8063739249D2D1D09A5DDA
2020-12-25 16:26:23 +01:00

73 lines
3.0 KiB
C++

//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: L4D mod render targets are specified by and accessable through this singleton
//
// $NoKeywords: $
//===========================================================================//
#include "cbase.h"
#include "tf_rendertargets.h"
#include "materialsystem/imaterialsystem.h"
#include "rendertexture.h"
#if defined( REPLAY_ENABLED )
#include "replay/replay_screenshot.h"
#endif
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
ITexture *CTFRenderTargets::CreateItemModelPanelTexture( const char *pszName, IMaterialSystem* pMaterialSystem, int iSize )
{
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
pszName,
iSize, iSize, RT_SIZE_DEFAULT,
pMaterialSystem->GetBackBufferFormat(),
MATERIAL_RT_DEPTH_SHARED,
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
0 );
}
//-----------------------------------------------------------------------------
// Purpose: InitClientRenderTargets, interface called by the engine at material system init in the engine
// Input : pMaterialSystem - the interface to the material system from the engine (our singleton hasn't been set up yet)
// pHardwareConfig - the user's hardware config, useful for conditional render targets setup
//-----------------------------------------------------------------------------
extern const char *g_ItemModelPanelRenderTargetNames[];
extern const char *g_pszModelImagePanelRTName;
void CTFRenderTargets::InitClientRenderTargets( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig )
{
BaseClass::InitClientRenderTargets( pMaterialSystem, pHardwareConfig );
// rt for item model panels
for ( int i = 0; i < ITEM_MODEL_IMAGE_CACHE_SIZE; i++ )
{
int index = m_tfRenderTargets.AddToTail();
m_tfRenderTargets[index].Init( CreateItemModelPanelTexture( g_ItemModelPanelRenderTargetNames[i], pMaterialSystem, 256 ) );
}
// rt for CModelImagePanel
int index = m_tfRenderTargets.AddToTail();
m_tfRenderTargets[index].Init( CreateItemModelPanelTexture( g_pszModelImagePanelRTName, pMaterialSystem, 256 ) );
CReplayScreenshotTaker::CreateRenderTarget( pMaterialSystem );
}
//-----------------------------------------------------------------------------
// Purpose: Shutdown client render targets. This gets called during shutdown in the engine
// Input : -
//-----------------------------------------------------------------------------
void CTFRenderTargets::ShutdownClientRenderTargets()
{
BaseClass::ShutdownClientRenderTargets();
for ( int i = 0; i < m_tfRenderTargets.Count(); i++ )
{
m_tfRenderTargets[i].Shutdown();
}
m_tfRenderTargets.Purge();
}
static CTFRenderTargets g_TFRenderTargets;
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CTFRenderTargets, IClientRenderTargets,
CLIENTRENDERTARGETS_INTERFACE_VERSION, g_TFRenderTargets );
CTFRenderTargets* g_pTFRenderTargets = &g_TFRenderTargets;