hedgewars/uLandTexture.pas
changeset 3612 b50215a8a43d
parent 3595 341e407e3754
child 3615 b78d7959540a
equal deleted inserted replaced
3611:ed00aa2b339e 3612:b50215a8a43d
    20 
    20 
    21 unit uLandTexture;
    21 unit uLandTexture;
    22 interface
    22 interface
    23 uses SDLh;
    23 uses SDLh;
    24 
    24 
       
    25 procedure initModule;
       
    26 procedure freeModule;
    25 procedure UpdateLandTexture(X, Width, Y, Height: LongInt);
    27 procedure UpdateLandTexture(X, Width, Y, Height: LongInt);
    26 procedure DrawLand(dX, dY: LongInt);
    28 procedure DrawLand(dX, dY: LongInt);
    27 procedure FreeLand;
    29 procedure FreeLand;
    28 
    30 
    29 implementation
    31 implementation
    30 uses uMisc, uLand, uStore, uConsts, GLunit;
    32 uses uMisc, uLand, uStore, uConsts, GLunit;
    31 
    33 
    32 
    34 
    33 const TEXSIZE = 256;
    35 const TEXSIZE = 256;
    34 {$IFDEF DOWNSCALE}
       
    35     LANDTEXARW = (LAND_WIDTH div TEXSIZE) div 2;
       
    36     LANDTEXARH = (LAND_HEIGHT div TEXSIZE) div 2;
       
    37 {$ELSE}
       
    38     LANDTEXARW = LAND_WIDTH div TEXSIZE;
       
    39     LANDTEXARH = LAND_HEIGHT div TEXSIZE;
       
    40 {$ENDIF}
       
    41 
    36 
    42 var
    37 type TLandRecord = record
    43     LandTextures: array[0..LANDTEXARW - 1, 0..LANDTEXARH - 1] of
       
    44             record
       
    45             shouldUpdate: boolean;
    38             shouldUpdate: boolean;
    46             tex: PTexture;
    39             tex: PTexture;
    47             end;
    40             end;
    48 
    41 var LandTextures: array of array of TLandRecord;
    49     tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord;
    42     tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord;
    50 
    43 LANDTEXARW: LongWord;
       
    44     LANDTEXARH: LongWord;
    51 function Pixels(x, y: Longword): Pointer;
    45 function Pixels(x, y: Longword): Pointer;
    52 var ty: Longword;
    46 var ty: Longword;
    53 begin
    47 begin
    54 for ty:= 0 to TEXSIZE - 1 do
    48 for ty:= 0 to TEXSIZE - 1 do
    55     Move(LandPixels[y * TEXSIZE + ty, x * TEXSIZE], tmpPixels[ty, 0], sizeof(Longword) * TEXSIZE);
    49     Move(LandPixels[y * TEXSIZE + ty, x * TEXSIZE], tmpPixels[ty, 0], sizeof(Longword) * TEXSIZE);
   133             with LandTextures[x, y] do
   127             with LandTextures[x, y] do
   134             begin
   128             begin
   135                 FreeTexture(tex);
   129                 FreeTexture(tex);
   136                 tex:= nil;
   130                 tex:= nil;
   137             end;
   131             end;
   138 
       
   139     if LandBackSurface <> nil then
   132     if LandBackSurface <> nil then
   140         SDL_FreeSurface(LandBackSurface);
   133         SDL_FreeSurface(LandBackSurface);
   141     LandBackSurface:= nil;
   134     LandBackSurface:= nil;
   142 end;
   135 end;
   143 
   136 
       
   137 procedure initModule;
       
   138 begin
       
   139     if (cReducedQuality and rqBlurryLand) = 0 then
       
   140     begin
       
   141         LANDTEXARW:= LAND_WIDTH div TEXSIZE;
       
   142         LANDTEXARH:= LAND_HEIGHT div TEXSIZE;
       
   143     end
       
   144     else
       
   145     begin
       
   146         LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2;
       
   147         LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2;
       
   148     end;
       
   149     
       
   150     SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
       
   151 end;
       
   152     
       
   153 procedure freeModule;
       
   154 begin
       
   155     LandTextures:= nil;
       
   156 end;
   144 end.
   157 end.