hedgewars/uLandTexture.pas
changeset 3697 d5b30d6373fc
parent 3666 f9c8fc74ac93
child 4357 a1fcfc341a52
equal deleted inserted replaced
3695:c11abf387a7d 3697:d5b30d6373fc
    40 
    40 
    41 var LandTextures: array of array of TLandRecord;
    41 var LandTextures: array of array of TLandRecord;
    42     tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord;
    42     tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord;
    43     LANDTEXARW: LongWord;
    43     LANDTEXARW: LongWord;
    44     LANDTEXARH: LongWord;
    44     LANDTEXARH: LongWord;
    45     
    45 
    46 function Pixels(x, y: Longword): Pointer;
    46 function Pixels(x, y: Longword): Pointer;
    47 var ty: Longword;
    47 var ty: Longword;
    48 begin
    48 begin
    49 for ty:= 0 to TEXSIZE - 1 do
    49 for ty:= 0 to TEXSIZE - 1 do
    50     Move(LandPixels[y * TEXSIZE + ty, x * TEXSIZE], tmpPixels[ty, 0], sizeof(Longword) * TEXSIZE);
    50     Move(LandPixels[y * TEXSIZE + ty, x * TEXSIZE], tmpPixels[ty, 0], sizeof(Longword) * TEXSIZE);
    99             with LandTextures[x, y] do
    99             with LandTextures[x, y] do
   100                 if shouldUpdate then
   100                 if shouldUpdate then
   101                     begin
   101                     begin
   102                     shouldUpdate:= false;
   102                     shouldUpdate:= false;
   103                     glBindTexture(GL_TEXTURE_2D, tex^.id);
   103                     glBindTexture(GL_TEXTURE_2D, tex^.id);
   104                     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXSIZE, TEXSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x,y)); 
   104                     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXSIZE, TEXSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x,y));
   105                     end
   105                     end
   106 end;
   106 end;
   107 
   107 
   108 procedure DrawLand(dX, dY: LongInt);
   108 procedure DrawLand(dX, dY: LongInt);
   109 var x, y: LongInt;
   109 var x, y: LongInt;
   130     else
   130     else
   131     begin
   131     begin
   132         LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2;
   132         LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2;
   133         LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2;
   133         LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2;
   134     end;
   134     end;
   135     
   135 
   136     SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
   136     SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
   137 end;
   137 end;
   138     
   138 
   139 procedure freeModule;
   139 procedure freeModule;
   140 var x, y: LongInt;
   140 var x, y: LongInt;
   141 begin
   141 begin
   142     for x:= 0 to LANDTEXARW -1 do
   142     for x:= 0 to LANDTEXARW -1 do
   143         for y:= 0 to LANDTEXARH - 1 do
   143         for y:= 0 to LANDTEXARH - 1 do