Engine:
authorsmxx
Sat, 01 May 2010 20:02:20 +0000
changeset 3390 1d4926d10a9e
parent 3389 9b97b9240c22
child 3391 77161719ec3c
Engine: * Changed Tint() to use the 4 byte version all the time instead of the longword pointer due to pixel format issues * Added a "laser dot" to laser sight
hedgewars/GearDrawing.inc
hedgewars/uChat.pas
hedgewars/uGears.pas
hedgewars/uStore.pas
hedgewars/uVisualGears.pas
hedgewars/uWorld.pas
--- a/hedgewars/GearDrawing.inc	Sat May 01 19:40:45 2010 +0000
+++ b/hedgewars/GearDrawing.inc	Sat May 01 20:02:20 2010 +0000
@@ -4,7 +4,6 @@
     hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
     lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
     defaultPos, HatVisible: boolean;
-    VertexBuffer: array [0..1] of TVertex2f;
     HH: PHedgehog;
 begin
 HH:= PHedgehog(Gear^.Hedgehog);
@@ -30,9 +29,9 @@
 
 if HH^.Effects[hePoisoned] then
     begin
-    Tint($4040FF00);
+    Tint($40, $FF, $00, $40);
     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
-    Tint($FFFFFFFF)
+    Tint($FF, $FF, $FF, $FF)
     end;
 
 if ((Gear^.State and gstWinner) <> 0) and
@@ -110,23 +109,22 @@
 
             //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
                 begin
+                glEnable(GL_LINE_SMOOTH);
                 glDisable(GL_TEXTURE_2D);
-                glEnable(GL_LINE_SMOOTH);
-
                 glLineWidth(1.0);
-
-                Tint($C0FF0000);
-                VertexBuffer[0].X:= hx + WorldDx;
-                VertexBuffer[0].Y:= hy + WorldDy;
-                VertexBuffer[1].X:= tx + WorldDx;
-                VertexBuffer[1].Y:= ty + WorldDy;
-
-                glEnableClientState(GL_VERTEX_ARRAY);
-                glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
-                glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
-                Tint($FFFFFFFF);
+                Tint($FF, $00, $00, $C0);
+                glBegin(GL_LINES);
+                glVertex3f(hx + WorldDx, hy + WorldDy, 0);
+                glVertex3f(tx + WorldDx, ty + WorldDy, 0);
+                glEnd();
+                glLineWidth(5.0);
+                glBegin(GL_LINES);
+                glVertex3f(tx + WorldDx - 0.5, ty + WorldDy, 0);
+                glVertex3f(tx + WorldDx + 0.5, ty + WorldDy, 0);
+                glEnd();
+                Tint($FF, $FF, $FF, $FF);
+                glDisable(GL_LINE_SMOOTH);
                 glEnable(GL_TEXTURE_2D);
-                glDisable(GL_LINE_SMOOTH);
                 end;
             end;
         // draw crosshair
@@ -524,7 +522,7 @@
         begin
         t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy;
         if (cTagsMask and htTransparent) <> 0 then
-            Tint($80FFFFFF);
+            Tint($FF, $FF, $FF, $80);
         if ((cTagsMask and htHealth) <> 0) then
             begin
             dec(t, HealthTagTex^.h + 2);
@@ -541,7 +539,7 @@
             DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex)
             end;
         if (cTagsMask and htTransparent) <> 0 then
-            Tint($FFFFFFFF)
+            Tint($FF, $FF, $FF, $FF)
         end;
     if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
         begin
@@ -557,7 +555,7 @@
 
 if HH^.Effects[hePoisoned] then
     begin
-    Tint($8040FF00);
+    Tint($40, $FF, $00, $80);
     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 37) mod 360);
     end;
 
@@ -573,7 +571,7 @@
     Tint($FF, $FF, $FF, max($40, floor($FF * abs(1 - (RealTicks mod 1500) / 750))));
     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
     end;
-    Tint($FFFFFFFF)
+    Tint($FF, $FF, $FF, $FF)
 end;
 
 procedure DrawGears;
@@ -673,7 +671,7 @@
           gtTarget: begin
                     Tint($FF, $FF, $FF, floor($FF * Gear^.Timer / 1000));
                     DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0);
-                    Tint($FFFFFFFF);
+                    Tint($FF, $FF, $FF, $FF);
                     end;
           gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
           gtCake: if Gear^.Pos = 6 then
@@ -717,16 +715,16 @@
     gtBigExplosion: begin
                     Tint($FF, $FF, $FF, floor($FF * (1 - power(Gear^.Timer / 250, 4))));
                     DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
