hedgewars/uWorld.pas
changeset 10321 863663e1b3fd
parent 10320 0f9ad60f738c
child 10322 6f1f8515181c
--- a/hedgewars/uWorld.pas	Tue Jun 17 16:10:43 2014 +0200
+++ b/hedgewars/uWorld.pas	Tue Jun 17 20:09:11 2014 +0200
@@ -967,7 +967,41 @@
     begin
     topy := cWaterLine + WorldDy;
 
-    // for GL_TRIANGLE_STRIP
+    // 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;