hedgewars/uLandTexture.pas
author sheepluva
Fri, 05 Dec 2014 02:39:25 +0100
changeset 10629 ce046762f796
parent 10494 0eb97cf4c78e
child 10634 35d059bd0932
permissions -rw-r--r--
some translation tweaks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
     1
(*
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
9998
736015b847e3 update copyright to 2014
sheepluva
parents: 9080
diff changeset
     3
 * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
     4
 *
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
     8
 *
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    12
 * GNU General Public License for more details.
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    13
 *
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 10040
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    17
 *)
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    18
2599
c7153d2348f3 move compiler directives to standard pascal
koda
parents: 2592
diff changeset
    19
{$INCLUDE "options.inc"}
2587
0dfa56a8513c fix a segfault in the iphone simulator by moving options.inc at the beginning of the file
koda
parents: 2376
diff changeset
    20
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    21
unit uLandTexture;
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    22
interface
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
    23
uses SDLh;
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    24
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
    25
procedure initModule;
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
    26
procedure freeModule;
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
    27
procedure UpdateLandTexture(X, Width, Y, Height: LongInt; landAdded: boolean);
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
    28
procedure DrawLand(dX, dY: LongInt);
5654
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
    29
procedure ResetLand;
7850
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7172
diff changeset
    30
procedure SetLandTexture;
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    31
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    32
implementation
10267
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
    33
uses uConsts, GLunit, uTypes, uVariables, uTextures, uDebug, uRender, uUtils;
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
    34
7172
f68d62711a5c After experimenting with a long running average at maxed out FPS and a variety of map sizes, 128 seems to actually be a good size to use if only drawing bits of world with stuff in it. 64 actually did even better in some situations, but significantly worse in others (lots of land, zoomed out).
nemo
parents: 7170
diff changeset
    35
const TEXSIZE = 128;
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
    36
      // in avoid tile borders stretch the blurry texture by 1 pixel more
10124
aabd1b75d5a3 Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents: 10108
diff changeset
    37
      BLURRYLANDOVERLAP: real = 1 / TEXSIZE / 2.0; // 1 pixel divided by texsize and blurry land scale factor
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    38
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
    39
type TLandRecord = record
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
    40
            shouldUpdate, landAdded: boolean;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    41
            tex: PTexture;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    42
            end;
3615
b78d7959540a further code cleanup and less redundancy
koda
parents: 3612
diff changeset
    43
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
    44
var LandTextures: array of array of TLandRecord;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    45
    tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord;
3615
b78d7959540a further code cleanup and less redundancy
koda
parents: 3612
diff changeset
    46
    LANDTEXARW: LongWord;
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
    47
    LANDTEXARH: LongWord;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3666
diff changeset
    48
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
    49
function Pixels(x, y: Longword): Pointer;
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
    50
var ty: Longword;
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    51
begin
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
    52
for ty:= 0 to TEXSIZE - 1 do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    53
    Move(LandPixels[y * TEXSIZE + ty, x * TEXSIZE], tmpPixels[ty, 0], sizeof(Longword) * TEXSIZE);
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2248
diff changeset
    54
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
    55
Pixels:= @tmpPixels
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
    56
end;
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    57
1859
e071284b118e Pixels2 proc, which uses Land array when updating textures
unc0rr
parents: 1852
diff changeset
    58
function Pixels2(x, y: Longword): Pointer;
e071284b118e Pixels2 proc, which uses Land array when updating textures
unc0rr
parents: 1852
diff changeset
    59
var tx, ty: Longword;
e071284b118e Pixels2 proc, which uses Land array when updating textures
unc0rr
parents: 1852
diff changeset
    60
begin
e071284b118e Pixels2 proc, which uses Land array when updating textures
unc0rr
parents: 1852
diff changeset
    61
for ty:= 0 to TEXSIZE - 1 do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    62
    for tx:= 0 to TEXSIZE - 1 do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    63
        tmpPixels[ty, tx]:= Land[y * TEXSIZE + ty, x * TEXSIZE + tx] or AMask;
2376
ece7b87f1334 Strip trailing spaces
nemo
parents: 2248
diff changeset
    64
1859
e071284b118e Pixels2 proc, which uses Land array when updating textures
unc0rr
parents: 1852
diff changeset
    65
Pixels2:= @tmpPixels
e071284b118e Pixels2 proc, which uses Land array when updating textures
unc0rr
parents: 1852
diff changeset
    66