-                    Tint($FFFFFFFF);
+                    Tint($FF, $FF, $FF, $FF);
                     end;
              gtEgg: DrawRotatedTextureF(SpritesData[sprEgg].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 16, 16, Gear^.DirAngle);
            gtPiano: begin
                     if (Gear^.State and gstDrowning) = 0 then
                         begin
-                        Tint($10FFFFFF);
+                        Tint($FF, $FF, $FF, $10);
                         for i:= 8 downto 1 do
                             DrawRotatedTextureF(SpritesData[sprPiano].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy - hwRound(Gear^.dY * 4 * i), 0, 1, 128, 128, 0);
-                        Tint($FFFFFFFF)
+                        Tint($FF, $FF, $FF, $FF)
                         end;
                     DrawRotatedTextureF(SpritesData[sprPiano].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 128, 128, 0);
                     end;
--- a/hedgewars/uChat.pas	Sat May 01 19:40:45 2010 +0000
+++ b/hedgewars/uChat.pas	Sat May 01 20:02:20 2010 +0000
@@ -126,9 +126,9 @@
     begin
     r.w:= InputStr.Width;
     DrawFillRect(r);
-    Tint($80000000);
+    Tint($00, $00, $00, $80);
     DrawTexture(9 - cScreenWidth div 2, visibleCount * 16 + 11, InputStr.Tex);
-    Tint($FFFFFFFF);
+    Tint($FF, $FF, $FF, $FF);
     DrawTexture(8 - cScreenWidth div 2, visibleCount * 16 + 10, InputStr.Tex);
     end;
 
@@ -145,9 +145,9 @@
     begin
     r.w:= Strs[i].Width;
     DrawFillRect(r);
-    Tint($80000000);
+    Tint($00, $00, $00, $80);
     DrawTexture(9 - cScreenWidth div 2, (visibleCount - t) * 16 - 5, Strs[i].Tex);
-    Tint($FFFFFFFF);
+    Tint($FF, $FF, $FF, $FF);
     DrawTexture(8 - cScreenWidth div 2, (visibleCount - t) * 16 - 6, Strs[i].Tex);
     dec(r.y, 16);
 
--- a/hedgewars/uGears.pas	Sat May 01 19:40:45 2010 +0000
+++ b/hedgewars/uGears.pas	Sat May 01 20:02:20 2010 +0000
@@ -958,12 +958,12 @@
 
     glLineWidth(4.0);
 
-    Tint($FFC0C0C0);
+    Tint($C0, $C0, $C0, $FF);
 
     glEnableClientState(GL_VERTEX_ARRAY);
     glVertexPointer(2, GL_FLOAT, 0, @RopePoints.rounded[0]);
     glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2);
-    Tint($FFFFFFFF);
+    Tint($FF, $FF, $FF, $FF);
 
     glPopMatrix;
 
--- a/hedgewars/uStore.pas	Sat May 01 19:40:45 2010 +0000
+++ b/hedgewars/uStore.pas	Sat May 01 20:02:20 2010 +0000
@@ -76,7 +76,6 @@
 procedure ShowWeaponTooltip(x, y: LongInt);
 procedure FreeWeaponTooltip;
 procedure Tint(r, g, b, a: Byte); inline;
-procedure Tint(c: Longword); inline;
 
 implementation
 uses uMisc, uConsole, uLand, uLocale, uWorld{$IFDEF IPHONEOS}, PascalExports{$ENDIF};
@@ -88,20 +87,6 @@
     cGPUVendor: TGPUVendor;
     lastTint: Longword;
 
-{$IFNDEF IPHONEOS}
-procedure Tint(r, g, b, a: Byte); inline;
-begin
-Tint((a shl 24) or (r shl 16) or (g shl 8) or b);
-end;
-
-procedure Tint(c: Longword); inline;
-begin
-if c = lastTint then
-    exit;
-glColor4ubv(@c);
-lastTint:= c;
-end;
-{$ELSE}
 procedure Tint(r, g, b, a: Byte); inline;
 var nc: Longword;
 begin
@@ -112,15 +97,6 @@
 lastTint:= nc;
 end;
 
-procedure Tint(c: Longword); inline;
-begin
-if c = lastTint then
-    exit;
-Tint((c shr 16) and $FF, (c shr 8) and $FF, c and $FF, (c shr 24) and $FF);
-lastTint:= c;
-end;
-{$ENDIF}
-
 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
 var r: TSDL_Rect;
 begin
