Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: L4D mod render targets are specified by and accessable through this singleton
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "cbase.h"
  8. #include "tf_rendertargets.h"
  9. #include "materialsystem/imaterialsystem.h"
  10. #include "rendertexture.h"
  11. #if defined( REPLAY_ENABLED )
  12. #include "replay/replay_screenshot.h"
  13. #endif
  14. //-----------------------------------------------------------------------------
  15. // Purpose:
  16. //-----------------------------------------------------------------------------
  17. ITexture *CTFRenderTargets::CreateItemModelPanelTexture( const char *pszName, IMaterialSystem* pMaterialSystem, int iSize )
  18. {
  19. return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
  20. pszName,
  21. iSize, iSize, RT_SIZE_DEFAULT,
  22. pMaterialSystem->GetBackBufferFormat(),
  23. MATERIAL_RT_DEPTH_SHARED,
  24. TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
  25. 0 );
  26. }
  27. //-----------------------------------------------------------------------------
  28. // Purpose: InitClientRenderTargets, interface called by the engine at material system init in the engine
  29. // Input : pMaterialSystem - the interface to the material system from the engine (our singleton hasn't been set up yet)
  30. // pHardwareConfig - the user's hardware config, useful for conditional render targets setup
  31. //-----------------------------------------------------------------------------
  32. extern const char *g_ItemModelPanelRenderTargetNames[];
  33. extern const char *g_pszModelImagePanelRTName;
  34. void CTFRenderTargets::InitClientRenderTargets( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig )
  35. {
  36. BaseClass::InitClientRenderTargets( pMaterialSystem, pHardwareConfig );
  37. // rt for item model panels
  38. for ( int i = 0; i < ITEM_MODEL_IMAGE_CACHE_SIZE; i++ )
  39. {
  40. int index = m_tfRenderTargets.AddToTail();
  41. m_tfRenderTargets[index].Init( CreateItemModelPanelTexture( g_ItemModelPanelRenderTargetNames[i], pMaterialSystem, 256 ) );
  42. }
  43. // rt for CModelImagePanel
  44. int index = m_tfRenderTargets.AddToTail();
  45. m_tfRenderTargets[index].Init( CreateItemModelPanelTexture( g_pszModelImagePanelRTName, pMaterialSystem, 256 ) );
  46. CReplayScreenshotTaker::CreateRenderTarget( pMaterialSystem );
  47. }
  48. //-----------------------------------------------------------------------------
  49. // Purpose: Shutdown client render targets. This gets called during shutdown in the engine
  50. // Input : -
  51. //-----------------------------------------------------------------------------
  52. void CTFRenderTargets::ShutdownClientRenderTargets()
  53. {
  54. BaseClass::ShutdownClientRenderTargets();
  55. for ( int i = 0; i < m_tfRenderTargets.Count(); i++ )
  56. {
  57. m_tfRenderTargets[i].Shutdown();
  58. }
  59. m_tfRenderTargets.Purge();
  60. }
  61. static CTFRenderTargets g_TFRenderTargets;
  62. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CTFRenderTargets, IClientRenderTargets,
  63. CLIENTRENDERTARGETS_INTERFACE_VERSION, g_TFRenderTargets );
  64. CTFRenderTargets* g_pTFRenderTargets = &g_TFRenderTargets;