root/OpenSceneGraph/trunk/src/osgPlugins/flt/flt.cpp @ 189

Revision 189, 1.1 kB (checked in by robert, 12 years ago)

Integrated Brede Johansen's updates to flt loader.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1// flt.cpp
2
3#include "flt.h"
4
5using namespace flt;
6
7////////////////////////////////////////////////////////////////////
8
9int flt::isLittleEndianMachine()
10{
11    int a = 1;
12    return (int)(*(char*)&a);
13}
14
15
16                                 /*nDst*/
17void flt::endian2(void* pSrc, int nSrc, void* pDst, int )
18{
19    if (nSrc == 2)
20    {
21        short tmp1;
22        tmp1 = *(short *)pSrc;
23        tmp1 = (tmp1 << 8) | ((tmp1 >> 8) & 0xff);
24        *(short *)pDst = tmp1;
25    }
26    else if (nSrc == 4)
27    {
28        long tmp1;
29        tmp1 = *(long *)pSrc;
30        tmp1 = (tmp1 << 24) | ((tmp1 << 8) & 0xff0000) | ((tmp1 >> 8) & 0xff00) | ((tmp1 >> 24) & 0xff);
31        *(long *)pDst = tmp1;
32    }
33    else if (nSrc == 8)
34    {
35        long tmp1, tmp2;
36        tmp1 = *(long *)pSrc;
37        tmp2 = *(1 + (long *)pSrc);
38        tmp1 = (tmp1 << 24) | ((tmp1 << 8) & 0xff0000) | ((tmp1 >> 8) & 0xff00) | ((tmp1 >> 24) & 0xff);
39        tmp2 = (tmp2 << 24) | ((tmp2 << 8) & 0xff0000) | ((tmp2 >> 8) & 0xff00) | ((tmp2 >> 24) & 0xff);
40        *(long *)pDst = tmp2;
41        *(1 + (long *)pDst) = tmp1;
42    }
43}
Note: See TracBrowser for help on using the browser.