From Marco Jez, improved Texture2D and Image handling of compare().
This commit is contained in:
parent
b3aba84d54
commit
7bf72cd43b
@ -81,8 +81,15 @@ 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)
|
||||
@ -91,13 +98,14 @@ 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;
|
||||
// same buffer + same parameters = same image
|
||||
if (_data == rhs._data) return 0;
|
||||
|
||||
if (_mipmapData<rhs._mipmapData) return -1;
|
||||
if (_mipmapData>rhs._mipmapData) return 1;
|
||||
// slowest comparison at the bottom!
|
||||
COMPARE_StateAttribute_Parameter(getFileName())
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user