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