--- a/hedgewars/uLand.pas Fri Jan 30 14:57:02 2009 +0000
+++ b/hedgewars/uLand.pas Fri Jan 30 14:59:59 2009 +0000
@@ -38,6 +38,7 @@
function GenPreview: TPreview;
procedure CheckLandDigest(s: shortstring);
procedure UpdateLandTexture(Y, Height: LongInt);
+procedure RealLandTexUpdate;
implementation
uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, uSHA, uIO;
@@ -47,6 +48,9 @@
ar: array[0..Pred(cMaxEdgePoints)] of TPoint;
end;
+var updTopY: LongInt = LAND_HEIGHT;
+ updBottomY: LongInt = 0;
+
procedure LogLandDigest;
var ctx: TSHA1Context;
dig: TSHA1Digest;
@@ -730,15 +734,27 @@
TryDo((Y >= 0) and (Y < LAND_HEIGHT), 'UpdateLandTexture: wrong Y parameter', true);
TryDo(Y + Height <= LAND_HEIGHT, 'UpdateLandTexture: wrong Height parameter', true);
+if Y < updTopY then updTopY:= Y;
+if Y + Height > updBottomY then updBottomY:= Y + Height
+end;
+
+procedure RealLandTexUpdate;
+begin
+if updBottomY = 0 then exit;
+
if LandTexture = nil then
LandTexture:= NewTexture(LAND_WIDTH, LAND_HEIGHT, @LandPixels)
else
begin
glBindTexture(GL_TEXTURE_2D, LandTexture^.id);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, Y, LAND_WIDTH, Height, GL_RGBA, GL_UNSIGNED_BYTE, @LandPixels[Y, 0]);
- end
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, updTopY, LAND_WIDTH, updBottomY - updTopY, GL_RGBA, GL_UNSIGNED_BYTE, @LandPixels[updTopY, 0]);
+ end;
+
+updTopY:= LAND_HEIGHT + 1;
+updBottomY:= 0
end;
+
initialization
end.