mirror of
https://github.com/jorio/Pomme.git
synced 2024-12-26 14:29:38 +00:00
QD3D/Graphics big-endian compatibility
This commit is contained in:
parent
a1e1b62681
commit
e567db5327
@ -576,7 +576,9 @@ void CopyBits(
|
||||
// if the source pixel is not equal to the background color.
|
||||
|
||||
UInt32 transparentColor = penBG;
|
||||
#if !(__BIG_ENDIAN__)
|
||||
ByteswapInts(sizeof(transparentColor), 1, &transparentColor); // need to byteswap because ARGBPixmap.GetPtr returns a pointer to raw (big-endian) ARGB ints
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < srcRectHeight; y++)
|
||||
{
|
||||
|
@ -543,11 +543,11 @@ TQ3Pixmap* Q3MetaFileParser::ParsePixmap(uint32_t chunkType, uint32_t chunkSize)
|
||||
f.Skip(rowBytes - width * bytesPerPixel);
|
||||
}
|
||||
|
||||
// Make every pixel little-endian (especially to avoid breaking 16-bit 1-5-5-5 ARGB textures)
|
||||
if (byteOrder == kQ3EndianBig)
|
||||
// Convert to native endianness (especially to avoid breaking 16-bit 1-5-5-5 ARGB textures)
|
||||
if (byteOrder != kQ3EndianNative)
|
||||
{
|
||||
ByteswapInts(bytesPerPixel, width*height, pixmap->image);
|
||||
pixmap->byteOrder = kQ3EndianLittle;
|
||||
pixmap->byteOrder = kQ3EndianNative;
|
||||
}
|
||||
|
||||
Q3Pixmap_ApplyEdgePadding(pixmap);
|
||||
|
@ -110,7 +110,7 @@ void Q3Pixmap_ApplyEdgePadding(TQ3Pixmap* pm)
|
||||
pm->width,
|
||||
pm->height,
|
||||
pm->rowBytes,
|
||||
pm->byteOrder==kQ3EndianBig? 0x0080: 0x8000);
|
||||
pm->byteOrder==kQ3EndianNative? 0x8000: 0x0080);
|
||||
break;
|
||||
|
||||
case kQ3PixelTypeARGB32:
|
||||
@ -120,7 +120,7 @@ void Q3Pixmap_ApplyEdgePadding(TQ3Pixmap* pm)
|
||||
pm->width,
|
||||
pm->height,
|
||||
pm->rowBytes,
|
||||
pm->byteOrder==kQ3EndianBig? 0x000000FF: 0xFF000000);
|
||||
pm->byteOrder==kQ3EndianNative? 0xFF000000: 0x000000FF);
|
||||
break;
|
||||
|
||||
case kQ3PixelTypeRGB16:
|
||||
|
@ -134,6 +134,11 @@ typedef enum
|
||||
{
|
||||
kQ3EndianBig = 0,
|
||||
kQ3EndianLittle = 1,
|
||||
#if __BIG_ENDIAN__
|
||||
kQ3EndianNative = kQ3EndianBig,
|
||||
#else
|
||||
kQ3EndianNative = kQ3EndianLittle,
|
||||
#endif
|
||||
kQ3EndianSize32 = 0xFFFFFFFF
|
||||
} TQ3Endian;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user