end;
e071284b118e Pixels2 proc, which uses Land array when updating textures
unc0rr
parents: 1852
diff changeset
    67
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
    68
procedure UpdateLandTexture(X, Width, Y, Height: LongInt; landAdded: boolean);
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
    69
var tx, ty: Longword;
10270
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    70
    tSize : LongInt;
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
    71
begin
8027
e5ba3dd12531 make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents: 7850
diff changeset
    72
    if cOnlyStats then exit;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6383
diff changeset
    73
    if (Width <= 0) or (Height <= 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6383
diff changeset
    74
        exit;
3595
341e407e3754 partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents: 3513
diff changeset
    75
    TryDo((X >= 0) and (X < LAND_WIDTH), 'UpdateLandTexture: wrong X parameter', true);
341e407e3754 partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents: 3513
diff changeset
    76
    TryDo(X + Width <= LAND_WIDTH, 'UpdateLandTexture: wrong Width parameter', true);
341e407e3754 partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents: 3513
diff changeset
    77
    TryDo((Y >= 0) and (Y < LAND_HEIGHT), 'UpdateLandTexture: wrong Y parameter', true);
341e407e3754 partially removing DOWNSCALE ifdef -- only two remain and their removal requires dynamic allocation (btw this breaks low quality mode)
koda
parents: 3513
diff changeset
    78
    TryDo(Y + Height <= LAND_HEIGHT, 'UpdateLandTexture: wrong Height parameter', true);
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    79
10270
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    80
    tSize:= TEXSIZE;
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    81
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    82
    // land textures have half the size/resolution in blurry mode
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    83
    if (cReducedQuality and rqBlurryLand) <> 0 then
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    84
        tSize:= tSize * 2;
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    85
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    86
    for ty:= Y div tSize to (Y + Height - 1) div tSize do
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    87
        for tx:= X div tSize to (X + Width - 1) div tSize do
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    88
            begin
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    89
            if not LandTextures[tx, ty].shouldUpdate then
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
    90
                begin
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
    91
                LandTextures[tx, ty].shouldUpdate:= true;
10270
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    92
                inc(dirtyLandTexCount);
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    93
                end;
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    94
            LandTextures[tx, ty].landAdded:= landAdded
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
    95
            end;
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    96
end;
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
    97
10268
1155384a4e31 "<unC0Rr> could also refuse to update textures when land changes if the tile isn't visible"
sheepluva
parents: 10267
diff changeset
    98
procedure RealLandTexUpdate(x1, x2, y1, y2: LongInt);
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
    99
var x, y, ty, tx, lx, ly : LongWord;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   100
    isEmpty: boolean;
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
   101
begin
8027
e5ba3dd12531 make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents: 7850
diff changeset
   102
    if cOnlyStats then exit;
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   103
(*
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
   104
if LandTextures[0, 0].tex = nil then
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   105
    for x:= 0 to LANDTEXARW -1 do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   106
        for y:= 0 to LANDTEXARH - 1 do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   107
            with LandTextures[x, y] do
3491
4619b1ae99b5 Engine:
smxx
parents: 3165
diff changeset
   108
                begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6383
diff changeset
   109
                tex:= NewTexture(TEXSIZE, TEXSIZE, Pixels(x, y));
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6383
diff changeset
   110
                glBindTexture(GL_TEXTURE_2D, tex^.id);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6383
diff changeset
   111
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, tpHigh);
3491
4619b1ae99b5 Engine:
smxx
parents: 3165
diff changeset
   112
                end
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
   113
else
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   114
*)
10268
1155384a4e31 "<unC0Rr> could also refuse to update textures when land changes if the tile isn't visible"
sheepluva
parents: 10267
diff changeset
   115
    for x:= x1 to x2 do
1155384a4e31 "<unC0Rr> could also refuse to update textures when land changes if the tile isn't visible"
sheepluva
parents: 10267
diff changeset
   116
        for y:= y1 to y2 do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   117
            with LandTextures[x, y] do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   118
                if shouldUpdate then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   119
                    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   120
                    shouldUpdate:= false;
10270
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
   121
                    dec(dirtyLandTexCount);
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   122
                    isEmpty:= not landAdded;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   123
                    landAdded:= false;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   124
                    ty:= 0;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   125
                    tx:= 1;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   126
                    ly:= y * TEXSIZE;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   127
                    lx:= x * TEXSIZE;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   128
                    // first check edges
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   129
                    while isEmpty and (ty < TEXSIZE) do
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   130
                        begin
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   131
                        isEmpty:= LandPixels[ly + ty, lx] and AMask = 0;
