DEADSOFTWARE

gl: fix screenshoting on gles
[d2df-sdl.git] / src / game / renders / opengl / r_render.pas
index 44ee5b61da1bdf57a5eb97d9c57113eb57f733f0..88c507977fe20c58463e93d20fa9c0e37fd1803f 100644 (file)
@@ -99,6 +99,7 @@ implementation
     {$ENDIF}
     SysUtils, Classes, Math,
     g_basic,
+    e_sound, // DebugSound
     e_log, e_res, utils, wadreader, mapdef,
     g_game, g_map, g_panel, g_options, g_console, g_player, g_weapons, g_language, g_triggers, g_monsters,
     g_net, g_netmaster,
@@ -118,6 +119,7 @@ implementation
 
     FPS, FPSCounter, FPSTime: LongWord;
     TakeScreenShot: Boolean;
+    DebugSound: Boolean;
 
   procedure r_Render_LoadTextures;
   begin
@@ -1108,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;
@@ -1132,7 +1129,7 @@ implementation
   end;
 
   procedure r_Render_Draw;
-    var p1, p2: TPlayer; time: LongWord; pw, ph: Integer;
+    var p1, p2: TPlayer; time: LongWord; pw, ph, i, j: Integer;
   begin
     if gExit = EXIT_QUIT then
       exit;
@@ -1324,7 +1321,12 @@ implementation
 
     r_Console_Draw(false);
 
-    // TODO g_debug_Sounds
+    if DebugSound and gGameOn then
+    begin
+      for i := 0 to High(e_SoundsArray) do
+        for j := 0 to e_SoundsArray[i].nRefs do
+          r_Draw_FillRect(i + 100, j + 100, i + 100 + 1, j + 100 + 1, 255, 0, 0, 255);
+    end;
 
     if gShowFPS then
     begin
@@ -1478,4 +1480,7 @@ implementation
   end;
 {$ENDIF}
 
+begin
+  conRegVar('d_sounds', @DebugSound, '', '');
+  DebugSound := false;
 end.