CDDSImage Class Reference

List of all members.

Public Member Functions

 CDDSImage ()
 ~CDDSImage ()
bool load (std::istream &is, bool flipImage=true, bool swapCubeMap=true, bool flipCubeMap=false)
void clear ()
 operator char * ()
CTextureoperator[] (Int32 index)
Int32 get_num_images (void)
CTextureget_image (Int32 index)
Int32 get_components ()
Int32 get_format ()
bool is_compressed ()
bool is_cubemap ()
bool is_volume ()
bool is_valid ()

Private Member Functions

Int32 clamp_size (Int32 size)
Int32 get_line_width (Int32 width, Int32 bpp)
Int32 size_dxtc (Int32 width, Int32 height)
Int32 size_rgb (Int32 width, Int32 height)
void swap_endian (void *val)
void align_memory (CTexture *surface)
void flip (char *image, Int32 width, Int32 height, Int32 depth, Int32 size)
bool check_dxt1_alpha_data (char *image, Int32 size)
void swap (void *byte1, void *byte2, Int32 size)
void flip_blocks_dxtc1 (DXTColBlock *line, Int32 numBlocks)
void flip_blocks_dxtc3 (DXTColBlock *line, Int32 numBlocks)
void flip_blocks_dxtc5 (DXTColBlock *line, Int32 numBlocks)
void flip_dxt5_alpha (DXT5AlphaBlock *block)

Private Attributes

Int32 format
Int32 components
bool compressed
bool cubemap
bool volume
bool valid
std::vector< CTextureimages

Detailed Description

Definition at line 226 of file OSGDDSImageFileType.cpp.


Constructor & Destructor Documentation

CDDSImage::CDDSImage (  ) 

Definition at line 518 of file OSGDDSImageFileType.cpp.

00518                      : 
00519     format(0),
00520     components(0),
00521     compressed(false),
00522     cubemap(false),
00523     volume(false),
00524     valid(false)
00525 {
00526 }

CDDSImage::~CDDSImage (  ) 

Definition at line 528 of file OSGDDSImageFileType.cpp.

00529 {
00530 }


Member Function Documentation

bool CDDSImage::load ( std::istream &  is,
bool  flipImage = true,
bool  swapCubeMap = true,
bool  flipCubeMap = false 
)

Definition at line 563 of file OSGDDSImageFileType.cpp.

References align_memory(), check_dxt1_alpha_data(), clamp_size(), clear(), components, compressed, cubemap, OSG::endLog(), flip(), format, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, images, CSurface::size, size, size_dxtc(), size_rgb(), swap_endian(), SWARNING, valid, volume, and CSurface::width.

Referenced by OSG::DDSImageFileType::read().