10494
0eb97cf4c78e Fix warnings given by 32-bit fpc
unC0Rr
parents: 10270
diff changeset
   132
                        if isEmpty then isEmpty:= LandPixels[ly + ty, Pred(lx + TEXSIZE)] and AMask = 0;
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   133
                        inc(ty)
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   134
                        end;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   135
                    while isEmpty and (tx < TEXSIZE-1) do
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   136
                        begin
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   137
                        isEmpty:= LandPixels[ly, lx + tx] and AMask = 0;
10494
0eb97cf4c78e Fix warnings given by 32-bit fpc
unC0Rr
parents: 10270
diff changeset
   138
                        if isEmpty then isEmpty:= LandPixels[Pred(ly + TEXSIZE), lx + tx] and AMask = 0;
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   139
                        inc(tx)
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   140
                        end;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   141
                    // then search every other remaining. does this sort of stuff defeat compiler opts?
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   142
                    ty:= 2;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   143
                    while isEmpty and (ty < TEXSIZE-1) do
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   144
                        begin
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   145
                        tx:= 2;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   146
                        while isEmpty and (tx < TEXSIZE-1) do
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   147
                            begin
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   148
                            isEmpty:= LandPixels[ly + ty, lx + tx] and AMask = 0;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   149
                            inc(tx,2)
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   150
                            end;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   151
                        inc(ty,2);
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   152
                        end;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   153
                    // and repeat
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   154
                    ty:= 1;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   155
                    while isEmpty and (ty < TEXSIZE-1) do
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   156
                        begin
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   157
                        tx:= 1;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   158
                        while isEmpty and (tx < TEXSIZE-1) do
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   159
                            begin
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   160
                            isEmpty:= LandPixels[ly + ty, lx + tx] and AMask = 0;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   161
                            inc(tx,2)
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   162
                            end;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   163
                        inc(ty,2);
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   164
                        end;
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   165
                    if not isEmpty then
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   166
                        begin
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   167
                        if tex = nil then tex:= NewTexture(TEXSIZE, TEXSIZE, Pixels(x, y));
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   168
                        glBindTexture(GL_TEXTURE_2D, tex^.id);
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   169
                        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXSIZE, TEXSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x,y));
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   170
                        end
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   171
                    else if tex <> nil then
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   172
                        begin
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   173
                        FreeTexture(tex);
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   174
                        tex:= nil
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   175
                        end;
10270
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
   176
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
   177
                    // nothing else to do
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
   178
                    if dirtyLandTexCount < 1 then
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
   179
                        exit;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   180
                    end
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
   181
end;
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
   182
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
   183
procedure DrawLand(dX, dY: LongInt);
10267
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   184
var x, y, tX, ty, tSize, fx, lx, fy, ly: LongInt;
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   185
    tScale: GLfloat;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   186
    overlap: boolean;
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
   187
begin
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   188
// init values based on quality settings
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   189
if (cReducedQuality and rqBlurryLand) <> 0 then
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   190
    begin
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   191
    tSize:= TEXSIZE * 2;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   192
    tScale:= 2.0;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   193
    overlap:= (cReducedQuality and rqClampLess) <> 0;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   194
    end
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   195
else
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   196
    begin
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   197
    tSize:= TEXSIZE;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   198
    tScale:= 1.0;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   199
    overlap:= false;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   200
    end;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   201
10267
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   202
// figure out visible area
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   203
// first column
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   204
tx:= ViewLeftX - dx;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   205
fx:= tx div tSize;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   206
if tx < 0 then dec(fx);
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   207
fx:= max(0, fx);
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   208
10267
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   209
// last column
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   210
tx:= ViewRightX - dx;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   211
lx:= tx div tSize;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   212
if tx < 0 then dec(lx);
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   213
lx:= min(LANDTEXARW -1, lx);
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   214
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   215
// all offscreen
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   216
if (fx > lx) then
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   217
    exit;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   218
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   219
// first row
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   220
ty:= ViewTopY - dy;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   221
fy:= ty div tSize;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   222
if ty < 0 then dec(fy);
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   223
fy:= max(0, fy);
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   224
10267
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   225
// last row
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   226
ty:= ViewBottomY - dy;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   227
ly:= ty div tSize;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   228
if ty < 0 then dec(ly);
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   229
ly:= min(LANDTEXARH -1, ly);
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   230
10267
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   231
// all offscreen
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   232
if (fy > ly) then
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   233
    exit;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   234
