From Marco Jez, improved Texture2D and Image handling of compare().

This commit is contained in:
Robert Osfield 2005-03-07 14:30:55 +00:00
parent b3aba84d54
commit 7bf72cd43b
2 changed files with 25 additions and 11 deletions

View File

@ -81,9 +81,16 @@ void Image::deallocateData()
int Image::compare(const Image& rhs) const
{
if (getFileName()<rhs.getFileName()) return -1;
else if (getFileName()>rhs.getFileName()) return 1;
// if at least one filename is empty, then need to test buffer
// pointers because images could have been created on the fly
// and therefore we can't rely on file names to get an accurate
// comparison
if (getFileName().empty() || rhs.getFileName().empty())
{
if (_data<rhs._data) return -1;
if (_data>rhs._data) return 1;
}
// need to test against image contents here...
COMPARE_StateAttribute_Parameter(_s)
COMPARE_StateAttribute_Parameter(_t)
@ -91,14 +98,15 @@ int Image::compare(const Image& rhs) const
COMPARE_StateAttribute_Parameter(_pixelFormat)
COMPARE_StateAttribute_Parameter(_dataType)
COMPARE_StateAttribute_Parameter(_packing)
COMPARE_StateAttribute_Parameter(_mipmapData)
COMPARE_StateAttribute_Parameter(_modifiedCount)
if (_data<rhs._data) return -1;
if (_data>rhs._data) return 1;
if (_mipmapData<rhs._mipmapData) return -1;
if (_mipmapData>rhs._mipmapData) return 1;
// same buffer + same parameters = same image
if (_data == rhs._data) return 0;
// slowest comparison at the bottom!
COMPARE_StateAttribute_Parameter(getFileName())
return 0;
}

View File

@ -81,8 +81,14 @@ int Texture2D::compare(const StateAttribute& sa) const
// compare each paramter in turn against the rhs.
#if 1
COMPARE_StateAttribute_Parameter(_textureWidth)
COMPARE_StateAttribute_Parameter(_textureHeight)
if (_textureWidth != 0 && rhs._textureWidth != 0)
{
COMPARE_StateAttribute_Parameter(_textureWidth)
}
if (_textureHeight != 0 && rhs._textureHeight != 0)
{
COMPARE_StateAttribute_Parameter(_textureHeight)
}
#endif
COMPARE_StateAttribute_Parameter(_subloadCallback)