Changeset 3301
- Timestamp:
- 08/18/04 08:06:02 (9 years ago)
- Location:
- OpenSceneGraph/trunk/src/osg
- Files:
-
- 2 modified
-
dxtctool.cpp (modified) (5 diffs)
-
dxtctool.h (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/dxtctool.cpp
r3300 r3301 79 79 { 80 80 // const size_t Size = ((m_Width + 3) / 4) * ((m_Height + 3) / 4) * BSIZE_DXT1; 81 __int8 * const pPixels = (__int8 * const) m_pPixels;81 dxtc_int8 * const pPixels = (dxtc_int8 * const) m_pPixels; 82 82 83 83 if (m_Height == 2) … … 102 102 { 103 103 // const size_t Size = ((m_Width + 3) / 4) * ((m_Height + 3) / 4) * BSIZE_DXT3; 104 // __int8 * const pPixels = (__int8 * const) m_pPixels;104 // dxtc_int8 * const pPixels = (dxtc_int8 * const) m_pPixels; 105 105 106 106 if (m_Height == 2) 107 107 for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 108 BVF_Alpha_DXT3_H2((( __int8 * const) m_pPixels) + (j * BSIZE_DXT3));109 BVF_Color_H2((( __int8 * const) m_pPixels) + (j * BSIZE_DXT3 + BSIZE_ALPHA_DXT3));108 BVF_Alpha_DXT3_H2(((dxtc_int8 * const) m_pPixels) + (j * BSIZE_DXT3)); 109 BVF_Color_H2(((dxtc_int8 * const) m_pPixels) + (j * BSIZE_DXT3 + BSIZE_ALPHA_DXT3)); 110 110 } 111 111 112 112 if (m_Height == 4) 113 113 for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 114 BVF_Alpha_DXT3_H4((( __int8 * const) m_pPixels) + (j * BSIZE_DXT3));115 BVF_Color_H4((( __int8 * const) m_pPixels) + (j * BSIZE_DXT3 + BSIZE_ALPHA_DXT3));114 BVF_Alpha_DXT3_H4(((dxtc_int8 * const) m_pPixels) + (j * BSIZE_DXT3)); 115 BVF_Color_H4(((dxtc_int8 * const) m_pPixels) + (j * BSIZE_DXT3 + BSIZE_ALPHA_DXT3)); 116 116 } 117 117 … … 121 121 const size_t TargetRow = ((m_Height + 3) / 4) - (i + 1); 122 122 BVF_Alpha_DXT3(GetBlock(i, j, BSIZE_DXT3), GetBlock(TargetRow, j, BSIZE_DXT3)); 123 BVF_Color((( __int8 * const) GetBlock(i, j, BSIZE_DXT3)) + BSIZE_ALPHA_DXT3,124 (( __int8 * const) GetBlock(TargetRow, j, BSIZE_DXT3)) + BSIZE_ALPHA_DXT3);123 BVF_Color(((dxtc_int8 * const) GetBlock(i, j, BSIZE_DXT3)) + BSIZE_ALPHA_DXT3, 124 ((dxtc_int8 * const) GetBlock(TargetRow, j, BSIZE_DXT3)) + BSIZE_ALPHA_DXT3); 125 125 } 126 126 } … … 131 131 { 132 132 // const size_t Size = ((m_Width + 3) / 4) * ((m_Height + 3) / 4) * BSIZE_DXT5; 133 // __int8 * const pPixels = (__int8 * const) m_pPixels;133 // dxtc_int8 * const pPixels = (dxtc_int8 * const) m_pPixels; 134 134 135 135 if (m_Height == 2) 136 136 for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 137 BVF_Alpha_DXT5_H2((( __int8 * const) m_pPixels) + (j * BSIZE_DXT5));138 BVF_Color_H2((( __int8 * const) m_pPixels) + (j * BSIZE_DXT5 + BSIZE_ALPHA_DXT5));137 BVF_Alpha_DXT5_H2(((dxtc_int8 * const) m_pPixels) + (j * BSIZE_DXT5)); 138 BVF_Color_H2(((dxtc_int8 * const) m_pPixels) + (j * BSIZE_DXT5 + BSIZE_ALPHA_DXT5)); 139 139 } 140 140 141 141 if (m_Height == 4) 142 142 for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 143 BVF_Alpha_DXT5_H4((( __int8 * const) m_pPixels) + (j * BSIZE_DXT5));144 BVF_Color_H4((( __int8 * const) m_pPixels) + (j * BSIZE_DXT5 + BSIZE_ALPHA_DXT5));143 BVF_Alpha_DXT5_H4(((dxtc_int8 * const) m_pPixels) + (j * BSIZE_DXT5)); 144 BVF_Color_H4(((dxtc_int8 * const) m_pPixels) + (j * BSIZE_DXT5 + BSIZE_ALPHA_DXT5)); 145 145 } 146 146 … … 150 150 const size_t TargetRow = ((m_Height + 3) / 4) - (i + 1); 151 151 BVF_Alpha_DXT5(GetBlock(i, j, BSIZE_DXT5), GetBlock(TargetRow, j, BSIZE_DXT5)); 152 BVF_Color((( __int8 * const) GetBlock(i, j, BSIZE_DXT5)) + BSIZE_ALPHA_DXT5,153 (( __int8 * const) GetBlock(TargetRow, j, BSIZE_DXT5)) + BSIZE_ALPHA_DXT5);152 BVF_Color(((dxtc_int8 * const) GetBlock(i, j, BSIZE_DXT5)) + BSIZE_ALPHA_DXT5, 153 ((dxtc_int8 * const) GetBlock(TargetRow, j, BSIZE_DXT5)) + BSIZE_ALPHA_DXT5); 154 154 } 155 155 } -
OpenSceneGraph/trunk/src/osg/dxtctool.h
r3300 r3301 44 44 #include <osg/Texture> 45 45 46 #if !defined(_MSC_VER) 47 48 typedef char __int8; 49 typedef short __int16; 50 typedef int __int32; 51 typedef long long __int64; 46 #if defined(_MSC_VER) 47 48 typedef __int8 dxtc_int8; 49 typedef __int16 dxtc_int16; 50 typedef __int32 dxtc_int32; 51 typedef __int64 dxtc_int64; 52 53 #define HEX_0x000000000000FFFF 0x000000000000FFFF 54 #define HEX_0x000000000FFF0000 0x000000000FFF0000 55 #define HEX_0x000000FFF0000000 0x000000FFF0000000 56 #define HEX_0x000FFF0000000000 0x000FFF0000000000 57 #define HEX_0xFFF0000000000000 0xFFF0000000000000 58 59 #else 60 61 typedef char dxtc_int8; 62 typedef short dxtc_int16; 63 typedef int dxtc_int32; 64 typedef long long dxtc_int64; 52 65 53 66 #define HEX_0x000000000000FFFF 0x000000000000FFFFll … … 56 69 #define HEX_0x000FFF0000000000 0x000FFF0000000000ll 57 70 #define HEX_0xFFF0000000000000 0xFFF0000000000000ll 58 59 #else60 61 #define HEX_0x000000000000FFFF 0x000000000000FFFF62 #define HEX_0x000000000FFF0000 0x000000000FFF000063 #define HEX_0x000000FFF0000000 0x000000FFF000000064 #define HEX_0x000FFF0000000000 0x000FFF000000000065 #define HEX_0xFFF0000000000000 0xFFF000000000000066 71 67 72 #endif … … 170 175 inline void dxtc_pixels::BVF_Color_H2(void * const pBlock) const { 171 176 // Swap the two first row of pixels 172 __int8 * const pP = ((__int8 * const) pBlock) + 4;177 dxtc_int8 * const pP = ((dxtc_int8 * const) pBlock) + 4; 173 178 174 179 std::swap(pP[0], pP[1]); … … 178 183 inline void dxtc_pixels::BVF_Color_H4(void * const pBlock) const { 179 184 // Swap the the first row of pixels with the last one, then the 2 middle row of pixels 180 __int8 * const pP = ((__int8 * const) pBlock) + 4;185 dxtc_int8 * const pP = ((dxtc_int8 * const) pBlock) + 4; 181 186 182 187 std::swap(pP[0], pP[3]); … … 187 192 inline void dxtc_pixels::BVF_Color(void * const pBlock1, void * const pBlock2) const { 188 193 // Swap the "2 colors" header (32bits each header) 189 __int32 * const pHdr1 = (__int32 * const) pBlock1;190 __int32 * const pHdr2 = (__int32 * const) pBlock2;194 dxtc_int32 * const pHdr1 = (dxtc_int32 * const) pBlock1; 195 dxtc_int32 * const pHdr2 = (dxtc_int32 * const) pBlock2; 191 196 192 197 std::swap(* pHdr1, * pHdr2); 193 198 194 199 // Now swap the pixel values 195 __int8 * const pP1 = ((__int8 * const) pBlock1) + 4;196 __int8 * const pP2 = ((__int8 * const) pBlock2) + 4;200 dxtc_int8 * const pP1 = ((dxtc_int8 * const) pBlock1) + 4; 201 dxtc_int8 * const pP2 = ((dxtc_int8 * const) pBlock2) + 4; 197 202 198 203 std::swap(pP1[0], pP2[3]); … … 205 210 inline void dxtc_pixels::BVF_Alpha_DXT3_H2(void * const pBlock) const { 206 211 // Swap the two first row of pixels 207 __int16 * const pP = (__int16 * const) pBlock;212 dxtc_int16 * const pP = (dxtc_int16 * const) pBlock; 208 213 209 214 std::swap(pP[0], pP[1]); … … 213 218 inline void dxtc_pixels::BVF_Alpha_DXT3_H4(void * const pBlock) const { 214 219 // Swap the the first row of pixels with the last one, then the 2 middle row of pixels 215 __int16 * const pP = (__int16 * const) pBlock;220 dxtc_int16 * const pP = (dxtc_int16 * const) pBlock; 216 221 217 222 std::swap(pP[0], pP[3]); … … 222 227 inline void dxtc_pixels::BVF_Alpha_DXT3(void * const pBlock1, void * const pBlock2) const { 223 228 // Swap all the pixel values 224 __int16 * const pP1 = (__int16 * const) pBlock1;225 __int16 * const pP2 = (__int16 * const) pBlock2;229 dxtc_int16 * const pP1 = (dxtc_int16 * const) pBlock1; 230 dxtc_int16 * const pP2 = (dxtc_int16 * const) pBlock2; 226 231 227 232 std::swap(pP1[0], pP2[3]); … … 234 239 inline void dxtc_pixels::BVF_Alpha_DXT5_H2(void * const pBlock) const { 235 240 // Swap the two first row of pixels (kinda tricky with DXT5 unaligned encoding) 236 __int32 * const pP = (__int32 * const) (((__int8 * const) pBlock) + 2);237 238 __int32 TmpDWord = (pP[0] & 0xFF000000);241 dxtc_int32 * const pP = (dxtc_int32 * const) (((dxtc_int8 * const) pBlock) + 2); 242 243 dxtc_int32 TmpDWord = (pP[0] & 0xFF000000); 239 244 TmpDWord |= (pP[0] & 0x00000FFF) << 12; 240 245 TmpDWord |= (pP[0] & 0x00FFF000) >> 12; … … 249 254 inline void dxtc_pixels::BVF_Alpha_DXT5_H4(void * const pBlock) const { 250 255 // Swap the the first row of pixels with the last one, then the 2 middle row of pixels (tricky again) 251 __int64 * const pB = (__int64 * const) pBlock;252 253 __int64 TmpQWord = (pB[0] & HEX_0x000000000000FFFF);256 dxtc_int64 * const pB = (dxtc_int64 * const) pBlock; 257 258 dxtc_int64 TmpQWord = (pB[0] & HEX_0x000000000000FFFF); 254 259 TmpQWord |= (pB[0] & HEX_0x000000000FFF0000) << 36; 255 260 TmpQWord |= (pB[0] & HEX_0x000000FFF0000000) << 12; … … 262 267 inline void dxtc_pixels::BVF_Alpha_DXT5(void * const pBlock1, void * const pBlock2) const { 263 268 // Swap all the pixel values (same trick for DXT5) 264 __int64 * const pB1 = (__int64 * const) pBlock1;265 __int64 * const pB2 = (__int64 * const) pBlock2;266 267 __int64 TmpQWord1 = (pB1[0] & HEX_0x000000000000FFFF);269 dxtc_int64 * const pB1 = (dxtc_int64 * const) pBlock1; 270 dxtc_int64 * const pB2 = (dxtc_int64 * const) pBlock2; 271 272 dxtc_int64 TmpQWord1 = (pB1[0] & HEX_0x000000000000FFFF); 268 273 TmpQWord1 |= (pB1[0] & HEX_0x000000000FFF0000) << 36; 269 274 TmpQWord1 |= (pB1[0] & HEX_0x000000FFF0000000) << 12; … … 271 276 TmpQWord1 |= (pB1[0] & HEX_0xFFF0000000000000) >> 36; 272 277 273 __int64 TmpQWord2 = (pB2[0] & HEX_0x000000000000FFFF);278 dxtc_int64 TmpQWord2 = (pB2[0] & HEX_0x000000000000FFFF); 274 279 TmpQWord2 |= (pB2[0] & HEX_0x000000000FFF0000) << 36; 275 280 TmpQWord2 |= (pB2[0] & HEX_0x000000FFF0000000) << 12; … … 283 288 284 289 inline void * dxtc_pixels::GetBlock(size_t i, size_t j, size_t BlockSize) const { 285 const __int8 * pPixels = (const __int8 *) m_pPixels;290 const dxtc_int8 * pPixels = (const dxtc_int8 *) m_pPixels; 286 291 287 292 return (void *) (pPixels + i * ((m_Width + 3) / 4) * BlockSize + j * BlockSize);