00567 {
00568     DDS_HEADER ddsh;
00569     char filecode[4];
00570     Int32 width, height, depth;
00571     Int32 (CDDSImage::*sizefunc)(Int32, Int32);
00572 
00573     // clear any previously loaded images
00574     clear();
00575     
00576     // read in file marker, make sure its a DDS file
00577     is.read(filecode, 4);
00578     if (strncmp(filecode, "DDS ", 4) != 0)
00579         return false;
00580 
00581     // read in DDS header
00582     is.read(reinterpret_cast<char*>(&ddsh), sizeof(ddsh));
00583 
00584     swap_endian(&ddsh.dwSize);
00585     swap_endian(&ddsh.dwFlags);
00586     swap_endian(&ddsh.dwHeight);
00587     swap_endian(&ddsh.dwWidth);
00588     swap_endian(&ddsh.dwPitchOrLinearSize);
00589     swap_endian(&ddsh.dwDepth);
00590     swap_endian(&ddsh.dwMipMapCount);
00591     swap_endian(&ddsh.ddspf.dwSize);
00592     swap_endian(&ddsh.ddspf.dwFlags);
00593     swap_endian(&ddsh.ddspf.dwFourCC);
00594     swap_endian(&ddsh.ddspf.dwRGBBitCount);
00595     swap_endian(&ddsh.dwCaps1);
00596     swap_endian(&ddsh.dwCaps2);
00597 
00598     // check if image is a cubempa
00599     if (ddsh.dwCaps2 & DDS_CUBEMAP)
00600         cubemap = true;
00601 
00602     // check if image is a volume texture
00603     if ((ddsh.dwCaps2 & DDS_VOLUME) && (ddsh.dwDepth > 0))
00604         volume = true;
00605 
00606     // figure out what the image format is
00607     if (ddsh.ddspf.dwFlags & DDS_FOURCC) 
00608     {
00609         switch(ddsh.ddspf.dwFourCC)
00610         {
00611             case FOURCC_DXT1:
00612                 format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
00613                 components = 3;
00614                 compressed = true;
00615                 break;
00616             case FOURCC_DXT3:
00617                 format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
00618                 components = 4;
00619                 compressed = true;
00620                 break;
00621             case FOURCC_DXT5:
00622                 format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
00623                 components = 4;
00624                 compressed = true;
00625                 break;
00626             default:
00627                 SWARNING << "ERROR: unknown compressed format(" 
00628                          << ddsh.ddspf.dwFourCC
00629                          << ")!" 
00630                          << endLog;
00631                 return false;
00632         }
00633     }
00634     else if (ddsh.ddspf.dwFlags == DDS_RGBA && ddsh.ddspf.dwRGBBitCount == 32)
00635     {
00636         format = Image::OSG_BGRA_PF; 
00637         compressed = false;
00638         components = 4;
00639     }
00640     else if (ddsh.ddspf.dwFlags == DDS_RGB  && ddsh.ddspf.dwRGBBitCount == 32)
00641     {
00642         format = Image::OSG_BGRA_PF; 
00643         compressed = false;
00644         components = 4;
00645     }
00646     else if (ddsh.ddspf.dwFlags == DDS_RGB  && ddsh.ddspf.dwRGBBitCount == 24)
00647     {
00648         format = Image::OSG_BGR_PF; 
00649         compressed = false;
00650         components = 3;
00651     }
00652     else if (/*ddsh.ddspf.dwFlags == 0x20000  &&*/ ddsh.ddspf.dwRGBBitCount == 8)
00653     {
00654         format = Image::OSG_L_PF; 
00655         compressed = false;
00656         components = 1;
00657     }
00658     else 
00659     {
00660         SWARNING << "ERROR: unknown image format!" << endLog;
00661         return false;
00662     }
00663     
00664     // store primary surface width/height/depth
00665     width = ddsh.dwWidth;
00666     height = ddsh.dwHeight;
00667     depth = clamp_size(ddsh.dwDepth);   // set to 1 if 0
00668     
00669     // use correct size calculation function depending on whether image is 
00670     // compressed
00671     sizefunc = (compressed ? &CDDSImage::size_dxtc : &CDDSImage::size_rgb);
00672 
00673     // load all surfaces for the image (6 surfaces for cubemaps)
00674     for(Int32 n = 0; n < (cubemap ? 6 : 1); n++)
00675     {
00676         Int32 size; 
00677 
00678         // calculate surface size
00679         size = (this->*sizefunc)(width, height)*depth;
00680 
00681         // load surface
00682         CTexture img(width, height, depth, size);
00683         is.read(img, img.size);
00684 
00685         align_memory(&img);
00686         
00687         if((format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) &&
00688            check_dxt1_alpha_data(img, img.size))
00689         {
00690             format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
00691         }
00692 
00693         if ((flipImage && !cubemap) || (flipCubeMap && cubemap))
00694             flip(img, img.width, img.height, img.depth, img.size);
00695         
00696         Int32 w = clamp_size(width >> 1);
00697         Int32 h = clamp_size(height >> 1);
00698         Int32 d = clamp_size(depth >> 1); 
00699 
00700         // store number of mipmaps
00701         Int32 numMipmaps = ddsh.dwMipMapCount;
00702 
00703         // number of mipmaps in file includes main surface so decrease count 
00704         // by one
00705         if (numMipmaps != 0)
00706             numMipmaps--;
00707 
00708         // load all mipmaps for current surface
00709         for (Int32 i = 0; i < numMipmaps && (w || h); i++)
00710         {
00711             // calculate mipmap size
00712             size = (this->*sizefunc)(w, h)*d;
00713 
00714             CSurface mipmap(w, h, d, size);
00715             is.read(mipmap, mipmap.size);
00716 
00717             if ((flipImage && !cubemap) || (flipCubeMap && cubemap))
00718             {
00719                 flip(mipmap, mipmap.width, mipmap.height, mipmap.depth, 
00720                      mipmap.size);
00721             }
00722 
00723             img.mipmaps.push_back(mipmap);
00724 
00725             // shrink to next power of 2
00726             w = clamp_size(w >> 1);
00727             h = clamp_size(h >> 1);
00728             d = clamp_size(d >> 1); 
00729         }
00730 
00731         images.push_back(img);
00732     }
00733 
00734     // swap cubemaps on y axis (since image is flipped in OGL)
00735     if (cubemap && swapCubeMap)
00736     {
00737         CTexture tmp;
00738         tmp = images[3];
00739         images[3] = images[2];
00740         images[2] = tmp;
00741     }
00742 
00743     valid = true;
00744 
00745     return true;
00746 }

