Changeset 11173

Show
Ignore:
Timestamp:
03/05/10 17:04:30 (4 years ago)
Author:
robert
Message:

Fixed usage of osg::swapBytes to properly pass in pointer to data that needs swapping.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/3ds/lib3ds/lib3ds_io.c

    r10853 r11173  
    172172    w = ((uint16_t)b[1] << 8) | 
    173173        ((uint16_t)b[0]); 
    174         /* --- Code for OpenSceneGraph --- */ 
    175     if (s_requiresByteSwap) 
    176     { 
    177         osg::swapBytes2((char*)w); 
    178     } 
    179         /* --- (end) Code for OpenSceneGraph --- */ 
    180         return(w); 
     174    /* --- Code for OpenSceneGraph --- */ 
     175    if (s_requiresByteSwap) 
     176    { 
     177        osg::swapBytes2((char*)&w); 
     178    } 
     179    /* --- (end) Code for OpenSceneGraph --- */ 
     180    return(w); 
    181181} 
    182182 
     
    196196        ((uint32_t)b[1] << 8) | 
    197197        ((uint32_t)b[0]); 
    198         /* --- Code for OpenSceneGraph --- */ 
    199     if (s_requiresByteSwap) 
    200     { 
    201         osg::swapBytes4((char*)d); 
    202     } 
    203         /* --- (end) Code for OpenSceneGraph --- */ 
     198    /* --- Code for OpenSceneGraph --- */ 
     199    if (s_requiresByteSwap) 
     200    { 
     201        osg::swapBytes4((char*)&d); 
     202    } 
     203    /* --- (end) Code for OpenSceneGraph --- */ 
    204204    return(d); 
    205205} 
     
    231231    w = ((uint16_t)b[1] << 8) | 
    232232        ((uint16_t)b[0]); 
    233         /* --- Code for OpenSceneGraph --- */ 
    234     if (s_requiresByteSwap) 
    235     { 
    236         osg::swapBytes2((char*)w); 
    237     } 
    238         /* --- (end) Code for OpenSceneGraph --- */ 
    239         return((int16_t)w); 
     233    /* --- Code for OpenSceneGraph --- */ 
     234    if (s_requiresByteSwap) 
     235    { 
     236        osg::swapBytes2((char*)&w); 
     237    } 
     238    /* --- (end) Code for OpenSceneGraph --- */ 
     239    return((int16_t)w); 
    240240} 
    241241 
     
    255255        ((uint32_t)b[1] << 8) | 
    256256        ((uint32_t)b[0]); 
    257         /* --- Code for OpenSceneGraph --- */ 
    258     if (s_requiresByteSwap) 
    259     { 
    260         osg::swapBytes4((char*)d); 
    261     } 
    262         /* --- (end) Code for OpenSceneGraph --- */ 
     257    /* --- Code for OpenSceneGraph --- */ 
     258    if (s_requiresByteSwap) 
     259    { 
     260        osg::swapBytes4((char*)&d); 
     261    } 
     262    /* --- (end) Code for OpenSceneGraph --- */ 
    263263    return((int32_t)d); 
    264264} 
     
    279279                    ((uint32_t)b[1] << 8) | 
    280280                    ((uint32_t)b[0]); 
    281         /* --- Code for OpenSceneGraph --- */ 
    282     if (s_requiresByteSwap) 
    283     { 
    284                 osg::swapBytes4((char*)d.dword_value); 
    285     } 
    286         /* --- (end) Code for OpenSceneGraph --- */ 
    287         return d.float_value; 
     281    /* --- Code for OpenSceneGraph --- */ 
     282    if (s_requiresByteSwap) 
     283    { 
     284        osg::swapBytes4((char*)&(d.dword_value)); 
     285    } 
     286    /* --- (end) Code for OpenSceneGraph --- */ 
     287    return d.float_value; 
    288288} 
    289289 
     
    361361void 
    362362lib3ds_io_write_word(Lib3dsIo *io, uint16_t w) { 
    363         /* --- Code for OpenSceneGraph --- */ 
    364     if (s_requiresByteSwap) 
    365     { 
    366                 osg::swapBytes2((char*)w); 
    367     } 
    368         /* --- (end) Code for OpenSceneGraph --- */ 
    369  
    370         uint8_t b[2]; 
     363    /* --- Code for OpenSceneGraph --- */ 
     364    if (s_requiresByteSwap) 
     365    { 
     366            osg::swapBytes2((char*)&w); 
     367    } 
     368    /* --- (end) Code for OpenSceneGraph --- */ 
     369 
     370    uint8_t b[2]; 
    371371 
    372372    assert(io); 
     
    384384void 
    385385lib3ds_io_write_dword(Lib3dsIo *io, uint32_t d) { 
    386         /* --- Code for OpenSceneGraph --- */ 
    387     if (s_requiresByteSwap) 
    388     { 
    389         osg::swapBytes4((char*)d); 
    390     } 
    391         /* --- (end) Code for OpenSceneGraph --- */ 
     386    /* --- Code for OpenSceneGraph --- */ 
     387    if (s_requiresByteSwap) 
     388    { 
     389        osg::swapBytes4((char*)&d); 
     390    } 
     391    /* --- (end) Code for OpenSceneGraph --- */ 
    392392    uint8_t b[4]; 
    393393 
     
    420420void 
    421421lib3ds_io_write_intw(Lib3dsIo *io, int16_t w) { 
    422         /* --- Code for OpenSceneGraph --- */ 
    423     if (s_requiresByteSwap) 
    424     { 
    425         osg::swapBytes2((char*)w); 
    426     } 
    427         /* --- (end) Code for OpenSceneGraph --- */ 
     422    /* --- Code for OpenSceneGraph --- */ 
     423    if (s_requiresByteSwap) 
     424    { 
     425        osg::swapBytes2((char*)&w); 
     426    } 
     427    /* --- (end) Code for OpenSceneGraph --- */ 
    428428    uint8_t b[2]; 
    429429 
     
    442442void 
    443443lib3ds_io_write_intd(Lib3dsIo *io, int32_t d) { 
    444         /* --- Code for OpenSceneGraph --- */ 
    445     if (s_requiresByteSwap) 
    446     { 
    447         osg::swapBytes4((char*)d); 
    448     } 
    449         /* --- (end) Code for OpenSceneGraph --- */ 
     444    /* --- Code for OpenSceneGraph --- */ 
     445    if (s_requiresByteSwap) 
     446    { 
     447        osg::swapBytes4((char*)&d); 
     448    } 
     449    /* --- (end) Code for OpenSceneGraph --- */ 
    450450    uint8_t b[4]; 
    451451 
     
    471471    assert(io); 
    472472    d.float_value = l; 
    473         /* --- Code for OpenSceneGraph --- */ 
    474     if (s_requiresByteSwap) 
    475     { 
    476                 osg::swapBytes4((char*)d.dword_value); 
    477     } 
    478         /* --- (end) Code for OpenSceneGraph --- */ 
     473    /* --- Code for OpenSceneGraph --- */ 
     474    if (s_requiresByteSwap) 
     475    { 
     476        osg::swapBytes4((char*)&d.dword_value); 
     477    } 
     478    /* --- (end) Code for OpenSceneGraph --- */ 
    479479    b[3] = (uint8_t)(((uint32_t)d.dword_value & 0xFF000000) >> 24); 
    480480    b[2] = (uint8_t)(((uint32_t)d.dword_value & 0x00FF0000) >> 16);