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.

111 lines
2.3 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef AMALGAMATEDTEXTURE_H
  7. #define AMALGAMATEDTEXTURE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "amalg_texture_vars.h"
  12. #include "bitmap/floatbitmap.h"
  13. #include "tier1/utlmap.h"
  14. #include "tier1/utlstringmap.h"
  15. #include "tier2/tier2.h"
  16. struct Sequence;
  17. struct SequenceFrame
  18. {
  19. SequenceFrame() : m_mapSequences( DefLessFunc( Sequence * ) ) {}
  20. FloatBitMap_t *m_pImage;
  21. int m_XCoord, m_YCoord; // where it ended up packed
  22. CUtlMap< Sequence *, int > m_mapSequences;
  23. };
  24. struct SequenceEntry
  25. {
  26. SequenceFrame *m_pSeqFrame[MAX_IMAGES_PER_FRAME];
  27. float m_fDisplayTime;
  28. };
  29. struct Sequence
  30. {
  31. int m_nSequenceNumber;
  32. bool m_Clamp; // as opposed to loop
  33. int m_eMode;
  34. CUtlVector<SequenceEntry> m_Frames;
  35. Sequence( void )
  36. {
  37. m_Clamp = true;
  38. m_eMode = SQM_RGBA;
  39. }
  40. };
  41. // The texture itself.
  42. class CAmalgamatedTexture
  43. {
  44. public:
  45. CAmalgamatedTexture();
  46. void Init( const char *pShtFileName = NULL );
  47. void WriteFile();
  48. void DetermineBestPacking();
  49. bool PackImages( char const *pFilename, int nWidth );
  50. int GetWidth() { return m_nWidth; }
  51. void SetCurrentSequenceClamp( bool bState );
  52. void SetPackingMode( int mode );
  53. void CreateNewSequence( int sequenceNumber, int mode );
  54. void ValidateSequenceType( int eMode, char *word );
  55. void SetSequenceType( int eMode );
  56. bool CurrentSequenceExists();
  57. void CreateFrame( float ftime, CUtlVector<char *> &frameNames );
  58. void LoadFrame( SequenceEntry &newSequenceEntry, char *fnamebuf, int frameNumber );
  59. private:
  60. int GetPackingMode();
  61. int GetSequenceType();
  62. void ValidateFramePacking( SequenceFrame *pBitmap, char *fileName );
  63. bool PackImages_Flat( char const *pFilename, int nWidth );
  64. bool PackImages_Rgb_A( char const *pFilename, int nWidth );
  65. float UCoord( int u )
  66. {
  67. float uc = u + 0.5;
  68. return uc / (float) m_nWidth;
  69. }
  70. float VCoord( int v )
  71. {
  72. float vc = v + 0.5;
  73. return vc / (float) m_nHeight;
  74. }
  75. const char *m_pShtFile;
  76. CUtlStringMap<SequenceFrame *> m_ImageList;
  77. int m_ePackingMode;
  78. CUtlVector<Sequence *> m_Sequences;
  79. Sequence *m_pCurSequence;
  80. int m_nWidth;
  81. int m_nHeight;
  82. };
  83. #endif // AMALGAMATEDTEXTURE_H