void CDDSImage::clear (  ) 

Definition at line 751 of file OSGDDSImageFileType.cpp.

References components, compressed, cubemap, format, images, valid, and volume.

Referenced by load().

00752 {
00753     components = 0;
00754     format = 0;
00755     compressed = false;
00756     cubemap = false;
00757     volume = false;
00758     valid = false;
00759 
00760     images.clear();
00761 }

CDDSImage::operator char * (  ) 

Definition at line 778 of file OSGDDSImageFileType.cpp.

References images, and valid.

00779 { 
00780     assert(valid);
00781 
00782     return images[0]; 
00783 }

CTexture & CDDSImage::operator[] ( Int32  index  ) 

Definition at line 767 of file OSGDDSImageFileType.cpp.

References images, and valid.

00768 { 
00769     // make sure an image has been loaded
00770     assert(valid);
00771     assert(index < (Int32)images.size());
00772 
00773     return images[index]; 
00774 }

Int32 CDDSImage::get_num_images ( void   )  [inline]

Definition at line 241 of file OSGDDSImageFileType.cpp.

References images.

Referenced by OSG::DDSImageFileType::read().

00241 { return (Int32)images.size(); }

CTexture& CDDSImage::get_image ( Int32  index  )  [inline]

Definition at line 242 of file OSGDDSImageFileType.cpp.

References images.

00243     {
00244         assert(index < (Int32)images.size());
00245         return images[index];
00246     }

Int32 CDDSImage::get_components (  )  [inline]

Definition at line 248 of file OSGDDSImageFileType.cpp.

References components.

Referenced by OSG::DDSImageFileType::read().

00248 { return components; }

Int32 CDDSImage::get_format (  )  [inline]

Definition at line 249 of file OSGDDSImageFileType.cpp.

References format.

Referenced by OSG::DDSImageFileType::read().

00249 { return format; }

bool CDDSImage::is_compressed (  )  [inline]

Definition at line 251 of file OSGDDSImageFileType.cpp.

References compressed.

Referenced by OSG::DDSImageFileType::read().

00251 { return compressed; }

bool CDDSImage::is_cubemap (  )  [inline]

Definition at line 252 of file OSGDDSImageFileType.cpp.

References cubemap.

Referenced by OSG::DDSImageFileType::read().

00252 { return cubemap; }

bool CDDSImage::is_volume (  )  [inline]

Definition at line 253 of file OSGDDSImageFileType.cpp.

References volume.

Referenced by OSG::DDSImageFileType::read().

00253 { return volume; }

