hedgewars/uRenderUtils.pas
branchtransitional_engine
changeset 15900 128ace913837
parent 15852 c4561095666a
child 15975 2146cb7be36f
equal deleted inserted replaced
15899:73cdc306888f 15900:128ace913837
    24 uses SDLh, uTypes;
    24 uses SDLh, uTypes;
    25 
    25 
    26 procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean);
    26 procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean);
    27 
    27 
    28 procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL
    28 procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL
    29 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); inline;
    29 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); 
    30 procedure copyToXYFromRect(src, dest: PSDL_Surface; srcX, srcY, srcW, srcH, destX, destY: LongInt);
    30 procedure copyToXYFromRect(src, dest: PSDL_Surface; srcX, srcY, srcW, srcH, destX, destY: LongInt);
    31 
    31 
    32 procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); inline;
    32 procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); 
    33 procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt; frame: LongInt);
    33 procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt; frame: LongInt);
    34 procedure DrawLine2Surf(dest: PSDL_Surface; x0,y0,x1,y1:LongInt; r,g,b: byte);
    34 procedure DrawLine2Surf(dest: PSDL_Surface; x0,y0,x1,y1:LongInt; r,g,b: byte);
    35 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
    35 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
    36 
    36 
    37 function  RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture;
    37 function  RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture;
    38 function  RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
    38 function  RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
    39 function  RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture;
    39 function  RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture;
    40 
    40 
    41 function IsTooDarkToRead(TextColor: Longword): boolean; inline;
    41 function IsTooDarkToRead(TextColor: Longword): boolean; 
    42 
    42 
    43 implementation
    43 implementation
    44 uses uVariables, uConsts, uTextures, SysUtils, uUtils, uDebug;
    44 uses uVariables, uConsts, uTextures, SysUtils, uUtils, uDebug;
    45 
    45 
    46 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
    46 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
    76 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect;
    76 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect;
    77 begin
    77 begin
    78     WriteInRoundRect:= WriteInRoundRect(Surface, X, Y, Color, Font, s, 0);
    78     WriteInRoundRect:= WriteInRoundRect(Surface, X, Y, Color, Font, s, 0);
    79 end;*)
    79 end;*)
    80 
    80 
    81 function IsTooDarkToRead(TextColor: LongWord): boolean; inline;
    81 function IsTooDarkToRead(TextColor: LongWord): boolean; 
    82 var clr: TSDL_Color;
    82 var clr: TSDL_Color;
    83 begin
    83 begin
    84     clr.r:= (TextColor shr 16) and $FF;
    84     clr.r:= (TextColor shr 16) and $FF;
    85     clr.g:= (TextColor shr 8) and $FF;
    85     clr.g:= (TextColor shr 8) and $FF;
    86     clr.b:= TextColor and $FF;
    86     clr.b:= TextColor and $FF;
   155             pixels^[j]:= tmpPixel;
   155             pixels^[j]:= tmpPixel;
   156             end;
   156             end;
   157     SDL_UnlockSurface(Surface);
   157     SDL_UnlockSurface(Surface);
   158 end;
   158 end;
   159 
   159 
   160 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); inline;
   160 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); 
   161 begin
   161 begin
   162     // copy from complete src
   162     // copy from complete src
   163     copyToXYFromRect(src, dest, 0, 0, src^.w, src^.h, destX, destY);
   163     copyToXYFromRect(src, dest, 0, 0, src^.w, src^.h, destX, destY);
   164 end;
   164 end;
   165 
   165 
   231 
   231 
   232     SDL_UnlockSurface(src);
   232     SDL_UnlockSurface(src);
   233     SDL_UnlockSurface(dest);
   233     SDL_UnlockSurface(dest);
   234 end;
   234 end;
   235 
   235 
   236 procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); inline;
   236 procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); 
   237 begin
   237 begin
   238    DrawSpriteFrame2Surf(sprite, dest, x, y, 0);
   238    DrawSpriteFrame2Surf(sprite, dest, x, y, 0);
   239 end;
   239 end;
   240 
   240 
   241 procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y,frame: LongInt);
   241 procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y,frame: LongInt);