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.

103 lines
3.8 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //===========================================================================//
  9. #ifndef MATERIALSYSTEMUTIL_H
  10. #define MATERIALSYSTEMUTIL_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "bitmap/imageformat.h" //ImageFormat enum definition
  15. #include "materialsystem/imaterialsystem.h" // RenderTargetSizeMode_t and MaterialRenderTargetDepth_t definition
  16. #include "materialsystem/itexture.h"
  17. //-----------------------------------------------------------------------------
  18. // Forward declarations
  19. //-----------------------------------------------------------------------------
  20. class IMaterial;
  21. class KeyValues;
  22. class KeyValues;
  23. //-----------------------------------------------------------------------------
  24. // Little utility class to deal with material references
  25. //-----------------------------------------------------------------------------
  26. class CMaterialReference
  27. {
  28. public:
  29. // constructor, destructor
  30. CMaterialReference( char const* pMaterialName = 0, const char *pTextureGroupName = 0, bool bComplain = true );
  31. ~CMaterialReference();
  32. // Attach to a material
  33. void Init( const char* pMaterialName, const char *pTextureGroupName, bool bComplain = true );
  34. void Init( const char *pMaterialName, KeyValues *pVMTKeyValues );
  35. void Init( IMaterial* pMaterial );
  36. void Init( CMaterialReference& ref );
  37. void Init( const char *pMaterialName, const char *pTextureGroupName, KeyValues *pVMTKeyValues );
  38. // Detach from a material
  39. void Shutdown( bool bDeleteIfUnreferenced = false );
  40. bool IsValid() { return m_pMaterial != 0; }
  41. // Automatic casts to IMaterial
  42. operator IMaterial*() { return m_pMaterial; }
  43. operator const IMaterial *() const { return m_pMaterial; }
  44. IMaterial* operator->() { return m_pMaterial; }
  45. // Assignment operator
  46. const CMaterialReference& operator=( const CMaterialReference &ref );
  47. private:
  48. CMaterialReference( CMaterialReference &ref ) { }
  49. IMaterial* m_pMaterial;
  50. };
  51. //-----------------------------------------------------------------------------
  52. // Little utility class to deal with texture references
  53. //-----------------------------------------------------------------------------
  54. class CTextureReference
  55. {
  56. public:
  57. // constructor, destructor
  58. CTextureReference( );
  59. CTextureReference( const CTextureReference &ref );
  60. ~CTextureReference();
  61. // Attach to a texture
  62. void Init( char const* pTexture, const char *pTextureGroupName, bool bComplain = true, int nAdditionalCreationFlags = 0 );
  63. void InitProceduralTexture( const char *pTextureName, const char *pTextureGroupName, int w, int h, ImageFormat fmt, int nFlags );
  64. void InitRenderTarget( int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat fmt, MaterialRenderTargetDepth_t depth, bool bHDR, char *pStrOptionalName = NULL );
  65. #if defined( _X360 )
  66. // used when RT coupling is disparate (texture is DDR based, surface is EDRAM based)
  67. void InitRenderTargetTexture( int width, int height, RenderTargetSizeMode_t sizeMode, ImageFormat fmt, MaterialRenderTargetDepth_t depth, bool bHDR, char *pStrOptionalName = NULL, int nRenderTargetFlags = 0 );
  68. void InitRenderTargetSurface( int width, int height, ImageFormat fmt, bool bSameAsTexture, RTMultiSampleCount360_t multiSampleCount = RT_MULTISAMPLE_NONE );
  69. #endif
  70. void Init( ITexture* pTexture );
  71. // Detach from a texture
  72. void Shutdown( bool bDeleteIfUnReferenced = false );
  73. bool IsValid() { return m_pTexture != 0; }
  74. // Automatic casts to ITexture
  75. operator ITexture*() { return m_pTexture; }
  76. operator ITexture const*() const { return m_pTexture; }
  77. ITexture* operator->() { return m_pTexture; }
  78. // Assignment operator
  79. const CTextureReference& operator=( CTextureReference &ref );
  80. private:
  81. ITexture* m_pTexture;
  82. };
  83. #endif // !MATERIALSYSTEMUTIL_H