hedgewars/uLand.pas
changeset 767 697728ffe39f
parent 766 cdc8f75ab7bc
child 768 2886dafa5bcf
--- a/hedgewars/uLand.pas	Sun Jan 27 17:27:13 2008 +0000
+++ b/hedgewars/uLand.pas	Sun Jan 27 18:39:02 2008 +0000
@@ -30,7 +30,7 @@
 procedure GenMap;
 function  GenPreview: TPreview;
 procedure CheckLandDigest(s: shortstring);
-procedure UpdateLandTexture;
+procedure UpdateLandTexture(Y, Height: LongInt);
 
 implementation
 uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, uSHA, uIO;
@@ -533,7 +533,7 @@
 AddObjects(tmpsurf, LandSurface);
 SDL_FreeSurface(tmpsurf);
 
-UpdateLandTexture;
+UpdateLandTexture(0, 1024);
 AddProgress
 end;
 
@@ -555,7 +555,7 @@
 BlitImageAndGenerateCollisionInfo(1024, 0, tmpsurf, LandSurface);
 SDL_FreeSurface(tmpsurf);
 
-UpdateLandTexture
+UpdateLandTexture(0, 1024)
 end;
 
 procedure LoadMap;
@@ -593,7 +593,7 @@
 if SDL_MustLock(LandSurface) then
    SDL_UnlockSurface(LandSurface);
 
-UpdateLandTexture
+UpdateLandTexture(0, 1024)
 end;
 
 procedure GenMap;
@@ -629,10 +629,23 @@
 GenPreview:= Preview
 end;
 
-procedure UpdateLandTexture;
+procedure UpdateLandTexture(Y, Height: LongInt);
+var p: pointer;
 begin
-if LandTexture <> nil then FreeTexture(LandTexture);
-LandTexture:= Surface2Tex(LandSurface)
+if LandTexture <> nil then
+   begin
+   if SDL_MustLock(LandSurface) then
+      SDLTry(SDL_LockSurface(LandSurface) >= 0, true);
+
+   glBindTexture(GL_TEXTURE_2D, LandTexture^.id);
+
+   p:= @PByteArray(LandSurface^.pixels)^[LandSurface^.pitch * Y];
+   glTexSubImage2D(GL_TEXTURE_2D, 0, 0, Y, 2048, Height, GL_RGBA, GL_UNSIGNED_BYTE, p);
+
+   if SDL_MustLock(LandSurface) then
+      SDL_UnlockSurface(LandSurface);
+   end else
+   LandTexture:= Surface2Tex(LandSurface)
 end;
 
 initialization