hedgewars/uMisc.pas
changeset 5004 2efa6a414518
parent 4976 088d40d8aba2
child 5046 fc6639d56799
equal deleted inserted replaced
5002:a9c44a8ffec8 5004:2efa6a414518
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 
    20 
    21 unit uMisc;
    21 unit uMisc;
    22 interface
    22 interface
    23 
    23 
    24 uses    SDLh, uConsts, GLunit, uTypes;
    24 uses SDLh, uConsts, GLunit, uTypes;
    25 
    25 
    26 procedure movecursor(dx, dy: LongInt);
    26 procedure movecursor(dx, dy: LongInt);
    27 function  doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
    27 function  doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
    28 procedure MakeScreenshot(filename: shortstring);
    28 procedure MakeScreenshot(filename: shortstring);
    29 function  GetTeamStatString(p: PTeam): shortstring;
    29 function  GetTeamStatString(p: PTeam): shortstring;
   114 {$I+}
   114 {$I+}
   115 
   115 
   116 FreeMem(p)
   116 FreeMem(p)
   117 end;
   117 end;
   118 
   118 
       
   119 // http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
   119 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
   120 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
   120 {* for more information http://www.idevgames.com/forum/showpost.php?p=85864&postcount=7 *}
   121 const conversionFormat: TSDL_PixelFormat = (
   121 var convertedSurf: PSDL_Surface = nil;
   122 {$IFDEF SDL13}format: 0;{$ENDIF}
       
   123         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
       
   124         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
       
   125 {$IFDEF ENDIAN_LITTLE}Rshift: 0; Gshift: 8; Bshift: 16; Ashift: 24;
       
   126 {$ELSE} Rshift: 24; Gshift: 16; Bshift: 8; Ashift: 0;{$ENDIF}
       
   127         RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
       
   128 {$IFDEF SDL13}refcount: 0; next: nil;
       
   129 {$ELSE} colorkey: 0; alpha: 255{$ENDIF});
       
   130 var convertedSurf: PSDL_Surface;
   122 begin
   131 begin
   123     if (tmpsurf^.format^.bitsperpixel = 24) or ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) then
   132     if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
       
   133        (tmpsurf^.format^.bitsperpixel = 24) then
   124         begin
   134         begin
   125         convertedSurf:= SDL_ConvertSurface(tmpsurf, @conversionFormat, SDL_SWSURFACE);
   135         convertedSurf:= SDL_ConvertSurface(tmpsurf, @conversionFormat, SDL_SWSURFACE);
   126         SDL_FreeSurface(tmpsurf);
   136         SDL_FreeSurface(tmpsurf);
   127         exit(convertedSurf);
   137         exit(convertedSurf);
   128         end;
   138         end;