diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 92f1ad496..65f2ad3ab 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -1404,14 +1404,23 @@ void Image::flipVertical() unsigned int rowSize = getRowSizeInBytes(); unsigned int rowStep = getRowStepInBytes(); + const bool dxtc(dxtc_tool::isDXTC(_pixelFormat)); if (_mipmapData.empty()) { // no mipmaps, // so we can safely handle 3d textures for(int r=0;r<_r;++r) { - if (!dxtc_tool::VerticalFlip(_s,_t,_pixelFormat,data(0,0,r))) + if (dxtc) { + if (!dxtc_tool::VerticalFlip(_s,_t,_pixelFormat,data(0,0,r))) + { + OSG_NOTICE << "Notice Image::flipVertical(): Vertical flip do not succeed" << std::endl; + } + } + else + { + if (isCompressed()) OSG_NOTICE << "Notice Image::flipVertical(): image is compressed but normal v-flip is used" << std::endl; // its not a compressed image, so implement flip oursleves. unsigned char* top = data(0,0,r); unsigned char* bottom = top + (_t-1)*rowStep; @@ -1422,8 +1431,16 @@ void Image::flipVertical() } else if (_r==1) { - if (!dxtc_tool::VerticalFlip(_s,_t,_pixelFormat,_data)) + if (dxtc) { + if (!dxtc_tool::VerticalFlip(_s,_t,_pixelFormat,_data)) + { + OSG_NOTICE << "Notice Image::flipVertical(): Vertical flip do not succeed" << std::endl; + } + } + else + { + if (isCompressed()) OSG_NOTICE << "Notice Image::flipVertical(): image is compressed but normal v-flip is used" << std::endl; // its not a compressed image, so implement flip oursleves. unsigned char* top = data(0,0,0); unsigned char* bottom = top + (_t-1)*rowStep; @@ -1441,7 +1458,14 @@ void Image::flipVertical() t >>= 1; if (s==0) s=1; if (t==0) t=1; - if (!dxtc_tool::VerticalFlip(s,t,_pixelFormat,_data+_mipmapData[i])) + if (dxtc) + { + if (!dxtc_tool::VerticalFlip(s,t,_pixelFormat,_data+_mipmapData[i])) + { + OSG_NOTICE << "Notice Image::flipVertical(): Vertical flip do not succeed" << std::endl; + } + } + else { // its not a compressed image, so implement flip oursleves. unsigned char* top = _data+_mipmapData[i]; diff --git a/src/osg/dxtctool.cpp b/src/osg/dxtctool.cpp index 2e4628c8d..7e486972a 100644 --- a/src/osg/dxtctool.cpp +++ b/src/osg/dxtctool.cpp @@ -17,6 +17,7 @@ namespace dxtc_tool { const size_t dxtc_pixels::BSIZE_ALPHA_DXT3 = 8; const size_t dxtc_pixels::BSIZE_ALPHA_DXT5 = 8; + ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// diff --git a/src/osg/dxtctool.h b/src/osg/dxtctool.h index 9251064ac..5d5f252d5 100644 --- a/src/osg/dxtctool.h +++ b/src/osg/dxtctool.h @@ -73,10 +73,9 @@ namespace dxtc_tool { - - - // C-like function wrappers +bool isDXTC(GLenum pixelFormat); + bool VerticalFlip(size_t Width, size_t Height, GLenum Format, void * pPixels); bool CompressedImageTranslucent(size_t Width, size_t Height, GLenum Format, void * pPixels); @@ -141,6 +140,20 @@ protected: // C-Like Function Wrappers ////////////////////////////////////////////////////////////////////// +inline bool isDXTC(GLenum pixelFormat) +{ + switch(pixelFormat) + { + case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): + case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): + case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT): + case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT): + return true; + default: + return false; + } +} + inline bool VerticalFlip(size_t Width, size_t Height, GLenum Format, void * pPixels) { return (dxtc_pixels(Width, Height, Format, pPixels)).VFlip(); }