hedgewars/uWorld.pas
changeset 10330 3ec09243cb55
parent 10325 7315870716f2
child 10331 cb6c33839d2a
--- a/hedgewars/uWorld.pas	Wed Jun 18 17:23:43 2014 +0200
+++ b/hedgewars/uWorld.pas	Wed Jun 18 23:57:51 2014 +0200
@@ -66,7 +66,7 @@
 {$ENDIF}
     ;
 
-var cWaveWidth, cWaveHeight: LongInt;
+var cWaveWidth: LongInt;
     AMShiftTargetX, AMShiftTargetY, AMShiftX, AMShiftY, SlotsNum: LongInt;
     AMAnimStartTime, AMState : LongInt;
     AMAnimState: Single;
@@ -790,185 +790,6 @@
 {$ENDIF}
 end;
 
-procedure DrawWaves(Dir, dX, dY, oX: LongInt; tnt: Byte);
-var VertexBuffer, TextureBuffer: array [0..7] of TVertex2f;
-    lw, waves, shift: GLfloat;
-    sprite: TSprite;
-    topy: LongInt;
-begin
-
-dY:= -cWaveHeight + dy;
-ox:= -cWaveHeight + ox;
-
-topy:= cWaterLine + WorldDy + dY;
-
-if (WorldEdge <> weSea) and (topY > ViewBottomY) then
-    exit;
-
-if SuddenDeathDmg then
-    sprite:= sprSDWater
-else
-    sprite:= sprWater;
-
-cWaveWidth:= SpritesData[sprite].Width;
-
-if WorldEdge = weSea then
-    lw:= playWidth div 2
-else
-    lw:= ViewWidth;
-
-if SuddenDeathDmg then
-    Tint(LongInt(tnt) * SDWaterColorArray[2].r div 255 + 255 - tnt,
-         LongInt(tnt) * SDWaterColorArray[2].g div 255 + 255 - tnt,
-         LongInt(tnt) * SDWaterColorArray[2].b div 255 + 255 - tnt,
-         255
-    )
-else
-    Tint(LongInt(tnt) * WaterColorArray[2].r div 255 + 255 - tnt,
-         LongInt(tnt) * WaterColorArray[2].g div 255 + 255 - tnt,
-         LongInt(tnt) * WaterColorArray[2].b div 255 + 255 - tnt,
-         255
-    );
-
-glBindTexture(GL_TEXTURE_2D, SpritesData[sprite].Texture^.id);
-
-if WorldEdge <> weSea then
-    begin
-    if topY < ViewBottomY then
-        begin
-        VertexBuffer[0].X:= -lw;
-        VertexBuffer[0].Y:= cWaterLine + WorldDy + dY;
-        VertexBuffer[1].X:= lw;
-        VertexBuffer[1].Y:= VertexBuffer[0].Y;
-        VertexBuffer[2].X:= lw;
-        VertexBuffer[2].Y:= VertexBuffer[0].Y + SpritesData[sprite].Height;
-        VertexBuffer[3].X:= -lw;
-        VertexBuffer[3].Y:= VertexBuffer[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);
-
-        {$IFDEF GL2}
-        UpdateModelviewProjection;
-        {$ENDIF}
-
-        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-        end;
-    end
-else // weSea: with waterwalls
-    begin
-    topy := cWaterLine + WorldDy;
-
-    // We will draw both bottom water and the water walls with a single call,
-    // by rendering a GL_TRIANGLE_STRIP of eight points.
-    //
-    // GL_TRIANGLE_STRIP works like this: "always create triangle between
-    // newest point and the two points that were specified before it."
-    //
-    // To get the result we want we will order the points like this:
-    //                                                                  ^ -Y
-    //                                                                  |
-    //   0-------1         7-------6  <---------------------- ViewTopY -|
-    //   |      /|         |     _/|                                    |
-    //   |     / |         |    /  |                                    |
-    //   |    /  |         |  _/   |                                    |
-    //   |   /   |         | /     |                                    |
-    //   |  /  _.3---------5{      |  <--- topy = cWaterLine + WorldDy -|
-    //   | / _/   `---.___   `--._ |                                    |
-    //   |/_/             `---.___\|                                    |
-    //   2-------------------------4  <------------ topy + wave height -|
-    //                                                                  |
-    //   ^       ^         ^       ^                                    V +Y
-    //   |       |         |       |
-    //   |       |         |     RightX + WorldDx + wave height
-    //   |       |         |       .
-    //   |       | RightX + WorldDx.
-    //   |       |         .       .
-    //   | LeftX + WorldDx .       .
-    //   |       .         .       .
-    // LeftX - wave height + WorldDx
-    //   |       .         .       .
-    // <-------------------------------->
-    // -X                              +X
-    //
-    // Note: additionally the parameters ox and dy are used to create different
-    // horizontal and vertical offsets between wave layers
-
-
-    VertexBuffer[0].X:= LeftX + WorldDx - SpritesData[sprite].Height - ox;
-    VertexBuffer[0].Y:= ViewTopY;
-    VertexBuffer[1].X:= LeftX + WorldDx - ox;
-    VertexBuffer[1].Y:= ViewTopY;
-    VertexBuffer[2].X:= VertexBuffer[0].X;
-    VertexBuffer[2].Y:= topy + SpritesData[sprite].Height + dy;
-    VertexBuffer[3].X:= VertexBuffer[1].X;
-    VertexBuffer[3].Y:= topy + dy;
-    VertexBuffer[4].X:= RightX + WorldDx + SpritesData[sprite].Height + ox;
-    VertexBuffer[4].Y:= topy + SpritesData[sprite].Height + dy;
-    VertexBuffer[5].X:= RightX + WorldDx + ox;
-    VertexBuffer[5].Y:= topy + dy;
-    VertexBuffer[6].X:= VertexBuffer[4].X;
-    VertexBuffer[6].Y:= ViewTopY;
-    VertexBuffer[7].X:= VertexBuffer[5].X;
-    VertexBuffer[7].Y:= ViewTopY;
-
-    waves:= 2 * lw / cWaveWidth;
-    shift:= - lw / cWaveWidth;
-    TextureBuffer[3].X:= shift + ((LongInt(RealTicks shr 6) * Dir + ox) mod cWaveWidth) / (cWaveWidth - 1);
-    TextureBuffer[3].Y:= 0;
-    TextureBuffer[5].X:= TextureBuffer[3].X + waves;
-    TextureBuffer[5].Y:= 0;
-    TextureBuffer[4].X:= TextureBuffer[5].X;
-    TextureBuffer[4].Y:= SpritesData[sprite].Texture^.ry;
-    TextureBuffer[2].X:= TextureBuffer[3].X;
-    TextureBuffer[2].Y:= SpritesData[sprite].Texture^.ry;
-
-    waves:= (topy + dy - ViewTopY) / cWaveWidth;
-
-    // left side
-    TextureBuffer[1].X:= TextureBuffer[3].X - waves;
-    TextureBuffer[1].Y:= 0;
-    TextureBuffer[0].X:= TextureBuffer[1].X;
-    TextureBuffer[0].Y:= SpritesData[sprite].Texture^.ry;
-
-    // right side
-    TextureBuffer[7].X:= TextureBuffer[5].X + waves;
-    TextureBuffer[7].Y:= 0;
-    TextureBuffer[6].X:= TextureBuffer[7].X;
-    TextureBuffer[6].Y:= SpritesData[sprite].Texture^.ry;
-
-
-    SetVertexPointer(@VertexBuffer[0], 8);
-    SetTexCoordPointer(@TextureBuffer[0], 8);
-
-    {$IFDEF GL2}
-    UpdateModelviewProjection;
-    {$ENDIF}
-
-    glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);
-    end;
-
-untint;
-
-{for i:= -1 to cWaterSprCount do
-    DrawSprite(sprWater,
-        i * cWaveWidth + ((WorldDx + (RealTicks shr 6) * Dir + dX) mod cWaveWidth) - (cScreenWidth div 2),
-        cWaterLine + WorldDy + dY,
-        0)}
-end;
-
 procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt);
 var i, w, h, lw, lh, rw, rh, sw: LongInt;
 begin