bool CDDSImage::is_valid (  )  [inline]

Definition at line 254 of file OSGDDSImageFileType.cpp.

References valid.

Referenced by OSG::DDSImageFileType::read().

00254 { return valid; }

int CDDSImage::clamp_size ( Int32  size  )  [inline, private]

Definition at line 548 of file OSGDDSImageFileType.cpp.

Referenced by load().

00549 {
00550     if (size <= 0)
00551         size = 1;
00552 
00553     return size;
00554 }

int CDDSImage::get_line_width ( Int32  width,
Int32  bpp 
) [inline, private]

Definition at line 792 of file OSGDDSImageFileType.cpp.

Referenced by align_memory().

00793 {
00794     return ((width * bpp + 31) & -32) >> 3;
00795 }

int CDDSImage::size_dxtc ( Int32  width,
Int32  height 
) [private]

Definition at line 799 of file OSGDDSImageFileType.cpp.

References format, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, and GL_COMPRESSED_RGBA_S3TC_DXT1_EXT.

Referenced by load().

00800 {
00801     Int32 comp( ( (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ||
00802                   (format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) ) ? 8 : 16 );
00803     
00804     return ((width+3)/4)*((height+3)/4)*comp;
00805 }

int CDDSImage::size_rgb ( Int32  width,
Int32  height 
) [private]

Definition at line 809 of file OSGDDSImageFileType.cpp.

References components.

Referenced by load().

00810 {
00811     return width*height*components;
00812 }

void CDDSImage::swap_endian ( void *  val  )  [inline, private]

Definition at line 534 of file OSGDDSImageFileType.cpp.

Referenced by load().

00535 {
00536 #if BYTE_ORDER == BIG_ENDIAN
00537     UInt32 *ival = (UInt32 *)val;
00538 
00539     *ival = ((*ival >> 24) & 0x000000ff) |
00540             ((*ival >>  8) & 0x0000ff00) |
00541             ((*ival <<  8) & 0x00ff0000) |
00542             ((*ival << 24) & 0xff000000);
00543 #endif
00544 }

void CDDSImage::align_memory ( CTexture surface  )  [private]

Definition at line 816 of file OSGDDSImageFileType.cpp.

References components, compressed, cubemap, CSurface::depth, get_line_width(), CSurface::height, CSurface::size, volume, and CSurface::width.

Referenced by load().

00817 {
00818     // don't bother with compressed images, volume textures, or cubemaps
00819     if (compressed || volume || cubemap)
00820         return;
00821 
00822     // calculate new image size
00823     Int32 linesize = get_line_width(surface->width, components*8);
00824     Int32 imagesize = linesize*surface->height;
00825 
00826     // exit if already aligned
00827     if (surface->size == imagesize)
00828         return;
00829 
00830     // create new image of new size
00831     CTexture newSurface(surface->width, surface->height, surface->depth, 
00832                         imagesize);
00833 
00834     // add pad bytes to end of each line
00835     char *srcimage = (char*)*surface;
00836     char *dstimage = (char*)newSurface;
00837     for (Int32 n = 0; n < surface->depth; n++)
00838     {
00839         char *curline = srcimage;
00840         char *newline = dstimage;
00841 
00842         Int32 imsize = surface->size / surface->depth;
00843         Int32 lnsize = imsize / surface->height;
00844         
00845         for (Int32 i = 0; i < surface->height; i++)
00846         {
00847             memcpy(newline, curline, lnsize);
00848             newline += linesize;
00849             curline += lnsize;
00850         }
00851     }
00852 
00853     // save padded image
00854     *surface = newSurface;
00855 }

void CDDSImage::flip ( char *  image,
Int32  width,
Int32  height,
Int32  depth,
Int32  size 
) [private]

Definition at line 899 of file OSGDDSImageFileType.cpp.

References compressed, flip_blocks_dxtc1(), flip_blocks_dxtc3(), flip_blocks_dxtc5(), format, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, swap(), and void().

Referenced by load().

00900 {
00901     Int32 linesize;
00902     Int32 offset;
00903 
00904     if (!compressed)
00905     {
00906         assert(depth > 0);
00907 
00908         Int32 imagesize = size/depth;
00909         linesize = imagesize / height;
00910 
00911         for (Int32 n = 0; n < depth; n++)
00912         {
00913             offset = imagesize*n;
00914             char *top = image + offset;
00915             char *bottom = top + (imagesize-linesize);
00916     
00917             for (Int32 i = 0; i < (height >> 1); i++)
00918             {
00919                 swap(bottom, top, linesize);
00920 
00921                 top += linesize;
00922                 bottom -= linesize;
00923             }
00924         }
00925     }
00926     else
00927     {
00928         void (CDDSImage::*flipblocks)(DXTColBlock*, Int32);
00929         Int32 xblocks = width / 4;
00930         Int32 yblocks = height / 4;
00931         Int32 blocksize;
00932 
00933         switch (format)
00934         {
00935             case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
00936                 blocksize = 8;
00937                 flipblocks = &CDDSImage::flip_blocks_dxtc1;
00938                 break;
00939             case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: 
00940                 blocksize = 8;
00941                 flipblocks = &CDDSImage::flip_blocks_dxtc1; 
00942                 break;
00943             case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: 
00944                 blocksize = 16;
00945                 flipblocks = &CDDSImage::flip_blocks_dxtc3; 
00946                 break;
00947             case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: 
00948                 blocksize = 16;
00949                 flipblocks = &CDDSImage::flip_blocks_dxtc5; 
00950                 break;
00951             default:
00952                 return;
00953         }
00954 
00955         linesize = xblocks * blocksize;
00956 
00957         DXTColBlock *top;
00958         DXTColBlock *bottom;
00959     
00960         for (Int32 j = 0; j < (yblocks >> 1); j++)
00961         {
00962             top = (DXTColBlock*)(image + j * linesize);
00963             bottom = (DXTColBlock*)(image + (((yblocks-j)-1) * linesize));
00964 
00965             (this->*flipblocks)(top, xblocks);
00966             (this->*flipblocks)(bottom, xblocks);
00967 
00968             swap(bottom, top, linesize);
00969         }
00970     }
00971 }    

bool CDDSImage::check_dxt1_alpha_data ( char *  image,
Int32  size 
) [private]

Definition at line 859 of file OSGDDSImageFileType.cpp.

References FNOTICE, and OSG::p.

Referenced by load().

00860 {
00861   bool        hasAlpha(false);
00862   DXTColBlock *colBlock((DXTColBlock*)(image));
00863 
00864   for (unsigned i = 0, n = (size / 8); i < n; i++)
00865     if (colBlock[i].col0 <= colBlock[i].col1) 
00866     {
00867         for (unsigned j = 0; j < 4; j++) {
00868           UInt8 byte = colBlock[i].row[j];
00869           for (unsigned p = 0; p < 4; p++, byte >> 2) {
00870             if ((byte & 3) == 3) {
00871               hasAlpha = true;
00872               break;
00873             }
00874           }
00875         }
00876 
00877         if (hasAlpha) 
00878         {
00879           FNOTICE (( "Found alpha in DXT1 %d/%d, col0:%d, col1:%d\n",
00880                      i, n, colBlock[i].col0, colBlock[i].col1 ));
00881 
00882           for (unsigned j = 0; j < 4; j++) 
00883             FNOTICE (( "  DXT Col Index: %d %d %d %d\n",
00884                        ((colBlock[i].row[j] >> 0) & 3),
00885                        ((colBlock[i].row[j] >> 2) & 3),
00886                        ((colBlock[i].row[j] >> 4) & 3),
00887                        ((colBlock[i].row[j] >> 6) & 3) ));
00888         }
00889 
00890         if (hasAlpha)
00891           break;
00892     }
00893 
00894   return hasAlpha;
00895 }

void CDDSImage::swap ( void *  byte1,
void *  byte2,
Int32  size 
) [private]

Definition at line 975 of file OSGDDSImageFileType.cpp.

Referenced by flip(), flip_blocks_dxtc1(), flip_blocks_dxtc3(), and flip_blocks_dxtc5().

00976 {
00977     UInt8 *tmp = new UInt8[size];
00978 
00979     memcpy(tmp, byte1, size);
00980     memcpy(byte1, byte2, size);
00981     memcpy(byte2, tmp, size);
00982 
00983     delete [] tmp;
00984 }

void CDDSImage::flip_blocks_dxtc1 ( DXTColBlock line,
Int32  numBlocks 
) [private]

Definition at line 988 of file OSGDDSImageFileType.cpp.

References DXTColBlock::row, and swap().

Referenced by flip().

00989 {
00990     DXTColBlock *curblock = line;
00991 
00992     for (Int32 i = 0; i < numBlocks; i++)
00993     {
00994         swap(&curblock->row[0], &curblock->row[3], sizeof(UInt8));
00995         swap(&curblock->row[1], &curblock->row[2], sizeof(UInt8));
00996 
00997         curblock++;
00998     }
00999 }

void CDDSImage::flip_blocks_dxtc3 ( DXTColBlock line,
Int32  numBlocks 
) [private]

Definition at line 1003 of file OSGDDSImageFileType.cpp.

References DXT3AlphaBlock::row, and swap().

Referenced by flip().

01004 {
01005     DXTColBlock *curblock = line;
01006     DXT3AlphaBlock *alphablock;
01007 
01008     for (Int32 i = 0; i < numBlocks; i++)
01009     {
01010         alphablock = (DXT3AlphaBlock*)curblock;
01011 
01012         swap(&alphablock->row[0], &alphablock->row[3], sizeof(UInt16));
01013         swap(&alphablock->row[1], &alphablock->row[2], sizeof(UInt16));
01014 
01015         curblock++;
01016 
01017         swap(&curblock->row[0], &curblock->row[3], sizeof(UInt8));
01018         swap(&curblock->row[1], &curblock->row[2], sizeof(UInt8));
01019 
01020         curblock++;
01021     }
01022 }

void CDDSImage::flip_blocks_dxtc5 ( DXTColBlock line,
Int32  numBlocks 
) [private]

Definition at line 1102 of file OSGDDSImageFileType.cpp.

References flip_dxt5_alpha(), DXTColBlock::row, and swap().

Referenced by flip().

01103 {
01104     DXTColBlock *curblock = line;
01105     DXT5AlphaBlock *alphablock;
01106     
01107     for (Int32 i = 0; i < numBlocks; i++)
01108     {
01109         alphablock = (DXT5AlphaBlock*)curblock;
01110         
01111         flip_dxt5_alpha(alphablock);
01112 
01113         curblock++;
01114 
01115         swap(&curblock->row[0], &curblock->row[3], sizeof(UInt8));
01116         swap(&curblock->row[1], &curblock->row[2], sizeof(UInt8));
01117 
01118         curblock++;
01119     }
01120 }

void CDDSImage::flip_dxt5_alpha ( DXT5AlphaBlock block  )  [private]

Definition at line 1026 of file OSGDDSImageFileType.cpp.

References DXT5AlphaBlock::row.

Referenced by flip_blocks_dxtc5().

01027 {
01028     UInt8 gBits[4][4];
01029     
01030     const UInt32 mask = 0x00000007;          // bits = 00 00 01 11
01031     UInt32 bits = 0;
01032     memcpy(&bits, &block->row[0], sizeof(UInt8) * 3);
01033 
01034     gBits[0][0] = (UInt8)(bits & mask);
01035     bits >>= 3;
01036     gBits[0][1] = (UInt8)(bits & mask);
01037     bits >>= 3;
01038     gBits[0][2] = (UInt8)(bits & mask);
01039     bits >>= 3;
01040     gBits[0][3] = (UInt8)(bits & mask);
01041     bits >>= 3;
01042     gBits[1][0] = (UInt8)(bits & mask);
01043     bits >>= 3;
01044     gBits[1][1] = (UInt8)(bits & mask);
01045     bits >>= 3;
01046     gBits[1][2] = (UInt8)(bits & mask);
01047     bits >>= 3;
01048     gBits[1][3] = (UInt8)(bits & mask);
01049 
01050     bits = 0;
01051     memcpy(&bits, &block->row[3], sizeof(UInt8) * 3);
01052 
01053     gBits[2][0] = (UInt8)(bits & mask);
01054     bits >>= 3;
01055     gBits[2][1] = (UInt8)(bits & mask);
01056     bits >>= 3;
01057     gBits[2][2] = (UInt8)(bits & mask);
01058     bits >>= 3;
01059     gBits[2][3] = (UInt8)(bits & mask);
01060     bits >>= 3;
01061     gBits[3][0] = (UInt8)(bits & mask);
01062     bits >>= 3;
01063     gBits[3][1] = (UInt8)(bits & mask);
01064     bits >>= 3;
01065     gBits[3][2] = (UInt8)(bits & mask);
01066     bits >>= 3;
01067     gBits[3][3] = (UInt8)(bits & mask);
01068 
01069     UInt32 *pBits = ((UInt32 *) &(block->row[0]));
01070 
01071     *pBits = *pBits | (gBits[3][0] << 0);
01072     *pBits = *pBits | (gBits[3][1] << 3);
01073     *pBits = *pBits | (gBits[3][2] << 6);
01074     *pBits = *pBits | (gBits[3][3] << 9);
01075 
01076     *pBits = *pBits | (gBits[2][0] << 12);
01077     *pBits = *pBits | (gBits[2][1] << 15);
01078     *pBits = *pBits | (gBits[2][2] << 18);
01079     *pBits = *pBits | (gBits[2][3] << 21);
01080 
01081     pBits = ((UInt32 *) &(block->row[3]));
01082 
01083 #if BYTE_ORDER == BIG_ENDIAN
01084     *pBits &= 0x000000ff;
01085 #else
01086     *pBits &= 0xff000000;
01087 #endif
01088 
01089     *pBits = *pBits | (gBits[1][0] << 0);
01090     *pBits = *pBits | (gBits[1][1] << 3);
01091     *pBits = *pBits | (gBits[1][2] << 6);
01092     *pBits = *pBits | (gBits[1][3] << 9);
01093 
01094     *pBits = *pBits | (gBits[0][0] << 12);
01095     *pBits = *pBits | (gBits[0][1] << 15);
01096     *pBits = *pBits | (gBits[0][2] << 18);
01097     *pBits = *pBits | (gBits[0][3] << 21);
01098 }


Member Data Documentation

Int32 CDDSImage::format [private]

Definition at line 275 of file OSGDDSImageFileType.cpp.

Referenced by clear(), flip(), get_format(), load(), and size_dxtc().

Int32 CDDSImage::components [private]

Definition at line 276 of file OSGDDSImageFileType.cpp.

Referenced by align_memory(), clear(), get_components(), load(), and size_rgb().

bool CDDSImage::compressed [private]

Definition at line 277 of file OSGDDSImageFileType.cpp.

Referenced by align_memory(), clear(), flip(), is_compressed(), and load().

bool CDDSImage::cubemap [private]

Definition at line 278 of file OSGDDSImageFileType.cpp.

Referenced by align_memory(), clear(), is_cubemap(), and load().

bool CDDSImage::volume [private]

Definition at line 279 of file OSGDDSImageFileType.cpp.

Referenced by align_memory(), clear(), is_volume(), and load().

bool CDDSImage::valid [private]

Definition at line 280 of file OSGDDSImageFileType.cpp.

Referenced by clear(), is_valid(), load(), operator char *(), and operator[]().

std::vector<CTexture> CDDSImage::images [private]


The documentation for this class was generated from the following file: