hedgewars/uLandTexture.pas
changeset 5654 1cb68f420aa6
parent 4976 088d40d8aba2
child 6380 1ff5ad1d771b
equal deleted inserted replaced
5653:fa58dea8a9ad 5654:1cb68f420aa6
    24 
    24 
    25 procedure initModule;
    25 procedure initModule;
    26 procedure freeModule;
    26 procedure freeModule;
    27 procedure UpdateLandTexture(X, Width, Y, Height: LongInt);
    27 procedure UpdateLandTexture(X, Width, Y, Height: LongInt);
    28 procedure DrawLand(dX, dY: LongInt);
    28 procedure DrawLand(dX, dY: LongInt);
       
    29 procedure ResetLand;
    29 
    30 
    30 implementation
    31 implementation
    31 uses uConsts, GLunit, uTypes, uVariables, uTextures, uDebug, uRender;
    32 uses uConsts, GLunit, uTypes, uVariables, uTextures, uDebug, uRender;
    32 
    33 
    33 const TEXSIZE = 256;
    34 const TEXSIZE = 256;
   120 end;
   121 end;
   121 
   122 
   122 procedure initModule;
   123 procedure initModule;
   123 begin
   124 begin
   124     if (cReducedQuality and rqBlurryLand) = 0 then
   125     if (cReducedQuality and rqBlurryLand) = 0 then
   125     begin
   126         begin
   126         LANDTEXARW:= LAND_WIDTH div TEXSIZE;
   127         LANDTEXARW:= LAND_WIDTH div TEXSIZE;
   127         LANDTEXARH:= LAND_HEIGHT div TEXSIZE;
   128         LANDTEXARH:= LAND_HEIGHT div TEXSIZE;
   128     end
   129         end
   129     else
   130     else
   130     begin
   131         begin
   131         LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2;
   132         LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2;
   132         LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2;
   133         LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2;
   133     end;
   134         end;
   134 
   135 
   135     SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
   136     SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
   136 end;
   137 end;
   137 
   138 
   138 procedure freeModule;
   139 procedure ResetLand;
   139 var x, y: LongInt;
   140 var x, y: LongInt;
   140 begin
   141 begin
   141     for x:= 0 to LANDTEXARW -1 do
   142     for x:= 0 to LANDTEXARW -1 do
   142         for y:= 0 to LANDTEXARH - 1 do
   143         for y:= 0 to LANDTEXARH - 1 do
   143             with LandTextures[x, y] do
   144             with LandTextures[x, y] do
   144             begin
   145                 begin
   145                 FreeTexture(tex);
   146                 if tex <> nil then FreeTexture(tex);
   146                 tex:= nil;
   147                 tex:= nil;
   147             end;
   148                 end;
       
   149 end;
       
   150 
       
   151 procedure freeModule;
       
   152 begin
       
   153     ResetLand;
   148     if LandBackSurface <> nil then
   154     if LandBackSurface <> nil then
   149         SDL_FreeSurface(LandBackSurface);
   155         SDL_FreeSurface(LandBackSurface);
   150     LandBackSurface:= nil;
   156     LandBackSurface:= nil;
   151     LandTextures:= nil;
   157     LandTextures:= nil;
   152 end;
   158 end;