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.

92 lines
2.3 KiB

  1. //====== Copyright � 1996-2003, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef PROCEDURALTEXTUREPANEL_H
  7. #define PROCEDURALTEXTUREPANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "materialsystem/itexture.h"
  12. #include "materialsystem/MaterialSystemUtil.h"
  13. #include "vgui_controls/EditablePanel.h"
  14. //-----------------------------------------------------------------------------
  15. // Forward declarations
  16. //-----------------------------------------------------------------------------
  17. struct BGRA8888_t;
  18. //-----------------------------------------------------------------------------
  19. //
  20. // Procedural texture image panel
  21. //
  22. //-----------------------------------------------------------------------------
  23. class CProceduralTexturePanel : public vgui::EditablePanel, public ITextureRegenerator
  24. {
  25. DECLARE_CLASS_SIMPLE( CProceduralTexturePanel, vgui::EditablePanel );
  26. public:
  27. // constructor
  28. CProceduralTexturePanel( vgui::Panel *pParent, const char *pName );
  29. ~CProceduralTexturePanel();
  30. // Methods of ITextureRegenerator
  31. virtual void Release() {}
  32. virtual void RegenerateTextureBits( ITexture *pTexture, IVTFTexture *pVTFTexture, Rect_t *pRect );
  33. // initialization, shutdown
  34. virtual bool Init( int nWidth, int nHeight, bool bAllocateImageBuffer );
  35. virtual void Shutdown();
  36. // Returns the image buffer + dimensions
  37. BGRA8888_t *GetImageBuffer();
  38. int GetImageWidth() const;
  39. int GetImageHeight() const;
  40. // Redownloads the procedural texture
  41. void DownloadTexture();
  42. // Sets the rectangle to paint. Use null to fill the entire panel
  43. void SetPaintRect( const Rect_t *pPaintRect = NULL );
  44. // Sets the texcoords to use with the procedural texture
  45. void SetTextureSubRect( const Rect_t &subRect );
  46. // Maintain proportions when drawing
  47. void MaintainProportions( bool bEnable );
  48. virtual void Paint( void );
  49. virtual void PaintBackground( void ) {}
  50. private:
  51. void CleanUp();
  52. protected:
  53. // Image buffer
  54. BGRA8888_t *m_pImageBuffer;
  55. int m_nWidth;
  56. int m_nHeight;
  57. // Paint rectangle
  58. Rect_t m_PaintRect;
  59. // Texture coordinate rectangle
  60. Rect_t m_TextureSubRect;
  61. CTextureReference m_ProceduralTexture;
  62. CMaterialReference m_ProceduralMaterial;
  63. int m_nTextureID;
  64. bool m_bMaintainProportions;
  65. bool m_bUsePaintRect;
  66. };
  67. #endif // PROCEDURALTEXTUREPANEL_H