DEADSOFTWARE

gl: fix screenshoting on gles
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Sun, 19 Feb 2023 22:30:39 +0000 (01:30 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 9 Jun 2023 09:18:49 +0000 (12:18 +0300)
src/game/renders/opengl/r_render.pas

index 0a27c456b8db4a2aff45c27d23771aaea515e24f..88c507977fe20c58463e93d20fa9c0e37fd1803f 100644 (file)
@@ -1110,15 +1110,10 @@ implementation
         InitImage(img);
         if NewImage(gWinSizeX, gWinSizeY, TImageFormat.ifA8R8G8B8, img) then
         begin
-          {$IFDEF ENDIAN_LITTLE}
-            typ := GL_UNSIGNED_INT_8_8_8_8_REV;
-          {$ELSE}
-            typ := GL_UNSIGNED_INT_8_8_8_8;
-          {$ENDIF}
-          glReadPixels(0, 0, gWinSizeX, gWinSizeY, GL_BGRA, typ, img.bits);
+          glReadPixels(0, 0, gWinSizeX, gWinSizeY, GL_RGBA, GL_UNSIGNED_BYTE, img.bits);
           if glGetError() = GL_NO_ERROR then
           begin
-            if FlipImage(img) then
+            if FlipImage(img) and SwapChannels(img, ChannelRed, ChannelBlue) then
             begin
               ok := SaveImageToFile(fname, img);
             end;