Skip to content

Commit

Permalink
COGLES2Driver: fix swapped color screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed May 8, 2021
1 parent 0805794 commit 05c109a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/Irrlicht/COGLES2Driver.cpp
Expand Up @@ -2591,6 +2591,22 @@ COGLES2Driver::~COGLES2Driver()
}
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__))
{
newImage->drop();
Expand Down

0 comments on commit 05c109a

Please sign in to comment.