ImageOpts.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __IMAGEOPTS_H__
  21. #define __IMAGEOPTS_H__
  22. enum textureType_t {
  23. TT_DISABLED,
  24. TT_2D,
  25. TT_CUBIC
  26. };
  27. /*
  28. ================================================
  29. The internal *Texture Format Types*, ::textureFormat_t, are:
  30. ================================================
  31. */
  32. enum textureFormat_t {
  33. FMT_NONE,
  34. //------------------------
  35. // Standard color image formats
  36. //------------------------
  37. FMT_RGBA8, // 32 bpp
  38. FMT_XRGB8, // 32 bpp
  39. //------------------------
  40. // Alpha channel only
  41. //------------------------
  42. // Alpha ends up being the same as L8A8 in our current implementation, because straight
  43. // alpha gives 0 for color, but we want 1.
  44. FMT_ALPHA,
  45. //------------------------
  46. // Luminance replicates the value across RGB with a constant A of 255
  47. // Intensity replicates the value across RGBA
  48. //------------------------
  49. FMT_L8A8, // 16 bpp
  50. FMT_LUM8, // 8 bpp
  51. FMT_INT8, // 8 bpp
  52. //------------------------
  53. // Compressed texture formats
  54. //------------------------
  55. FMT_DXT1, // 4 bpp
  56. FMT_DXT5, // 8 bpp
  57. //------------------------
  58. // Depth buffer formats
  59. //------------------------
  60. FMT_DEPTH, // 24 bpp
  61. //------------------------
  62. //
  63. //------------------------
  64. FMT_X16, // 16 bpp
  65. FMT_Y16_X16, // 32 bpp
  66. FMT_RGB565, // 16 bpp
  67. };
  68. int BitsForFormat( textureFormat_t format );
  69. /*
  70. ================================================
  71. DXT5 color formats
  72. ================================================
  73. */
  74. enum textureColor_t {
  75. CFM_DEFAULT, // RGBA
  76. CFM_NORMAL_DXT5, // XY format and use the fast DXT5 compressor
  77. CFM_YCOCG_DXT5, // convert RGBA to CoCg_Y format
  78. CFM_GREEN_ALPHA // Copy the alpha channel to green
  79. };
  80. /*
  81. ================================================
  82. idImageOpts hold parameters for texture operations.
  83. ================================================
  84. */
  85. class idImageOpts {
  86. public:
  87. idImageOpts();
  88. bool operator==( const idImageOpts & opts );
  89. //---------------------------------------------------
  90. // these determine the physical memory size and layout
  91. //---------------------------------------------------
  92. textureType_t textureType;
  93. textureFormat_t format;
  94. textureColor_t colorFormat;
  95. int width;
  96. int height; // not needed for cube maps
  97. int numLevels; // if 0, will be 1 for NEAREST / LINEAR filters, otherwise based on size
  98. bool gammaMips; // if true, mips will be generated with gamma correction
  99. bool readback; // 360 specific - cpu reads back from this texture, so allocate with cached memory
  100. };
  101. /*
  102. ========================
  103. idImageOpts::idImageOpts
  104. ========================
  105. */
  106. ID_INLINE idImageOpts::idImageOpts() {
  107. format = FMT_NONE;
  108. colorFormat = CFM_DEFAULT;
  109. width = 0;
  110. height = 0;
  111. numLevels = 0;
  112. textureType = TT_2D;
  113. gammaMips = false;
  114. readback = false;
  115. };
  116. /*
  117. ========================
  118. idImageOpts::operator==
  119. ========================
  120. */
  121. ID_INLINE bool idImageOpts::operator==( const idImageOpts & opts ) {
  122. return ( memcmp( this, &opts, sizeof( *this ) ) == 0 );
  123. }
  124. #endif