Changeset 3301

Show
Ignore:
Timestamp:
08/18/04 08:06:02 (10 years ago)
Author:
robert
Message:

Rejigged the int* definitions to try and get round Mingw compile errors

Location:
OpenSceneGraph/trunk/src/osg
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osg/dxtctool.cpp

    r3300 r3301  
    7979{ 
    8080    // 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; 
    8282 
    8383    if (m_Height == 2) 
     
    102102{ 
    103103    // 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; 
    105105 
    106106    if (m_Height == 2) 
    107107        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)); 
    110110        } 
    111111 
    112112    if (m_Height == 4) 
    113113        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)); 
    116116        } 
    117117 
     
    121121                const size_t TargetRow = ((m_Height + 3) / 4) - (i + 1); 
    122122                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); 
    125125            } 
    126126} 
     
    131131{ 
    132132    // 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; 
    134134 
    135135    if (m_Height == 2) 
    136136        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)); 
    139139        } 
    140140 
    141141    if (m_Height == 4) 
    142142        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)); 
    145145        } 
    146146 
     
    150150                const size_t TargetRow = ((m_Height + 3) / 4) - (i + 1); 
    151151                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); 
    154154            } 
    155155} 
  • OpenSceneGraph/trunk/src/osg/dxtctool.h

    r3300 r3301  
    4444#include <osg/Texture> 
    4545 
    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; 
    5265 
    5366    #define HEX_0x000000000000FFFF 0x000000000000FFFFll 
     
    5669    #define HEX_0x000FFF0000000000 0x000FFF0000000000ll 
    5770    #define HEX_0xFFF0000000000000 0xFFF0000000000000ll 
    58  
    59 #else 
    60  
    61     #define HEX_0x000000000000FFFF 0x000000000000FFFF 
    62     #define HEX_0x000000000FFF0000 0x000000000FFF0000 
    63     #define HEX_0x000000FFF0000000 0x000000FFF0000000 
    64     #define HEX_0x000FFF0000000000 0x000FFF0000000000 
    65     #define HEX_0xFFF0000000000000 0xFFF0000000000000 
    6671 
    6772#endif 
     
    170175inline void dxtc_pixels::BVF_Color_H2(void * const pBlock) const { 
    171176    // 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; 
    173178 
    174179    std::swap(pP[0], pP[1]); 
     
    178183inline void dxtc_pixels::BVF_Color_H4(void * const pBlock) const { 
    179184    // 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; 
    181186 
    182187    std::swap(pP[0], pP[3]); 
     
    187192inline void dxtc_pixels::BVF_Color(void * const pBlock1, void * const pBlock2) const { 
    188193    // 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; 
    191196 
    192197    std::swap(* pHdr1, * pHdr2); 
    193198 
    194199    // 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; 
    197202 
    198203    std::swap(pP1[0], pP2[3]); 
     
    205210inline void dxtc_pixels::BVF_Alpha_DXT3_H2(void * const pBlock) const { 
    206211    // Swap the two first row of pixels 
    207     __int16 * const pP = (__int16 * const) pBlock; 
     212    dxtc_int16 * const pP = (dxtc_int16 * const) pBlock; 
    208213 
    209214    std::swap(pP[0], pP[1]); 
     
    213218inline void dxtc_pixels::BVF_Alpha_DXT3_H4(void * const pBlock) const { 
    214219    // 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; 
    216221 
    217222    std::swap(pP[0], pP[3]); 
     
    222227inline void dxtc_pixels::BVF_Alpha_DXT3(void * const pBlock1, void * const pBlock2) const { 
    223228    // 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; 
    226231 
    227232    std::swap(pP1[0], pP2[3]); 
     
    234239inline void dxtc_pixels::BVF_Alpha_DXT5_H2(void * const pBlock) const { 
    235240    // 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); 
    239244    TmpDWord |=    (pP[0] & 0x00000FFF) << 12; 
    240245    TmpDWord |= (pP[0] & 0x00FFF000) >> 12; 
     
    249254inline void dxtc_pixels::BVF_Alpha_DXT5_H4(void * const pBlock) const { 
    250255    // 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); 
    254259    TmpQWord |= (pB[0] & HEX_0x000000000FFF0000) << 36; 
    255260    TmpQWord |= (pB[0] & HEX_0x000000FFF0000000) << 12; 
     
    262267inline void dxtc_pixels::BVF_Alpha_DXT5(void * const pBlock1, void * const pBlock2) const { 
    263268    // 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); 
    268273    TmpQWord1 |= (pB1[0] & HEX_0x000000000FFF0000) << 36; 
    269274    TmpQWord1 |= (pB1[0] & HEX_0x000000FFF0000000) << 12; 
     
    271276    TmpQWord1 |= (pB1[0] & HEX_0xFFF0000000000000) >> 36; 
    272277 
    273     __int64 TmpQWord2 = (pB2[0] & HEX_0x000000000000FFFF); 
     278    dxtc_int64 TmpQWord2 = (pB2[0] & HEX_0x000000000000FFFF); 
    274279    TmpQWord2 |= (pB2[0] & HEX_0x000000000FFF0000) << 36; 
    275280    TmpQWord2 |= (pB2[0] & HEX_0x000000FFF0000000) << 12; 
     
    283288 
    284289inline 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; 
    286291 
    287292    return (void *) (pPixels + i * ((m_Width + 3) / 4) * BlockSize + j * BlockSize);