Counter Strike : Global Offensive Source Code
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.

147 lines
4.9 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $Header: $
  6. // $NoKeywords: $
  7. //===========================================================================//
  8. #ifndef TEXTUREMANAGER_H
  9. #define TEXTUREMANAGER_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "itextureinternal.h"
  14. class ITexture;
  15. class ITextureInternal;
  16. class IVTFTexture;
  17. enum
  18. {
  19. COLOR_CORRECTION_MAX_TEXTURES = 4,
  20. COLOR_CORRECTION_TEXTURE_SIZE = 32
  21. };
  22. //-----------------------------------------------------------------------------
  23. // Texture manager interface
  24. //-----------------------------------------------------------------------------
  25. abstract_class ITextureManager
  26. {
  27. public:
  28. // Initialization + shutdown
  29. virtual void Init( int nFlags ) = 0;
  30. virtual void Shutdown() = 0;
  31. // Allocate, free standard render target textures
  32. virtual void AllocateStandardRenderTargets( ) = 0;
  33. virtual void FreeStandardRenderTargets() = 0;
  34. //Some render targets are managed by code outside of the materialsystem but are used by the materialsystem all the time.
  35. virtual void CacheExternalStandardRenderTargets() = 0;
  36. // Creates a procedural texture
  37. // NOTE: Passing in NULL as a texture name will cause it to not
  38. // be able to be looked up by name using FindOrLoadTexture.
  39. // NOTE: Using compressed textures is not allowed; also
  40. // Also, you may not get a texture with the requested size or format;
  41. // you'll get something close though.
  42. virtual ITextureInternal *CreateProceduralTexture(
  43. const char *pTextureName,
  44. const char *pTextureGroupName,
  45. int w,
  46. int h,
  47. int d,
  48. ImageFormat fmt,
  49. int nFlags ) = 0;
  50. // Creates a texture which is a render target
  51. virtual ITextureInternal *CreateRenderTargetTexture(
  52. const char *pRTName, // NULL for auto-generated name
  53. int w,
  54. int h,
  55. RenderTargetSizeMode_t sizeMode,
  56. ImageFormat fmt,
  57. RenderTargetType_t type,
  58. unsigned int textureFlags,
  59. unsigned int renderTargetFlags,
  60. bool bMultipleTargets ) = 0;
  61. // Loads a texture from disk
  62. virtual ITextureInternal *FindOrLoadTexture( const char *pTextureName, const char *pTextureGroupName, int nAdditionalCreationFlags = 0 ) = 0;
  63. // Call this to reset the filtering state
  64. virtual void ResetTextureFilteringState() = 0;
  65. // Reload all textures
  66. virtual void ReloadTextures( void ) = 0;
  67. // These two are used when we lose our video memory due to a mode switch etc
  68. virtual void ReleaseTextures( bool bReleaseManaged = true ) = 0;
  69. virtual void RestoreRenderTargets( void ) = 0;
  70. virtual void RestoreNonRenderTargetTextures( void ) = 0;
  71. // delete any texture that has a refcount <= 0
  72. virtual void RemoveUnusedTextures( void ) = 0;
  73. virtual void DebugPrintUsedTextures( void ) = 0;
  74. // Request a texture ID
  75. virtual int RequestNextTextureID() = 0;
  76. // Get at a couple standard textures
  77. virtual ITextureInternal *ErrorTexture() = 0;
  78. virtual ITextureInternal *NormalizationCubemap() = 0;
  79. virtual ITextureInternal *SignedNormalizationCubemap() = 0;
  80. virtual ITextureInternal *ColorCorrectionTexture( int index ) = 0;
  81. virtual ITextureInternal *ShadowNoise2D() = 0;
  82. virtual ITextureInternal *SSAONoise2D() = 0;
  83. virtual ITextureInternal *IdentityLightWarp() = 0;
  84. virtual ITextureInternal *FullFrameDepthTexture() = 0;
  85. virtual ITextureInternal *StereoParamTexture() = 0;
  86. // Generates an error texture pattern
  87. virtual void GenerateErrorTexture( ITexture *pTexture, IVTFTexture *pVTFTexture ) = 0;
  88. // Updates the color correction state
  89. virtual void SetColorCorrectionTexture( int i, ITextureInternal *pTexture ) = 0;
  90. virtual void ForceAllTexturesIntoHardware( void ) = 0;
  91. virtual bool IsTextureLoaded( const char *pTextureName ) = 0;
  92. virtual bool GetTextureInformation( char const *szTextureName, MaterialTextureInfo_t &info ) = 0;
  93. virtual void RemoveTexture( ITextureInternal *pTexture ) = 0;
  94. // start with -1, list terminates with -1
  95. virtual int FindNext( int iIndex, ITextureInternal **ppTexture ) = 0;
  96. virtual void AddTextureAlias( const char *pAlias, const char *pRealName ) = 0;
  97. virtual void RemoveTextureAlias( const char *pAlias ) = 0;
  98. virtual void SetExcludedTextures( const char *pScriptName, bool bUsingWeaponModelCache ) = 0;
  99. virtual void UpdateExcludedTextures( void ) = 0;
  100. virtual void ClearForceExcludes( void ) = 0;
  101. //Releases texture memory bits for temporary render targets, does NOT destroy the CTexture entirely
  102. virtual void ReleaseTempRenderTargetBits( void ) = 0;
  103. // See CL_HandlePureServerWhitelist for a description of the pure server stuff.
  104. virtual void ReloadFilesInList( IFileList *pFilesToReload ) = 0;
  105. };
  106. //-----------------------------------------------------------------------------
  107. // Singleton instance
  108. //-----------------------------------------------------------------------------
  109. inline ITextureManager *TextureManager()
  110. {
  111. extern ITextureManager *g_pTextureManager;
  112. return g_pTextureManager;
  113. }
  114. #endif // TEXTUREMANAGER_H