hedgewars/uRender.pas
changeset 10255 fdc342ebdc31
parent 10108 c68cf030eded
child 10266 a90a55ec5b98
equal deleted inserted replaced
10254:eb28335df088 10255:fdc342ebdc31
    50 procedure DrawLine              (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
    50 procedure DrawLine              (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
    51 procedure DrawFillRect          (r: TSDL_Rect);
    51 procedure DrawFillRect          (r: TSDL_Rect);
    52 procedure DrawHedgehog          (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
    52 procedure DrawHedgehog          (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
    53 procedure DrawScreenWidget      (widget: POnScreenWidget);
    53 procedure DrawScreenWidget      (widget: POnScreenWidget);
    54 
    54 
       
    55 procedure openglTint            (r, g, b, a: Byte); inline;
    55 procedure Tint                  (r, g, b, a: Byte); inline;
    56 procedure Tint                  (r, g, b, a: Byte); inline;
    56 procedure Tint                  (c: Longword); inline;
    57 procedure Tint                  (c: Longword); inline;
    57 procedure untint(); inline;
    58 procedure untint(); inline;
    58 procedure setTintAdd            (f: boolean); inline;
    59 procedure setTintAdd            (f: boolean); inline;
    59 
    60 
   711 begin
   712 begin
   712 widget:= widget; // avoid hint
   713 widget:= widget; // avoid hint
   713 {$ENDIF}
   714 {$ENDIF}
   714 end;
   715 end;
   715 
   716 
       
   717 procedure openglTint(r, g, b, a: Byte); inline;
       
   718 {$IFDEF GL2}
       
   719 const
       
   720     scale:Real = 1.0/255.0;
       
   721 {$ENDIF}
       
   722 begin
       
   723     {$IFDEF GL2}
       
   724     glUniform4f(uMainTintLocation, r*scale, g*scale, b*scale, a*scale);
       
   725     {$ELSE}
       
   726     glColor4ub(r, g, b, a);
       
   727     {$ENDIF}
       
   728 end;
       
   729 
   716 procedure Tint(r, g, b, a: Byte); inline;
   730 procedure Tint(r, g, b, a: Byte); inline;
   717 var
   731 var
   718     nc, tw: Longword;
   732     nc, tw: Longword;
   719     {$IFDEF GL2}
       
   720     scale:Real = 1.0/255.0;
       
   721     {$ENDIF}
       
   722 begin
   733 begin
   723     nc:= (r shl 24) or (g shl 16) or (b shl 8) or a;
   734     nc:= (r shl 24) or (g shl 16) or (b shl 8) or a;
   724 
   735 
   725     if nc = lastTint then
   736     if nc = lastTint then
   726         exit;
   737         exit;
   733         r:= tw;
   744         r:= tw;
   734         g:= tw;
   745         g:= tw;
   735         b:= tw
   746         b:= tw
   736         end;
   747         end;
   737 
   748 
   738     {$IFDEF GL2}
   749     openglTint(r, g, b, a);
   739     glUniform4f(uMainTintLocation, r*scale, g*scale, b*scale, a*scale);
       
   740     //glColor4ub(r, g, b, a);
       
   741     {$ELSE}
       
   742     glColor4ub(r, g, b, a);
       
   743     {$ENDIF}
       
   744     lastTint:= nc;
   750     lastTint:= nc;
   745 end;
   751 end;
   746 
   752 
   747 procedure Tint(c: Longword); inline;
   753 procedure Tint(c: Longword); inline;
   748 begin
   754 begin
   750     Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF))
   756     Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF))
   751 end;
   757 end;
   752 
   758 
   753 procedure untint(); inline;
   759 procedure untint(); inline;
   754 begin
   760 begin
   755     Tint($FF, $FF, $FF, $FF)
   761     if cWhiteColor = lastTint then exit;
       
   762     openglTint($FF, $FF, $FF, $FF);
       
   763     lastTint:= cWhiteColor;
   756 end;
   764 end;
   757 
   765 
   758 procedure setTintAdd(f: boolean); inline;
   766 procedure setTintAdd(f: boolean); inline;
   759 begin
   767 begin
   760     if f then
   768     if f then