DDSHeader.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #ifndef __DDS_HEADER_H__
  2. #define __DDS_HEADER_H__
  3. // little-endian, of course
  4. #define DDS_MAGIC 0x20534444
  5. // DDS_header.dwFlags
  6. #define DDSD_CAPS 0x00000001
  7. #define DDSD_HEIGHT 0x00000002
  8. #define DDSD_WIDTH 0x00000004
  9. #define DDSD_PITCH 0x00000008
  10. #define DDSD_PIXELFORMAT 0x00001000
  11. #define DDSD_MIPMAPCOUNT 0x00020000
  12. #define DDSD_LINEARSIZE 0x00080000
  13. #define DDSD_DEPTH 0x00800000
  14. // DDS_header.sPixelFormat.dwFlags
  15. #define DDPF_ALPHAPIXELS 0x00000001
  16. #define DDPF_FOURCC 0x00000004
  17. #define DDPF_INDEXED 0x00000020
  18. #define DDPF_RGB 0x00000040
  19. // DDS_header.sCaps.dwCaps1
  20. #define DDSCAPS_COMPLEX 0x00000008
  21. #define DDSCAPS_TEXTURE 0x00001000
  22. #define DDSCAPS_MIPMAP 0x00400000
  23. // DDS_header.sCaps.dwCaps2
  24. #define DDSCAPS2_CUBEMAP 0x00000200
  25. #define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400
  26. #define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800
  27. #define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000
  28. #define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000
  29. #define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000
  30. #define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000
  31. #define DDSCAPS2_VOLUME 0x00200000
  32. #define D3DFMT_DXT1 '1TXD' // DXT1 compression texture format
  33. #define D3DFMT_DXT2 '2TXD' // DXT2 compression texture format
  34. #define D3DFMT_DXT3 '3TXD' // DXT3 compression texture format
  35. #define D3DFMT_DXT4 '4TXD' // DXT4 compression texture format
  36. #define D3DFMT_DXT5 '5TXD' // DXT5 compression texture format
  37. #define PF_IS_DXT1(pf) \
  38. ((pf.dwFlags & DDPF_FOURCC) && \
  39. (pf.dwFourCC == D3DFMT_DXT1))
  40. #define PF_IS_DXT3(pf) \
  41. ((pf.dwFlags & DDPF_FOURCC) && \
  42. (pf.dwFourCC == D3DFMT_DXT3))
  43. #define PF_IS_DXT5(pf) \
  44. ((pf.dwFlags & DDPF_FOURCC) && \
  45. (pf.dwFourCC == D3DFMT_DXT5))
  46. #define PF_IS_BGRA8(pf) \
  47. ((pf.dwFlags & DDPF_RGB) && \
  48. (pf.dwFlags & DDPF_ALPHAPIXELS) && \
  49. (pf.dwRGBBitCount == 32) && \
  50. (pf.dwRBitMask == 0xff0000) && \
  51. (pf.dwGBitMask == 0xff00) && \
  52. (pf.dwBBitMask == 0xff) && \
  53. (pf.dwAlphaBitMask == 0xff000000U))
  54. #define PF_IS_BGR8(pf) \
  55. ((pf.dwFlags & DDPF_ALPHAPIXELS) && \
  56. !(pf.dwFlags & DDPF_ALPHAPIXELS) && \
  57. (pf.dwRGBBitCount == 24) && \
  58. (pf.dwRBitMask == 0xff0000) && \
  59. (pf.dwGBitMask == 0xff00) && \
  60. (pf.dwBBitMask == 0xff))
  61. #define PF_IS_BGR5A1(pf) \
  62. ((pf.dwFlags & DDPF_RGB) && \
  63. (pf.dwFlags & DDPF_ALPHAPIXELS) && \
  64. (pf.dwRGBBitCount == 16) && \
  65. (pf.dwRBitMask == 0x00007c00) && \
  66. (pf.dwGBitMask == 0x000003e0) && \
  67. (pf.dwBBitMask == 0x0000001f) && \
  68. (pf.dwAlphaBitMask == 0x00008000))
  69. #define PF_IS_BGR565(pf) \
  70. ((pf.dwFlags & DDPF_RGB) && \
  71. !(pf.dwFlags & DDPF_ALPHAPIXELS) && \
  72. (pf.dwRGBBitCount == 16) && \
  73. (pf.dwRBitMask == 0x0000f800) && \
  74. (pf.dwGBitMask == 0x000007e0) && \
  75. (pf.dwBBitMask == 0x0000001f))
  76. #define PF_IS_INDEX8(pf) \
  77. ((pf.dwFlags & DDPF_INDEXED) && \
  78. (pf.dwRGBBitCount == 8))
  79. union DDS_header
  80. {
  81. struct
  82. {
  83. unsigned int dwMagic;
  84. unsigned int dwSize;
  85. unsigned int dwFlags;
  86. unsigned int dwHeight;
  87. unsigned int dwWidth;
  88. unsigned int dwPitchOrLinearSize;
  89. unsigned int dwDepth;
  90. unsigned int dwMipMapCount;
  91. unsigned int dwReserved1[ 11 ];
  92. // DDPIXELFORMAT
  93. struct
  94. {
  95. unsigned int dwSize;
  96. unsigned int dwFlags;
  97. unsigned int dwFourCC;
  98. unsigned int dwRGBBitCount;
  99. unsigned int dwRBitMask;
  100. unsigned int dwGBitMask;
  101. unsigned int dwBBitMask;
  102. unsigned int dwAlphaBitMask;
  103. } sPixelFormat;
  104. // DDCAPS2
  105. struct
  106. {
  107. unsigned int dwCaps1;
  108. unsigned int dwCaps2;
  109. unsigned int dwDDSX;
  110. unsigned int dwReserved;
  111. } sCaps;
  112. unsigned int dwReserved2;
  113. };
  114. char data[ 128 ];
  115. };
  116. #endif // mydds_h
粤ICP备19079148号