hedgewars/uMisc.pas
changeset 9317 a04c30940d2d
parent 9311 5baf10a52f43
child 9521 8054d9d775fd
child 9998 736015b847e3
child 11360 7a7611adf715
equal deleted inserted replaced
9315:15487f7fed42 9317:a04c30940d2d
    28 
    28 
    29 procedure movecursor(dx, dy: LongInt);
    29 procedure movecursor(dx, dy: LongInt);
    30 function  doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
    30 function  doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
    31 function  MakeScreenshot(filename: shortstring; k: LongInt): boolean;
    31 function  MakeScreenshot(filename: shortstring; k: LongInt): boolean;
    32 function  GetTeamStatString(p: PTeam): shortstring;
    32 function  GetTeamStatString(p: PTeam): shortstring;
    33 {$IFDEF SDL13}
    33 {$IFDEF SDL2}
    34 function  SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
    34 function  SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
    35 {$ELSE}
    35 {$ELSE}
    36 function  SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline;
    36 function  SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline;
    37 {$ENDIF}
    37 {$ENDIF}
    38 
    38 
   259 image^.width:= cScreenWidth div k;
   259 image^.width:= cScreenWidth div k;
   260 image^.height:= cScreenHeight div k;
   260 image^.height:= cScreenHeight div k;
   261 image^.size:= size;
   261 image^.size:= size;
   262 image^.buffer:= p;
   262 image^.buffer:= p;
   263 
   263 
   264 SDL_CreateThread(@SaveScreenshot{$IFDEF SDL13}, 'snapshot'{$ENDIF}, image);
   264 SDL_CreateThread(@SaveScreenshot{$IFDEF SDL2}, 'snapshot'{$ENDIF}, image);
   265 MakeScreenshot:= true; // possibly it is not true but we will not wait for thread to terminate
   265 MakeScreenshot:= true; // possibly it is not true but we will not wait for thread to terminate
   266 end;
   266 end;
   267 
   267 
   268 // http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
   268 // http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
   269 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
   269 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
   277         SDL_FreeSurface(tmpsurf);
   277         SDL_FreeSurface(tmpsurf);
   278         doSurfaceConversion:= convertedSurf;
   278         doSurfaceConversion:= convertedSurf;
   279     end;
   279     end;
   280 end;
   280 end;
   281 
   281 
   282 {$IFDEF SDL13}
   282 {$IFDEF SDL2}
   283 function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
   283 function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
   284 {$ELSE}
   284 {$ELSE}
   285 function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline;
   285 function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline;
   286 {$ENDIF}
   286 {$ENDIF}
   287 begin
   287 begin
   297     s:= p^.TeamName + ':' + IntToStr(p^.TeamHealth) + ':';
   297     s:= p^.TeamName + ':' + IntToStr(p^.TeamHealth) + ':';
   298     GetTeamStatString:= s;
   298     GetTeamStatString:= s;
   299 end;
   299 end;
   300 
   300 
   301 procedure initModule;
   301 procedure initModule;
       
   302 {$IFDEF SDL2}
   302 const SDL_PIXELFORMAT_ABGR8888 = (1 shl 28) or (6 shl 24) or (7 shl 20) or (6 shl 16) or (32 shl 8) or 4;
   303 const SDL_PIXELFORMAT_ABGR8888 = (1 shl 28) or (6 shl 24) or (7 shl 20) or (6 shl 16) or (32 shl 8) or 4;
   303 begin
   304 {$ELSE}
       
   305 const format: TSDL_PixelFormat = (
       
   306         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
       
   307         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
       
   308         Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift;
       
   309         RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
       
   310         colorkey: 0; alpha: 255);
       
   311 {$ENDIF}
       
   312 begin
       
   313 {$IFDEF SDL2}
   304     conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888);
   314     conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888);
       
   315 {$ELSE}
       
   316     conversionFormat:= @format;
       
   317 {$ENDIF}
   305 end;
   318 end;
   306 
   319 
   307 procedure freeModule;
   320 procedure freeModule;
   308 begin
   321 begin
       
   322 {$IFDEF SDL2}
   309     SDL_FreeFormat(conversionFormat);
   323     SDL_FreeFormat(conversionFormat);
       
   324 {$ENDIF}
   310 end;
   325 end;
   311 
   326 
   312 end.
   327 end.