hedgewars/uMisc.pas
changeset 5004 2efa6a414518
parent 4976 088d40d8aba2
child 5046 fc6639d56799
--- a/hedgewars/uMisc.pas	Sun Mar 13 03:43:18 2011 +0100
+++ b/hedgewars/uMisc.pas	Sun Mar 13 18:23:51 2011 +0100
@@ -21,7 +21,7 @@
 unit uMisc;
 interface
 
-uses    SDLh, uConsts, GLunit, uTypes;
+uses SDLh, uConsts, GLunit, uTypes;
 
 procedure movecursor(dx, dy: LongInt);
 function  doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
@@ -116,11 +116,21 @@
 FreeMem(p)
 end;
 
+// http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
-{* for more information http://www.idevgames.com/forum/showpost.php?p=85864&postcount=7 *}
-var convertedSurf: PSDL_Surface = nil;
+const conversionFormat: TSDL_PixelFormat = (
+{$IFDEF SDL13}format: 0;{$ENDIF}
+        palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
+        Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
+{$IFDEF ENDIAN_LITTLE}Rshift: 0; Gshift: 8; Bshift: 16; Ashift: 24;
+{$ELSE} Rshift: 24; Gshift: 16; Bshift: 8; Ashift: 0;{$ENDIF}
+        RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
+{$IFDEF SDL13}refcount: 0; next: nil;
+{$ELSE} colorkey: 0; alpha: 255{$ENDIF});
+var convertedSurf: PSDL_Surface;
 begin
-    if (tmpsurf^.format^.bitsperpixel = 24) or ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) then
+    if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
+       (tmpsurf^.format^.bitsperpixel = 24) then
         begin
         convertedSurf:= SDL_ConvertSurface(tmpsurf, @conversionFormat, SDL_SWSURFACE);
         SDL_FreeSurface(tmpsurf);