osgEarth 2.1.1
Static Public Member Functions

anonymous_namespace{ImageUtils.cpp}::ColorReader< GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GLubyte > Struct Template Reference

List of all members.

Static Public Member Functions

static osg::Vec4 read (const ImageUtils::PixelReader *pr, int s, int t, int r, int m)

Detailed Description

template<>
struct anonymous_namespace{ImageUtils.cpp}::ColorReader< GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GLubyte >

Definition at line 822 of file ImageUtils.cpp.


Member Function Documentation

static osg::Vec4 anonymous_namespace{ImageUtils.cpp}::ColorReader< GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GLubyte >::read ( const ImageUtils::PixelReader pr,
int  s,
int  t,
int  r,
int  m 
) [inline, static]

Definition at line 824 of file ImageUtils.cpp.

        {
            static const int BLOCK_BYTES = 8;

            unsigned int blocksPerRow = pr->_image->s()/4;
            unsigned int bs = s/4, bt = t/4;
            unsigned int blockStart = (bt*blocksPerRow+bs) * BLOCK_BYTES;

            const GLushort* p = (const GLushort*)(pr->data() + blockStart);

            GLushort c0p = *p++;
            osg::Vec4f c0(
                (float)(c0p >> 11)/31.0f,
                (float)((c0p & 0x07E0) >> 5)/63.0f,
                (float)((c0p & 0x001F))/31.0f,
                1.0f );

            GLushort c1p = *p++;
            osg::Vec4f c1(
                (float)(c1p >> 11)/31.0f,
                (float)((c1p & 0x07E0) >> 5)/63.0f,
                (float)((c1p & 0x001F))/31.0f,
                1.0f );

            static const float one_third  = 1.0f/3.0f;
            static const float two_thirds = 2.0f/3.0f;

            osg::Vec4f c2, c3;
            if ( c0p > c1p )
            {
                c2 = c0*two_thirds + c1*one_third;
                c3 = c0*one_third  + c1*two_thirds;
            }
            else
            {
                c2 = c0*0.5 + c1*0.5;
                c3.set(0,0,0,1);
            }

            unsigned int table = *(unsigned int*)p;
            int ls = s-4*bs, lt = t-4*bt; //int ls = s % 4, lt = t % 4;
            int x = ls + (4 * lt);

            unsigned int index = (table >> (2*x)) & 0x00000003;

            return index==0? c0 : index==1? c1 : index==2? c2 : c3;
        }

Here is the call graph for this function:


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines