diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uLandTexture.pas --- a/hedgewars/uLandTexture.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uLandTexture.pas Sat Mar 06 10:59:20 2010 +0000 @@ -29,30 +29,30 @@ implementation uses uMisc, uLand, uStore, uConsts, {$IFDEF GLES11} - gles11; + gles11; {$ELSE} - GL; + GL; {$ENDIF} const TEXSIZE = 256; - LANDTEXARW = LAND_WIDTH div TEXSIZE; - LANDTEXARH = LAND_HEIGHT div TEXSIZE; + LANDTEXARW = LAND_WIDTH div TEXSIZE; + LANDTEXARH = LAND_HEIGHT div TEXSIZE; var - LandTextures: array[0..LANDTEXARW - 1, 0..LANDTEXARH - 1] of - record - shouldUpdate: boolean; - tex: PTexture; - end; + LandTextures: array[0..LANDTEXARW - 1, 0..LANDTEXARH - 1] of + record + shouldUpdate: boolean; + tex: PTexture; + end; - tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord; + tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord; function Pixels(x, y: Longword): Pointer; var ty: Longword; begin for ty:= 0 to TEXSIZE - 1 do - Move(LandPixels[y * TEXSIZE + ty, x * TEXSIZE], tmpPixels[ty, 0], sizeof(Longword) * TEXSIZE); + Move(LandPixels[y * TEXSIZE + ty, x * TEXSIZE], tmpPixels[ty, 0], sizeof(Longword) * TEXSIZE); Pixels:= @tmpPixels end; @@ -61,8 +61,8 @@ var tx, ty: Longword; begin for ty:= 0 to TEXSIZE - 1 do - for tx:= 0 to TEXSIZE - 1 do - tmpPixels[ty, tx]:= Land[y * TEXSIZE + ty, x * TEXSIZE + tx] or AMask; + for tx:= 0 to TEXSIZE - 1 do + tmpPixels[ty, tx]:= Land[y * TEXSIZE + ty, x * TEXSIZE + tx] or AMask; Pixels2:= @tmpPixels end; @@ -77,28 +77,28 @@ TryDo(Y + Height <= LAND_HEIGHT, 'UpdateLandTexture: wrong Height parameter', true); for ty:= Y div TEXSIZE to (Y + Height - 1) div TEXSIZE do - for tx:= X div TEXSIZE to (X + Width - 1) div TEXSIZE do - LandTextures[tx, ty].shouldUpdate:= true + for tx:= X div TEXSIZE to (X + Width - 1) div TEXSIZE do + LandTextures[tx, ty].shouldUpdate:= true end; procedure RealLandTexUpdate; var x, y: LongWord; begin if LandTextures[0, 0].tex = nil then - for x:= 0 to LANDTEXARW -1 do - for y:= 0 to LANDTEXARH - 1 do - with LandTextures[x, y] do - tex:= NewTexture(TEXSIZE, TEXSIZE, Pixels(x, y)) + for x:= 0 to LANDTEXARW -1 do + for y:= 0 to LANDTEXARH - 1 do + with LandTextures[x, y] do + tex:= NewTexture(TEXSIZE, TEXSIZE, Pixels(x, y)) else - for x:= 0 to LANDTEXARW -1 do - for y:= 0 to LANDTEXARH - 1 do - with LandTextures[x, y] do - if shouldUpdate then - begin - shouldUpdate:= false; - glBindTexture(GL_TEXTURE_2D, tex^.id); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEXSIZE, TEXSIZE, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x, y)); - end + for x:= 0 to LANDTEXARW -1 do + for y:= 0 to LANDTEXARH - 1 do + with LandTextures[x, y] do + if shouldUpdate then + begin + shouldUpdate:= false; + glBindTexture(GL_TEXTURE_2D, tex^.id); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEXSIZE, TEXSIZE, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x, y)); + end end; procedure DrawLand(dX, dY: LongInt); @@ -107,21 +107,21 @@ RealLandTexUpdate; for x:= 0 to LANDTEXARW -1 do - for y:= 0 to LANDTEXARH - 1 do - with LandTextures[x, y] do - DrawTexture(dX + x * TEXSIZE, dY + y * TEXSIZE, tex) + for y:= 0 to LANDTEXARH - 1 do + with LandTextures[x, y] do + DrawTexture(dX + x * TEXSIZE, dY + y * TEXSIZE, tex) end; procedure FreeLand; var x, y: LongInt; begin - for x:= 0 to LANDTEXARW -1 do - for y:= 0 to LANDTEXARH - 1 do - with LandTextures[x, y] do - begin - FreeTexture(tex); - tex:= nil; - end; + for x:= 0 to LANDTEXARW -1 do + for y:= 0 to LANDTEXARH - 1 do + with LandTextures[x, y] do + begin + FreeTexture(tex); + tex:= nil; + end; end; end.