hedgewars/uRender.pas
changeset 5488 fef456439238
parent 5441 39962b855540
child 5559 a937d43a032f
--- a/hedgewars/uRender.pas	Wed Jul 27 11:41:43 2011 +0400
+++ b/hedgewars/uRender.pas	Mon Aug 01 10:08:02 2011 +0400
@@ -22,7 +22,7 @@
 
 interface
 
-uses SDLh, uTypes, GLunit;
+uses SDLh, uTypes, GLunit, uConsts;
 
 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
 procedure DrawFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
@@ -453,11 +453,20 @@
 
 
 procedure Tint(r, g, b, a: Byte); inline;
-var nc: Longword;
+var nc, tw: Longword;
 begin
 nc:= (a shl 24) or (b shl 16) or (g shl 8) or r;
 if nc = lastTint then
     exit;
+if cGrayScale then
+    begin
+    tw:= round(r * RGB_LUMINANCE_RED + g * RGB_LUMINANCE_GREEN + b * RGB_LUMINANCE_BLUE);
+    if tw > 255 then tw:= 255;
+    r:= tw;
+    g:= tw;
+    b:= tw
+    end;
+
 glColor4ub(r, g, b, a);
 lastTint:= nc;
 end;