equal
deleted
inserted
replaced
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; dump: LongWord): boolean; |
31 function MakeScreenshot(filename: shortstring; k: LongInt; dump: LongWord): boolean; |
32 function GetTeamStatString(p: PTeam): shortstring; |
32 function GetTeamStatString(p: PTeam): shortstring; |
33 {$IFDEF SDL2} |
|
34 function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline; |
33 function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline; |
35 {$ELSE} |
|
36 function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline; |
|
37 {$ENDIF} |
|
38 |
34 |
39 implementation |
35 implementation |
40 uses SysUtils, uVariables, uUtils |
36 uses SysUtils, uVariables, uUtils |
41 {$IFDEF PNG_SCREENSHOTS}, PNGh, png {$ENDIF}; |
37 {$IFDEF PNG_SCREENSHOTS}, PNGh, png {$ENDIF}; |
42 |
38 |
301 image^.height:= cScreenHeight div k |
297 image^.height:= cScreenHeight div k |
302 end; |
298 end; |
303 image^.size:= size; |
299 image^.size:= size; |
304 image^.buffer:= p; |
300 image^.buffer:= p; |
305 |
301 |
306 SDL_CreateThread(@SaveScreenshot{$IFDEF SDL2}, 'snapshot'{$ENDIF}, image); |
302 SDL_CreateThread(@SaveScreenshot, PChar('snapshot'), image); |
307 MakeScreenshot:= true; // possibly it is not true but we will not wait for thread to terminate |
303 MakeScreenshot:= true; // possibly it is not true but we will not wait for thread to terminate |
308 end; |
304 end; |
309 |
305 |
310 // http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860 |
306 // http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860 |
311 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; |
307 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; |
319 SDL_FreeSurface(tmpsurf); |
315 SDL_FreeSurface(tmpsurf); |
320 doSurfaceConversion:= convertedSurf; |
316 doSurfaceConversion:= convertedSurf; |
321 end; |
317 end; |
322 end; |
318 end; |
323 |
319 |
324 {$IFDEF SDL2} |
|
325 function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline; |
320 function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline; |
326 {$ELSE} |
|
327 function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline; |
|
328 {$ENDIF} |
|
329 begin |
321 begin |
330 SDL_RectMake.x:= x; |
322 SDL_RectMake.x:= x; |
331 SDL_RectMake.y:= y; |
323 SDL_RectMake.y:= y; |
332 SDL_RectMake.w:= width; |
324 SDL_RectMake.w:= width; |
333 SDL_RectMake.h:= height; |
325 SDL_RectMake.h:= height; |
338 begin |
330 begin |
339 s:= p^.TeamName + ':' + IntToStr(p^.TeamHealth) + ':'; |
331 s:= p^.TeamName + ':' + IntToStr(p^.TeamHealth) + ':'; |
340 GetTeamStatString:= s; |
332 GetTeamStatString:= s; |
341 end; |
333 end; |
342 |
334 |
343 {$IFDEF SDL2} |
335 procedure initModule; |
344 // FIXME - pretty sure this is not handling endianness correctly like the SDL1 is |
|
345 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; |
336 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; |
346 {$ELSE} |
337 begin |
347 const format: TSDL_PixelFormat = ( |
|
348 palette: nil; BitsPerPixel: 32; BytesPerPixel: 4; |
|
349 Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0; |
|
350 Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift; |
|
351 RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask; |
|
352 colorkey: 0; alpha: 255); |
|
353 {$ENDIF} |
|
354 |
|
355 procedure initModule; |
|
356 begin |
|
357 {$IFDEF SDL2} |
|
358 conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888); |
338 conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888); |
359 {$ELSE} |
|
360 conversionFormat:= @format; |
|
361 {$ENDIF} |
|
362 end; |
339 end; |
363 |
340 |
364 procedure freeModule; |
341 procedure freeModule; |
365 begin |
342 begin |
366 {$IFDEF SDL2} |
|
367 SDL_FreeFormat(conversionFormat); |
343 SDL_FreeFormat(conversionFormat); |
368 {$ENDIF} |
|
369 end; |
344 end; |
370 |
345 |
371 end. |
346 end. |