COGLES2Driver: fix swapped color screenshots

This commit is contained in:
sfan5 2021-05-08 20:57:24 +02:00
parent 08057945f6
commit 05c109a1d5

@ -2591,6 +2591,22 @@ COGLES2Driver::~COGLES2Driver()
} }
delete [] tmpBuffer; delete [] tmpBuffer;
// also GL_RGBA doesn't match the internal encoding of the image (which is BGRA)
if (GL_RGBA == internalformat && GL_UNSIGNED_BYTE == type)
{
pixels = static_cast<u8*>(newImage->getData());
for (u32 i = 0; i < ScreenSize.Height; i++)
{
for (u32 j = 0; j < ScreenSize.Width; j++)
{
u32 c = *(u32*) (pixels + 4 * j);
*(u32*) (pixels + 4 * j) = (c & 0xFF00FF00) |
((c & 0x00FF0000) >> 16) | ((c & 0x000000FF) << 16);
}
pixels += pitch;
}
}
if (testGLError(__LINE__)) if (testGLError(__LINE__))
{ {
newImage->drop(); newImage->drop();