From Bradley Baker Searles, "We had someone replace a DDS texture with a GL_RGB/GL_UNSIGNED_SHORT_5_6_6 image, which would trigger a crash in Image.cpp while flipping the mipmap chain. The code was trying to flip the mipmaps using the rowStep for the full-size image (we have "dds_flip" set in the osgDB::ReaderWriter::Options in the osgDB::Registry)."

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14732 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2015-02-26 19:14:28 +00:00
parent 9dffd49241
commit 6a30705870

View File

@ -1558,16 +1558,18 @@ void Image::flipVertical()
{ {
if (!dxtc_tool::VerticalFlip(s,t,_pixelFormat,_data+_mipmapData[i])) if (!dxtc_tool::VerticalFlip(s,t,_pixelFormat,_data+_mipmapData[i]))
{ {
OSG_NOTICE << "Notice Image::flipVertical(): Vertical flip do not succeed" << std::endl; OSG_NOTICE << "Notice Image::flipVertical(): Vertical flip did not succeed" << std::endl;
} }
} }
else else
{ {
// its not a compressed image, so implement flip oursleves. // it's not a compressed image, so implement flip ourselves.
unsigned int mipRowSize = computeRowWidthInBytes(s, _pixelFormat, _dataType, _packing);
unsigned int mipRowStep = mipRowSize;
unsigned char* top = _data+_mipmapData[i]; unsigned char* top = _data+_mipmapData[i];
unsigned char* bottom = top + (t-1)*rowStep; unsigned char* bottom = top + (t-1)*mipRowStep;
flipImageVertical(top, bottom, rowSize, rowStep); flipImageVertical(top, bottom, mipRowSize, mipRowStep);
} }
} }
} }