# HG changeset patch # User unc0rr # Date 1237755382 0 # Node ID 6283bd8a960b793d38fb5a9cd92f5c0ef5d0ecee # Parent ae0addb057910bcefe8d71baf26169442469b936 use glVertexPointer to render water diff -r ae0addb05791 -r 6283bd8a960b hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Sun Mar 22 17:44:00 2009 +0000 +++ b/hedgewars/uLandObjects.pas Sun Mar 22 20:56:22 2009 +0000 @@ -371,8 +371,10 @@ Readln(f, c1.r, c1.g, c1. b); Readln(f, c2.r, c2.g, c2. b); // read water gradient colors -Readln(f, WaterColor.r, WaterColor.g, WaterColor. b); -Readln(f, DeepWaterColor.r, DeepWaterColor.g, DeepWaterColor. b); +Readln(f, WaterColorArray[0].r, WaterColorArray[0].g, WaterColorArray[0]. b); +Readln(f, WaterColorArray[2].r, WaterColorArray[2].g, WaterColorArray[2]. b); +WaterColorArray[1]:= WaterColorArray[0]; +WaterColorArray[3]:= WaterColorArray[2]; glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99); // sky color cExplosionBorderColor:= c2.value or $FF000000; diff -r ae0addb05791 -r 6283bd8a960b hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Sun Mar 22 17:44:00 2009 +0000 +++ b/hedgewars/uMisc.pas Sun Mar 22 20:56:22 2009 +0000 @@ -114,6 +114,12 @@ AttackBar: LongInt = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP +type HwColor3f = record + r, g, b: byte + end; + +var WaterColorArray: array[0..3] of HwColor3f; + function hwSign(r: hwFloat): LongInt; function Min(a, b: LongInt): LongInt; function Max(a, b: LongInt): LongInt; diff -r ae0addb05791 -r 6283bd8a960b hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sun Mar 22 17:44:00 2009 +0000 +++ b/hedgewars/uWorld.pas Sun Mar 22 20:56:22 2009 +0000 @@ -184,6 +184,7 @@ tdx, tdy: Double; grp: TCapGroup; s: string[15]; + VertexBuffer: array [0..3] of TVertex2f; procedure DrawRepeated(spr: TSprite; Shift: LongInt); var i, w: LongInt; @@ -227,21 +228,33 @@ // Water r.y:= WorldDy + cWaterLine + 32; if r.y < cScreenHeight then - begin - if r.y < 0 then r.y:= 0; + begin + if r.y < 0 then r.y:= 0; + + glDisable(GL_TEXTURE_2D); + VertexBuffer[0].X:= 0; + VertexBuffer[0].Y:= r.y; + VertexBuffer[1].X:= cScreenWidth; + VertexBuffer[1].Y:= r.y; + VertexBuffer[2].X:= cScreenWidth; + VertexBuffer[2].Y:= cScreenHeight; + VertexBuffer[3].X:= 0; + VertexBuffer[3].Y:= cScreenHeight; - glDisable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - glColor3ub(WaterColor.r, WaterColor.g, WaterColor. b); // water color - glVertex2i(0, r.y); - glVertex2i(cScreenWidth, r.y); - glColor3ub(DeepWaterColor.r, DeepWaterColor.g, DeepWaterColor. b); // deep water color - glVertex2i(cScreenWidth, cScreenHeight); - glVertex2i(0, cScreenHeight); - glEnd(); - glColor4f(1, 1, 1, 1); // disable coloring - glEnable(GL_TEXTURE_2D) - end; + glEnableClientState (GL_COLOR_ARRAY); + glColorPointer(3, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); + + glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); + + glEnableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + + glColor4f(1, 1, 1, 1); // disable coloring + glEnable(GL_TEXTURE_2D) + end; // Attack bar if CurrentTeam <> nil then