fix some (newly introduces) glitches with normal water
authorsheepluva
Tue, 17 Jun 2014 16:10:43 +0200
changeset 10320 0f9ad60f738c
parent 10319 240775460dc5
child 10321 863663e1b3fd
fix some (newly introduces) glitches with normal water
hedgewars/uWorld.pas
--- a/hedgewars/uWorld.pas	Tue Jun 17 15:39:29 2014 +0200
+++ b/hedgewars/uWorld.pas	Tue Jun 17 16:10:43 2014 +0200
@@ -791,9 +791,10 @@
 end;
 
 procedure DrawWater(Alpha: byte; OffsetY, OffsetX: LongInt);
-var VertexBuffer : array [0..4] of TVertex2f;
+var VertexBuffer : array [0..3] of TVertex2f;
     topy, lx, rx: LongInt;
 begin
+
     // Water
 topy:= OffsetY + WorldDy + cWaterLine;
 
@@ -939,28 +940,28 @@
         VertexBuffer[2].Y:= VertexBuffer[0].Y + SpritesData[sprite].Height;
         VertexBuffer[3].X:= -lw;
         VertexBuffer[3].Y:= VertexBuffer[2].Y;
-        end;
 
-    waves:= lw * 2 / cWaveWidth;
-    shift:= - lw / cWaveWidth;
-    TextureBuffer[0].X:= shift + (( - WorldDx + LongInt(RealTicks shr 6) * Dir + dX) mod cWaveWidth) / (cWaveWidth - 1);
-    TextureBuffer[0].Y:= 0;
-    TextureBuffer[1].X:= TextureBuffer[0].X + waves;
-    TextureBuffer[1].Y:= TextureBuffer[0].Y;
-    TextureBuffer[2].X:= TextureBuffer[1].X;
-    TextureBuffer[2].Y:= SpritesData[sprite].Texture^.ry;
-    TextureBuffer[3].X:= TextureBuffer[0].X;
-    TextureBuffer[3].Y:= TextureBuffer[2].Y;
+        waves:= lw * 2 / cWaveWidth;
+        shift:= - lw / cWaveWidth;
+        TextureBuffer[0].X:= shift + (( - WorldDx + LongInt(RealTicks shr 6) * Dir + dX) mod cWaveWidth) / (cWaveWidth - 1);
+        TextureBuffer[0].Y:= 0;
+        TextureBuffer[1].X:= TextureBuffer[0].X + waves;
+        TextureBuffer[1].Y:= TextureBuffer[0].Y;
+        TextureBuffer[2].X:= TextureBuffer[1].X;
+        TextureBuffer[2].Y:= SpritesData[sprite].Texture^.ry;
+        TextureBuffer[3].X:= TextureBuffer[0].X;
+        TextureBuffer[3].Y:= TextureBuffer[2].Y;
 
 
-    SetVertexPointer(@VertexBuffer[0], 4);
-    SetTexCoordPointer(@TextureBuffer[0],4);
+        SetVertexPointer(@VertexBuffer[0], 4);
+        SetTexCoordPointer(@TextureBuffer[0], 4);
 
-    {$IFDEF GL2}
-    UpdateModelviewProjection;
-    {$ENDIF}
+        {$IFDEF GL2}
+        UpdateModelviewProjection;
+        {$ENDIF}
 
-    glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
+        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+        end;
     end
 else // weSea: with waterwalls
     begin