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.

108 lines
2.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef GAMEUIDYNAMICTEXTURES_H
  8. #define GAMEUIDYNAMICTEXTURES_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier1/utlobjectreference.h"
  13. #include "tier1/utldict.h"
  14. #include "tier1/utlstring.h"
  15. #include "tier1/utlstringmap.h"
  16. #include "materialsystem/materialsystemutil.h"
  17. #include "materialsystem/imaterialproxy.h"
  18. #include "bitmap/texturepacker.h"
  19. //----------------------------------------------------------------------------
  20. // Helper class for entries in the packer
  21. //----------------------------------------------------------------------------
  22. class ImageAliasData_t
  23. {
  24. public:
  25. ImageAliasData_t()
  26. {
  27. Init();
  28. }
  29. void Init()
  30. {
  31. m_XPos = 0;
  32. m_YPos = 0;
  33. m_Width = 0;
  34. m_Height = 0;
  35. m_szBaseTextureName = "";
  36. m_Material = NULL;
  37. m_bIsInSheet = false;
  38. m_nNodeIndex = -1;
  39. m_nRefCount = 0;
  40. }
  41. int m_XPos;
  42. int m_YPos;
  43. int m_Width;
  44. int m_Height;
  45. CUtlString m_szBaseTextureName;
  46. CMaterialReference m_Material;
  47. bool m_bIsInSheet;
  48. int m_nNodeIndex;
  49. int m_nRefCount;
  50. private:
  51. ImageAliasData_t( ImageAliasData_t &ref ) { }
  52. };
  53. //-----------------------------------------------------------------------------
  54. // A template describing how a gameUI will function
  55. // It loads CVguiCompiledDoc
  56. //-----------------------------------------------------------------------------
  57. class CGameUIDynamicTextures
  58. {
  59. public:
  60. CGameUIDynamicTextures();
  61. ~CGameUIDynamicTextures();
  62. void InitRenderTargets();
  63. IMaterialProxy *CreateProxy( const char *proxyName );
  64. void Shutdown();
  65. void SetImageEntry( const char *pEntryName, ImageAliasData_t &imageData );
  66. void LoadImageAlias( const char *pAlias, const char *pBaseTextureName );
  67. void ReleaseImageAlias( const char *pAlias );
  68. IMaterial *GetImageAliasMaterial( const char *pAlias );
  69. ImageAliasData_t *GetImageAliasData( const char *pAlias );
  70. bool IsErrorImageAliasData( ImageAliasData_t *pData );
  71. void GetDynamicSheetSize( int &nWidth, int &nHeight );
  72. void DrawDynamicTexture( const char *pAlias, int x, int y );
  73. void OnRestore( int nChangeFlags );
  74. void RegenerateTexture( int nChangeFlags );
  75. private:
  76. void LoadImageAliasTexture( const char *pAlias, const char *pBaseTextureName );
  77. // Stores the actual texture we're writing into
  78. CTextureReference m_TexturePage;
  79. CTexturePacker *m_pDynamicTexturePacker;
  80. CUtlStringMap< ImageAliasData_t > m_ImageAliasMap;
  81. CMaterialReference m_RenderMaterial; // used to render dynamic textures into the render target.
  82. bool m_bRegenerate;
  83. };
  84. #endif // GAMEUIDYNAMICTEXTURES_H