10269
2193bef70edf <koda> wut, chats as commit mesages?
sheepluva
parents: 10268
diff changeset
   235
// update visible areas of landtex before drawing
10270
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
   236
if dirtyLandTexCount > 0 then
cd78906ed898 superminor tweaks
sheepluva
parents: 10269
diff changeset
   237
    RealLandTexUpdate(fx, lx, fy, ly);
10268
1155384a4e31 "<unC0Rr> could also refuse to update textures when land changes if the tile isn't visible"
sheepluva
parents: 10267
diff changeset
   238
10267
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   239
tX:= dX + tsize * fx;
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   240
10267
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   241
// loop through columns
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   242
for x:= fx to lx do
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   243
    begin
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   244
    // loop through textures in this column
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   245
    for y:= fy to ly do
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   246
        with LandTextures[x, y] do
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   247
            if tex <> nil then
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   248
                begin
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   249
                ty:= dY + y * tSize;
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   250
                if overlap then
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   251
                    DrawTexture2(tX, ty, tex, tScale, BLURRYLANDOVERLAP)
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   252
                else
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   253
                    DrawTexture(tX, ty, tex, tScale);
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   254
                end;
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   255
10267
237b403f92be figure out visible land tiles in advance
sheepluva
parents: 10266
diff changeset
   256
    // increment tX
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   257
    inc(tX, tSize);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10124
diff changeset
   258
    end;
1807
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
   259
end;
795f97007833 Split land texture into small ones:
unc0rr
parents: 1806
diff changeset
   260
7850
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7172
diff changeset
   261
procedure SetLandTexture;
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   262
begin
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   263
    if (cReducedQuality and rqBlurryLand) = 0 then
5654
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   264
        begin
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   265
        LANDTEXARW:= LAND_WIDTH div TEXSIZE;
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   266
        LANDTEXARH:= LAND_HEIGHT div TEXSIZE;
5654
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   267
        end
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   268
    else
5654
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   269
        begin
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   270
        LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2;
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   271
        LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2;
5654
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   272
        end;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3666
diff changeset
   273
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   274
    SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   275
end;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3666
diff changeset
   276
7850
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7172
diff changeset
   277
procedure initModule;
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7172
diff changeset
   278
begin
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7172
diff changeset
   279
end;
fcbb024090a4 cleanup in initEverything and freeEverything
koda
parents: 7172
diff changeset
   280
5654
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   281
procedure ResetLand;
3615
b78d7959540a further code cleanup and less redundancy
koda
parents: 3612
diff changeset
   282
var x, y: LongInt;
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   283
begin
6382
0e76c5cd4250 move the order of reloading texture to workaround buggy drivers
koda
parents: 6380
diff changeset
   284
    for x:= 0 to LANDTEXARW - 1 do
3615
b78d7959540a further code cleanup and less redundancy
koda
parents: 3612
diff changeset
   285
        for y:= 0 to LANDTEXARH - 1 do
b78d7959540a further code cleanup and less redundancy
koda
parents: 3612
diff changeset
   286
            with LandTextures[x, y] do
5654
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   287
                begin
7170
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   288
                if tex <> nil then
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   289
                    begin
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   290
                    FreeTexture(tex);
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   291
                    tex:= nil
84ac6c6d2d8e Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents: 7151
diff changeset
   292
                    end
5654
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   293
                end;
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   294
end;
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   295
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   296
procedure freeModule;
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   297
begin
1cb68f420aa6 Free land texture, reset sky colour.
nemo
parents: 4976
diff changeset
   298
    ResetLand;
3615
b78d7959540a further code cleanup and less redundancy
koda
parents: 3612
diff changeset
   299
    if LandBackSurface <> nil then
b78d7959540a further code cleanup and less redundancy
koda
parents: 3612
diff changeset
   300
        SDL_FreeSurface(LandBackSurface);
b78d7959540a further code cleanup and less redundancy
koda
parents: 3612
diff changeset
   301
    LandBackSurface:= nil;
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 6700
diff changeset
   302
    SetLength(LandTextures, 0, 0);
3612
b50215a8a43d land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes
koda
parents: 3595
diff changeset
   303
end;
1806
3c4f0886c123 More reorganization
unc0rr
parents:
diff changeset
   304
end.