@@ -799,7 +775,7 @@
 begin
 glDisable(GL_TEXTURE_2D);
 
-Tint($80000000);
+Tint($00, $00, $00, $80);
 
 VertexBuffer[0].X:= r.x;
 VertexBuffer[0].Y:= r.y;
@@ -815,7 +791,7 @@
 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
 glDisableClientState(GL_VERTEX_ARRAY);
 
-Tint($FFFFFFFF);
+Tint($FF, $FF, $FF, $FF);
 glEnable(GL_TEXTURE_2D)
 end;
 
--- a/hedgewars/uVisualGears.pas	Sat May 01 19:40:45 2010 +0000
+++ b/hedgewars/uVisualGears.pas	Sat May 01 20:02:20 2010 +0000
@@ -760,7 +760,7 @@
                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
                             DrawRotatedF(sprFeather, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
                             if Gear^.FrameTicks < 255 then
-                                Tint($FFFFFFFF);
+                                Tint($FF, $FF, $FF, $FF);
                             end;
                 end;
         Gear:= Gear^.NextGear
@@ -778,7 +778,7 @@
                         Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
                         DrawTextureF(ropeIconTex, Gear^.scale, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 32, 32);
                         DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
-                        Tint($FFFFFFFF);
+                        Tint($FF, $FF, $FF, $FF);
                         end;
                 vgtHealth:  begin
                             case Gear^.Frame div 10 of
@@ -786,21 +786,21 @@
                                 1:Tint($FF, 0, 0, floor(Gear^.FrameTicks * $FF / 1000));
                             end;
                             DrawSprite(sprHealth, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, 0);
-                            Tint($FFFFFFFF);
+                            Tint($FF, $FF, $FF, $FF);
                             end;
                 vgtShell: begin
                             if Gear^.FrameTicks < $FF then
                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
                             DrawRotatedF(sprShell, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
                             if Gear^.FrameTicks < $FF then
-                                Tint($FFFFFFFF);
+                                Tint($FF, $FF, $FF, $FF);
                             end;
                   vgtEgg: begin
                             if Gear^.FrameTicks < $FF then
                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
                             DrawRotatedF(sprEgg, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
                             if Gear^.FrameTicks < $FF then
-                                Tint($FFFFFFFF);
+                                Tint($FF, $FF, $FF, $FF);
                             end;
                 vgtSplash: DrawSprite(sprSplash, hwRound(Gear^.X) + WorldDx - 40, hwRound(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
                 vgtDroplet: DrawSprite(sprDroplet, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);
@@ -808,14 +808,14 @@
                             if Gear^.FrameTicks < $FF then
                                 Tint($FF, $FF, $FF, Gear^.FrameTicks div 2)
                             else
-                                Tint($80FFFFFF);
+                                Tint($FF, $FF, $FF, $80);
                             DrawRotatedF(sprBeeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
-                            Tint($FFFFFFFF);
+                            Tint($FF, $FF, $FF, $FF);
                             end;
                 vgtSmokeRing: begin
                             Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
                             DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
-                            Tint($FFFFFFFF);
+                            Tint($FF, $FF, $FF, $FF);
                             end;
             end;
         case Gear^.Kind of
--- a/hedgewars/uWorld.pas	Sat May 01 19:40:45 2010 +0000
+++ b/hedgewars/uWorld.pas	Sat May 01 20:02:20 2010 +0000
@@ -380,7 +380,7 @@
 
 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 glDisableClientState(GL_VERTEX_ARRAY);
-Tint($FFFFFFFF);
+Tint($FF, $FF, $FF, $FF);
 
 {for i:= -1 to cWaterSprCount do
     DrawSprite(sprWater,
@@ -652,7 +652,7 @@
       highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
       
       if highlight then
-         Tint(Clan^.Color);
+         Tint(((Clan^.Color shr 16) and $FF), ((Clan^.Color shr 8) and $FF), (Clan^.Color and $FF), $FF);
 
       // draw name
       DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY, NameTagTex);
@@ -675,7 +675,7 @@
       // this approach should be faster than drawing all borders one by one tinted or not
       if highlight then
          begin
-         Tint($FFFFFFFF);
+         Tint($FF, $FF, $FF, $FF);
 
          // draw name
          r.x:= 2;
@@ -845,7 +845,7 @@
         glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
         glDisableClientState(GL_VERTEX_ARRAY);
         glEnable(GL_TEXTURE_2D);
-        Tint($FFFFFFFF);
+        Tint($FF, $FF, $FF, $FF);
         if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone
         end
     end;