hedgewars/uLand.pas
changeset 753 40fc0deb388f
parent 700 be4847674071
child 754 94ac14829085
equal deleted inserted replaced
752:69f1dc50a1fa 753:40fc0deb388f
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  *)
    17  *)
    18 
    18 
    19 unit uLand;
    19 unit uLand;
    20 interface
    20 interface
    21 uses SDLh, uLandTemplates, uFloat;
    21 uses SDLh, uLandTemplates, uFloat, GL;
    22 {$include options.inc}
    22 {$include options.inc}
    23 type TLandArray = packed array[0..1023, 0..2047] of LongWord;
    23 type TLandArray = packed array[0..1023, 0..2047] of LongWord;
    24      TPreview = packed array[0..127, 0..31] of byte;
    24      TPreview = packed array[0..127, 0..31] of byte;
    25 
    25 
    26 var  Land: TLandArray;
    26 var  Land: TLandArray;
    27      LandSurface: PSDL_Surface;
    27      LandSurface: PSDL_Surface;
       
    28      LandTexture: GLuint;
    28 
    29 
    29 procedure GenMap;
    30 procedure GenMap;
    30 function GenPreview: TPreview;
    31 function GenPreview: TPreview;
    31 procedure CheckLandDigest(s: shortstring);
    32 procedure CheckLandDigest(s: shortstring);
    32 
    33 
   512 
   513 
   513 GenBlank(EdgeTemplates[SelectTemplate]);
   514 GenBlank(EdgeTemplates[SelectTemplate]);
   514 
   515 
   515 AddProgress;
   516 AddProgress;
   516 with PixelFormat^ do
   517 with PixelFormat^ do
   517      tmpsurf:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, AMask);
   518      tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2048, 1024, 32, $FF, $FF00, $FF0000, 0);
   518 TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true);
   519 TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true);
   519 ColorizeLand(tmpsurf);
   520 ColorizeLand(tmpsurf);
   520 AddProgress;
   521 AddProgress;
   521 AddBorder(tmpsurf);
   522 AddBorder(tmpsurf);
   522 with PixelFormat^ do
   523 with PixelFormat^ do
   523      LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, AMask);
   524      LandSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2048, 1024, 32, $FF, $FF00, $FF0000, 0);
   524 TryDo(LandSurface <> nil, 'Error creating land surface', true);
   525 TryDo(LandSurface <> nil, 'Error creating land surface', true);
   525 SDL_FillRect(LandSurface, nil, 0);
   526 SDL_FillRect(LandSurface, nil, 0);
   526 AddProgress;
   527 AddProgress;
   527 
   528 
   528 SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0);
   529 SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0);
   529 AddObjects(tmpsurf, LandSurface);
   530 AddObjects(tmpsurf, LandSurface);
   530 SDL_FreeSurface(tmpsurf);
   531 SDL_FreeSurface(tmpsurf);
   531 
   532 
       
   533 LandTexture:= Surface2Tex(LandSurface);
   532 AddProgress
   534 AddProgress
   533 end;
   535 end;
   534 
   536 
   535 procedure MakeFortsMap;
   537 procedure MakeFortsMap;
   536 var tmpsurf: PSDL_Surface;
   538 var tmpsurf: PSDL_Surface;
   537 begin
   539 begin
   538 WriteLnToConsole('Generating forts land...');
   540 WriteLnToConsole('Generating forts land...');
   539 TryDo(TeamsCount = 2, 'More or less than 2 teams on map in forts mode!', true);
   541 TryDo(TeamsCount = 2, 'More or less than 2 teams on map in forts mode!', true);
   540 
   542 
   541 with PixelFormat^ do
   543 with PixelFormat^ do
   542      LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, AMask);
   544      LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, 32, RMask, GMask, BMask, AMask);
   543 SDL_FillRect(LandSurface, nil, 0);
   545 SDL_FillRect(LandSurface, nil, 0);
   544 
   546 
   545 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + TeamsArray[0]^.FortName + 'L', false, true, true);
   547 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + TeamsArray[0]^.FortName + 'L', false, true, true);
   546 BlitImageAndGenerateCollisionInfo(0, 0, tmpsurf, LandSurface);
   548 BlitImageAndGenerateCollisionInfo(0, 0, tmpsurf, LandSurface);
   547 SDL_FreeSurface(tmpsurf);
   549 SDL_FreeSurface(tmpsurf);