tweak untint a little (especially in connection with GrayScale)
authorsheepluva
Wed, 04 Jun 2014 19:39:54 +0200
changeset 10255 fdc342ebdc31
parent 10254 eb28335df088
child 10256 b07288b729c4
tweak untint a little (especially in connection with GrayScale)
hedgewars/uRender.pas
--- a/hedgewars/uRender.pas	Tue Jun 03 11:09:18 2014 -0400
+++ b/hedgewars/uRender.pas	Wed Jun 04 19:39:54 2014 +0200
@@ -52,6 +52,7 @@
 procedure DrawHedgehog          (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
 procedure DrawScreenWidget      (widget: POnScreenWidget);
 
+procedure openglTint            (r, g, b, a: Byte); inline;
 procedure Tint                  (r, g, b, a: Byte); inline;
 procedure Tint                  (c: Longword); inline;
 procedure untint(); inline;
@@ -713,12 +714,22 @@
 {$ENDIF}
 end;
 
+procedure openglTint(r, g, b, a: Byte); inline;
+{$IFDEF GL2}
+const
+    scale:Real = 1.0/255.0;
+{$ENDIF}
+begin
+    {$IFDEF GL2}
+    glUniform4f(uMainTintLocation, r*scale, g*scale, b*scale, a*scale);
+    {$ELSE}
+    glColor4ub(r, g, b, a);
+    {$ENDIF}
+end;
+
 procedure Tint(r, g, b, a: Byte); inline;
 var
     nc, tw: Longword;
-    {$IFDEF GL2}
-    scale:Real = 1.0/255.0;
-    {$ENDIF}
 begin
     nc:= (r shl 24) or (g shl 16) or (b shl 8) or a;
 
@@ -735,12 +746,7 @@
         b:= tw
         end;
 
-    {$IFDEF GL2}
-    glUniform4f(uMainTintLocation, r*scale, g*scale, b*scale, a*scale);
-    //glColor4ub(r, g, b, a);
-    {$ELSE}
-    glColor4ub(r, g, b, a);
-    {$ENDIF}
+    openglTint(r, g, b, a);
     lastTint:= nc;
 end;
 
@@ -752,7 +758,9 @@
 
 procedure untint(); inline;
 begin
-    Tint($FF, $FF, $FF, $FF)
+    if cWhiteColor = lastTint then exit;
+    openglTint($FF, $FF, $FF, $FF);
+    lastTint:= cWhiteColor;
 end;
 
 procedure setTintAdd(f: boolean); inline;