Forráskód Böngészése

Updated htf utils demo

GLScene 2 éve
szülő
commit
94c98c03a7

BIN
Demos/media/kapiti.htf


+ 2 - 2
Demos/utilities/HTFUtils/Etopo2.tpcfg

@@ -1,7 +1,7 @@
-HTFName=F:\HTF\etopo2.htf
+HTFName=D:\HTF\etopo2.htf
 WorldSizeX=10800
 WorldSizeX=10800
 WorldSizeY=6336
 WorldSizeY=6336
 TileSize=128
 TileSize=128
 DefaultZ=0
 DefaultZ=0
-DEMPath=F:\DEM
+DEMPath=D:\DEM
 DEMs="topo_8.2.img,""0,0"",10800x6336,""16 bits (non-Intel)"""
 DEMs="topo_8.2.img,""0,0"",10800x6336,""16 bits (non-Intel)"""

+ 2 - 2
Demos/utilities/HTFUtils/Globe.tpcfg

@@ -1,7 +1,7 @@
-HTFName=F:\HTF\globe.htf
+HTFName=D:\HTF\globe.htf
 WorldSizeX=43200
 WorldSizeX=43200
 WorldSizeY=21600
 WorldSizeY=21600
 TileSize=128
 TileSize=128
 DefaultZ=-500
 DefaultZ=-500
-DEMPath=F:\DEM
+DEMPath=D:\DEM
 DEMs="a10g,""0,0"",10800x4800,""16 bits (Intel)""","b10g,""10800,0"",10800x4800,""16 bits (Intel)""","c10g,""21600,0"",10800x4800,""16 bits (Intel)""","d10g,""32400,0"",10800x4800,""16 bits (Intel)""","e10g,""0,4800"",10800x6000,""16 bits (Intel)""","f10g,""10800,4800"",10800x6000,""16 bits (Intel)""","g10g,""21600,4800"",10800x6000,""16 bits (Intel)""","h10g,""32400,4800"",10800x6000,""16 bits (Intel)""","i10g,""0,10800"",10800x6000,""16 bits (Intel)""","j10g,""10800,10800"",10800x6000,""16 bits (Intel)""","k10g,""21600,10800"",10800x6000,""16 bits (Intel)""","l10g,""32400,10800"",10800x6000,""16 bits (Intel)""","m10g,""0,16800"",10800x4800,""16 bits (Intel)""","n10g,""10800,16800"",10800x4800,""16 bits (Intel)""","o10g,""21600,16800"",10800x4800,""16 bits (Intel)""","p10g,""32400,16800"",10800x4800,""16 bits (Intel)"""
 DEMs="a10g,""0,0"",10800x4800,""16 bits (Intel)""","b10g,""10800,0"",10800x4800,""16 bits (Intel)""","c10g,""21600,0"",10800x4800,""16 bits (Intel)""","d10g,""32400,0"",10800x4800,""16 bits (Intel)""","e10g,""0,4800"",10800x6000,""16 bits (Intel)""","f10g,""10800,4800"",10800x6000,""16 bits (Intel)""","g10g,""21600,4800"",10800x6000,""16 bits (Intel)""","h10g,""32400,4800"",10800x6000,""16 bits (Intel)""","i10g,""0,10800"",10800x6000,""16 bits (Intel)""","j10g,""10800,10800"",10800x6000,""16 bits (Intel)""","k10g,""21600,10800"",10800x6000,""16 bits (Intel)""","l10g,""32400,10800"",10800x6000,""16 bits (Intel)""","m10g,""0,16800"",10800x4800,""16 bits (Intel)""","n10g,""10800,16800"",10800x4800,""16 bits (Intel)""","o10g,""21600,16800"",10800x4800,""16 bits (Intel)""","p10g,""32400,16800"",10800x4800,""16 bits (Intel)"""

+ 7 - 7
Demos/utilities/HTFUtils/HTFViewerD.dproj

@@ -7,7 +7,7 @@
         <TargetedPlatforms>1</TargetedPlatforms>
         <TargetedPlatforms>1</TargetedPlatforms>
         <AppType>Application</AppType>
         <AppType>Application</AppType>
         <FrameworkType>VCL</FrameworkType>
         <FrameworkType>VCL</FrameworkType>
-        <ProjectVersion>19.3</ProjectVersion>
+        <ProjectVersion>19.4</ProjectVersion>
         <Platform Condition="'$(Platform)'==''">Win32</Platform>
         <Platform Condition="'$(Platform)'==''">Win32</Platform>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
@@ -932,17 +932,17 @@
                         <Operation>1</Operation>
                         <Operation>1</Operation>
                     </Platform>
                     </Platform>
                 </DeployClass>
                 </DeployClass>
+                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
-                <ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
-                <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
             </Deployment>
             </Deployment>
         </BorlandProject>
         </BorlandProject>
         <ProjectFileVersion>12</ProjectFileVersion>
         <ProjectFileVersion>12</ProjectFileVersion>

+ 2 - 2
Demos/utilities/HTFUtils/Maui_1k.tpcfg

@@ -1,7 +1,7 @@
-HTFName=F:\HTF\maui_1k.htf
+HTFName=D:\HTF\maui_1k.htf
 WorldSizeX=1024
 WorldSizeX=1024
 WorldSizeY=1024
 WorldSizeY=1024
 TileSize=128
 TileSize=128
 DefaultZ=0
 DefaultZ=0
-DEMPath=F:\DEM
+DEMPath=D:\DEM
 DEMs="maui_1k.bt,""0,0"",1025x1025,""VTP's BT (single)"""
 DEMs="maui_1k.bt,""0,0"",1025x1025,""VTP's BT (single)"""

+ 2 - 2
Demos/utilities/HTFUtils/TerrainBase.tpcfg

@@ -1,7 +1,7 @@
-HTFName=F:\HTF\tbase.htf
+HTFName=D:\HTF\tbase.htf
 WorldSizeX=4320
 WorldSizeX=4320
 WorldSizeY=2160
 WorldSizeY=2160
 TileSize=128
 TileSize=128
 DefaultZ=0
 DefaultZ=0
-DEMPath=F:\DEM
+DEMPath=D:\DEM
 DEMs="tbase.bin,""0,0"",4320x2160,""16 bits (Intel)"""
 DEMs="tbase.bin,""0,0"",4320x2160,""16 bits (Intel)"""

+ 3 - 1
Demos/utilities/HTFUtils/TerrainPackD.dpr

@@ -15,7 +15,8 @@ program TerrainPackD;
 uses
 uses
   Forms,
   Forms,
   fTerrainPackD in 'fTerrainPackD.pas' {MainForm},
   fTerrainPackD in 'fTerrainPackD.pas' {MainForm},
-  fNavD in 'fNavD.pas' {NavForm};
+  fNavD in 'fNavD.pas' {NavForm},
+  fViewerD in 'fViewerD.pas' {ViewerForm};
 
 
 {$R *.res}
 {$R *.res}
 
 
@@ -23,5 +24,6 @@ begin
   Application.Initialize;
   Application.Initialize;
   Application.CreateForm(TMainForm, MainForm);
   Application.CreateForm(TMainForm, MainForm);
   Application.CreateForm(TNavForm, NavForm);
   Application.CreateForm(TNavForm, NavForm);
+  Application.CreateForm(TViewerForm, ViewerForm);
   Application.Run;
   Application.Run;
 end.
 end.

+ 11 - 7
Demos/utilities/HTFUtils/TerrainPackD.dproj

@@ -7,7 +7,7 @@
         <TargetedPlatforms>1</TargetedPlatforms>
         <TargetedPlatforms>1</TargetedPlatforms>
         <AppType>Application</AppType>
         <AppType>Application</AppType>
         <FrameworkType>VCL</FrameworkType>
         <FrameworkType>VCL</FrameworkType>
-        <ProjectVersion>19.3</ProjectVersion>
+        <ProjectVersion>19.4</ProjectVersion>
         <Platform Condition="'$(Platform)'==''">Win32</Platform>
         <Platform Condition="'$(Platform)'==''">Win32</Platform>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
@@ -94,6 +94,10 @@
         <DCCReference Include="fNavD.pas">
         <DCCReference Include="fNavD.pas">
             <Form>NavForm</Form>
             <Form>NavForm</Form>
         </DCCReference>
         </DCCReference>
+        <DCCReference Include="fViewerD.pas">
+            <Form>ViewerForm</Form>
+            <FormType>dfm</FormType>
+        </DCCReference>
         <BuildConfiguration Include="Base">
         <BuildConfiguration Include="Base">
             <Key>Base</Key>
             <Key>Base</Key>
         </BuildConfiguration>
         </BuildConfiguration>
@@ -931,17 +935,17 @@
                         <Operation>1</Operation>
                         <Operation>1</Operation>
                     </Platform>
                     </Platform>
                 </DeployClass>
                 </DeployClass>
+                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
-                <ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
-                <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
             </Deployment>
             </Deployment>
         </BorlandProject>
         </BorlandProject>
         <ProjectFileVersion>12</ProjectFileVersion>
         <ProjectFileVersion>12</ProjectFileVersion>

+ 6 - 11
Demos/utilities/HTFUtils/fNavD.dfm

@@ -3,27 +3,22 @@ object NavForm: TNavForm
   Top = 328
   Top = 328
   BorderStyle = bsDialog
   BorderStyle = bsDialog
   Caption = 'Nav Form'
   Caption = 'Nav Form'
-  ClientHeight = 240
-  ClientWidth = 240
+  ClientHeight = 192
+  ClientWidth = 192
   Color = clBtnFace
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
   Font.Color = clWindowText
-  Font.Height = -14
+  Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   Font.Style = []
   FormStyle = fsStayOnTop
   FormStyle = fsStayOnTop
   Position = poDesktopCenter
   Position = poDesktopCenter
-  PixelsPerInch = 120
-  TextHeight = 16
+  TextHeight = 13
   object Image: TImage32
   object Image: TImage32
     Left = 0
     Left = 0
     Top = 0
     Top = 0
-    Width = 240
-    Height = 240
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Width = 192
+    Height = 192
     Bitmap.ResamplerClassName = 'TNearestResampler'
     Bitmap.ResamplerClassName = 'TNearestResampler'
     BitmapAlign = baTopLeft
     BitmapAlign = baTopLeft
     Scale = 1.000000000000000000
     Scale = 1.000000000000000000

+ 1 - 1
Demos/utilities/HTFUtils/fNavD.pas

@@ -36,7 +36,7 @@ implementation
 {$R *.dfm}
 {$R *.dfm}
 
 
 uses
 uses
-  fViewer;
+  fViewerD;
 
 
 function TNavForm.Execute(htf : TGLHeightTileFile) : Boolean;
 function TNavForm.Execute(htf : TGLHeightTileFile) : Boolean;
 var
 var

+ 130 - 282
Demos/utilities/HTFUtils/fTerrainPackD.dfm

@@ -2,32 +2,28 @@ object MainForm: TMainForm
   Left = 252
   Left = 252
   Top = 328
   Top = 328
   Caption = 'Terrain Pack v1.1'
   Caption = 'Terrain Pack v1.1'
-  ClientHeight = 515
-  ClientWidth = 726
+  ClientHeight = 412
+  ClientWidth = 581
   Color = clBtnFace
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
   Font.Color = clWindowText
-  Font.Height = -14
+  Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   Font.Style = []
   Menu = MainMenu
   Menu = MainMenu
   ShowHint = True
   ShowHint = True
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   OnDestroy = FormDestroy
-  PixelsPerInch = 120
-  TextHeight = 16
+  TextHeight = 13
   object StringGrid: TStringGrid
   object StringGrid: TStringGrid
     Left = 0
     Left = 0
-    Top = 351
-    Width = 726
-    Height = 139
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Top = 282
+    Width = 581
+    Height = 110
     Align = alClient
     Align = alClient
     BorderStyle = bsNone
     BorderStyle = bsNone
-    DefaultColWidth = 138
+    DefaultColWidth = 110
+    DefaultRowHeight = 19
     FixedCols = 0
     FixedCols = 0
     RowCount = 2
     RowCount = 2
     Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing, goThumbTracking]
     Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing, goThumbTracking]
@@ -37,277 +33,189 @@ object MainForm: TMainForm
   end
   end
   object Panel1: TPanel
   object Panel1: TPanel
     Left = 0
     Left = 0
-    Top = 215
-    Width = 726
-    Height = 136
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Top = 173
+    Width = 581
+    Height = 109
     Align = alTop
     Align = alTop
     BevelInner = bvRaised
     BevelInner = bvRaised
     BevelOuter = bvLowered
     BevelOuter = bvLowered
     TabOrder = 1
     TabOrder = 1
     DesignSize = (
     DesignSize = (
-      726
-      136)
+      581
+      109)
     object Label1: TLabel
     object Label1: TLabel
-      Left = 10
-      Top = 104
-      Width = 59
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 8
+      Top = 83
+      Width = 48
+      Height = 13
       Caption = 'DEM path'
       Caption = 'DEM path'
     end
     end
     object Label2: TLabel
     object Label2: TLabel
-      Left = 10
-      Top = 14
-      Width = 66
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 8
+      Top = 11
+      Width = 54
+      Height = 13
       Caption = 'HTF output'
       Caption = 'HTF output'
     end
     end
     object Label3: TLabel
     object Label3: TLabel
-      Left = 10
-      Top = 44
-      Width = 65
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 8
+      Top = 35
+      Width = 51
+      Height = 13
       Caption = 'World Size'
       Caption = 'World Size'
     end
     end
     object Label4: TLabel
     object Label4: TLabel
-      Left = 150
-      Top = 44
-      Width = 21
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 120
+      Top = 35
+      Width = 17
+      Height = 13
       Alignment = taCenter
       Alignment = taCenter
       AutoSize = False
       AutoSize = False
       Caption = 'x'
       Caption = 'x'
     end
     end
     object Label5: TLabel
     object Label5: TLabel
-      Left = 400
-      Top = 44
-      Width = 81
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 320
+      Top = 35
+      Width = 66
+      Height = 13
       Caption = 'Default height'
       Caption = 'Default height'
     end
     end
     object Label6: TLabel
     object Label6: TLabel
-      Left = 260
-      Top = 44
-      Width = 52
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 208
+      Top = 35
+      Width = 40
+      Height = 13
       Caption = 'Tile Size'
       Caption = 'Tile Size'
     end
     end
     object Label7: TLabel
     object Label7: TLabel
-      Left = 240
-      Top = 74
-      Width = 72
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 192
+      Top = 59
+      Width = 55
+      Height = 13
       Caption = 'Tile overlap'
       Caption = 'Tile overlap'
     end
     end
     object Label8: TLabel
     object Label8: TLabel
-      Left = 400
-      Top = 74
-      Width = 89
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 320
+      Top = 59
+      Width = 72
+      Height = 13
       Caption = 'Filter to default:'
       Caption = 'Filter to default:'
     end
     end
     object Label9: TLabel
     object Label9: TLabel
-      Left = 590
-      Top = 44
-      Width = 46
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 472
+      Top = 35
+      Width = 37
+      Height = 13
       Caption = 'Z Scale'
       Caption = 'Z Scale'
     end
     end
     object EDHTFName: TEdit
     object EDHTFName: TEdit
-      Left = 90
-      Top = 10
-      Width = 591
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 72
+      Top = 8
+      Width = 473
+      Height = 21
       Anchors = [akLeft, akTop, akRight]
       Anchors = [akLeft, akTop, akRight]
       TabOrder = 0
       TabOrder = 0
     end
     end
     object EDDEMPath: TEdit
     object EDDEMPath: TEdit
-      Left = 90
-      Top = 100
-      Width = 591
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 72
+      Top = 80
+      Width = 473
+      Height = 21
       Anchors = [akLeft, akTop, akRight]
       Anchors = [akLeft, akTop, akRight]
       TabOrder = 1
       TabOrder = 1
       OnChange = EDDEMPathChange
       OnChange = EDDEMPathChange
     end
     end
     object BUDEMPath: TButton
     object BUDEMPath: TButton
-      Left = 684
-      Top = 100
-      Width = 30
-      Height = 26
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 547
+      Top = 80
+      Width = 24
+      Height = 21
       Anchors = [akTop, akRight]
       Anchors = [akTop, akRight]
       Caption = '...'
       Caption = '...'
       TabOrder = 2
       TabOrder = 2
       OnClick = BUDEMPathClick
       OnClick = BUDEMPathClick
     end
     end
     object BUPickHTF: TButton
     object BUPickHTF: TButton
-      Left = 684
-      Top = 10
-      Width = 30
-      Height = 26
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 547
+      Top = 8
+      Width = 24
+      Height = 21
       Anchors = [akTop, akRight]
       Anchors = [akTop, akRight]
       Caption = '...'
       Caption = '...'
       TabOrder = 3
       TabOrder = 3
       OnClick = BUPickHTFClick
       OnClick = BUPickHTFClick
     end
     end
     object EDSizeX: TEdit
     object EDSizeX: TEdit
-      Left = 90
-      Top = 40
-      Width = 61
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 72
+      Top = 32
+      Width = 49
+      Height = 21
       TabOrder = 4
       TabOrder = 4
     end
     end
     object EDSizeY: TEdit
     object EDSizeY: TEdit
-      Left = 170
-      Top = 40
-      Width = 61
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 136
+      Top = 32
+      Width = 49
+      Height = 21
       TabOrder = 5
       TabOrder = 5
     end
     end
     object EDDefaultZ: TEdit
     object EDDefaultZ: TEdit
-      Left = 500
-      Top = 40
-      Width = 61
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 400
+      Top = 32
+      Width = 49
+      Height = 21
       TabOrder = 6
       TabOrder = 6
       Text = '0'
       Text = '0'
       OnChange = EDDefaultZChange
       OnChange = EDDefaultZChange
     end
     end
     object EDTileSize: TEdit
     object EDTileSize: TEdit
-      Left = 320
-      Top = 40
-      Width = 61
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 256
+      Top = 32
+      Width = 49
+      Height = 21
       TabOrder = 7
       TabOrder = 7
       Text = '256'
       Text = '256'
     end
     end
     object EDTileOverlap: TEdit
     object EDTileOverlap: TEdit
-      Left = 320
-      Top = 70
-      Width = 61
-      Height = 24
+      Left = 256
+      Top = 56
+      Width = 49
+      Height = 21
       Hint = 
       Hint = 
         'Tile overlap in samples'#13#10'When overlap is 1, righternmost and bot' +
         'Tile overlap in samples'#13#10'When overlap is 1, righternmost and bot' +
         'tommost undefined samples '#13#10'will be filled completed with last r' +
         'tommost undefined samples '#13#10'will be filled completed with last r' +
         'ow value in place of default value'
         'ow value in place of default value'
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       TabOrder = 8
       TabOrder = 8
       Text = '0'
       Text = '0'
     end
     end
     object EDZFilter: TEdit
     object EDZFilter: TEdit
-      Left = 500
-      Top = 70
-      Width = 63
-      Height = 24
+      Left = 400
+      Top = 56
+      Width = 50
+      Height = 21
       Hint = 
       Hint = 
         'All samples with this altitude will be replaced by default heigh' +
         'All samples with this altitude will be replaced by default heigh' +
         't'
         't'
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       TabOrder = 9
       TabOrder = 9
       OnChange = EDZFilterChange
       OnChange = EDZFilterChange
     end
     end
     object EDZScale: TEdit
     object EDZScale: TEdit
-      Left = 644
-      Top = 40
-      Width = 71
-      Height = 24
+      Left = 515
+      Top = 32
+      Width = 57
+      Height = 21
       Hint = 
       Hint = 
         'Scaling is applied after filtering, and applied to default heigh' +
         'Scaling is applied after filtering, and applied to default heigh' +
         't too'
         't too'
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       TabOrder = 10
       TabOrder = 10
       Text = '1.0'
       Text = '1.0'
       OnChange = EDZScaleChange
       OnChange = EDZScaleChange
     end
     end
     object CBWholeOnly: TCheckBox
     object CBWholeOnly: TCheckBox
-      Left = 590
-      Top = 74
-      Width = 121
-      Height = 21
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 472
+      Top = 59
+      Width = 97
+      Height = 17
       Caption = 'Whole tiles only'
       Caption = 'Whole tiles only'
       TabOrder = 11
       TabOrder = 11
     end
     end
@@ -315,120 +223,76 @@ object MainForm: TMainForm
   object ToolBar: TToolBar
   object ToolBar: TToolBar
     Left = 0
     Left = 0
     Top = 0
     Top = 0
-    Width = 726
-    Height = 215
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Width = 581
+    Height = 173
     AutoSize = True
     AutoSize = True
     BorderWidth = 1
     BorderWidth = 1
-    ButtonHeight = 211
-    ButtonWidth = 114
+    ButtonHeight = 169
+    ButtonWidth = 91
     Caption = 'ToolBar'
     Caption = 'ToolBar'
     Images = ImageList
     Images = ImageList
     TabOrder = 2
     TabOrder = 2
     object ToolButton1: TToolButton
     object ToolButton1: TToolButton
       Left = 0
       Left = 0
       Top = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACOpen
       Action = ACOpen
     end
     end
     object ToolButton2: TToolButton
     object ToolButton2: TToolButton
-      Left = 114
+      Left = 91
       Top = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACSave
       Action = ACSave
     end
     end
     object ToolButton3: TToolButton
     object ToolButton3: TToolButton
-      Left = 228
+      Left = 182
       Top = 0
       Top = 0
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 8
       Caption = 'ToolButton3'
       Caption = 'ToolButton3'
       ImageIndex = 2
       ImageIndex = 2
       Style = tbsSeparator
       Style = tbsSeparator
     end
     end
     object ToolButton4: TToolButton
     object ToolButton4: TToolButton
-      Left = 238
+      Left = 190
       Top = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACNewDEM
       Action = ACNewDEM
     end
     end
     object ToolButton5: TToolButton
     object ToolButton5: TToolButton
-      Left = 352
+      Left = 281
       Top = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACRemoveDEM
       Action = ACRemoveDEM
     end
     end
     object ToolButton6: TToolButton
     object ToolButton6: TToolButton
-      Left = 466
+      Left = 372
       Top = 0
       Top = 0
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 8
       Caption = 'ToolButton6'
       Caption = 'ToolButton6'
       ImageIndex = 6
       ImageIndex = 6
       Style = tbsSeparator
       Style = tbsSeparator
     end
     end
     object ToolButton7: TToolButton
     object ToolButton7: TToolButton
-      Left = 476
+      Left = 380
       Top = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACProcess
       Action = ACProcess
     end
     end
     object ToolButton8: TToolButton
     object ToolButton8: TToolButton
-      Left = 590
+      Left = 471
       Top = 0
       Top = 0
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 8
       Caption = 'ToolButton8'
       Caption = 'ToolButton8'
       ImageIndex = 4
       ImageIndex = 4
       Style = tbsSeparator
       Style = tbsSeparator
     end
     end
     object ToolButton9: TToolButton
     object ToolButton9: TToolButton
-      Left = 600
+      Left = 479
       Top = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACViewer
       Action = ACViewer
     end
     end
   end
   end
   object CBType: TComboBox
   object CBType: TComboBox
-    Left = 410
-    Top = 230
-    Width = 141
-    Height = 24
+    Left = 328
+    Top = 184
+    Width = 113
+    Height = 21
     Hint = 'Select input file format.'
     Hint = 'Select input file format.'
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
     Style = csDropDownList
     Style = csDropDownList
     TabOrder = 3
     TabOrder = 3
     Visible = False
     Visible = False
@@ -443,15 +307,11 @@ object MainForm: TMainForm
       'DTED')
       'DTED')
   end
   end
   object CBFile: TComboBox
   object CBFile: TComboBox
-    Left = 10
-    Top = 230
-    Width = 141
-    Height = 24
+    Left = 8
+    Top = 184
+    Width = 113
+    Height = 21
     Hint = 'Filename to be inported.'
     Hint = 'Filename to be inported.'
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
     DropDownCount = 24
     DropDownCount = 24
     TabOrder = 4
     TabOrder = 4
     Visible = False
     Visible = False
@@ -459,13 +319,9 @@ object MainForm: TMainForm
   end
   end
   object PanelFoot: TPanel
   object PanelFoot: TPanel
     Left = 0
     Left = 0
-    Top = 490
-    Width = 726
-    Height = 25
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Top = 392
+    Width = 581
+    Height = 20
     Align = alBottom
     Align = alBottom
     BevelOuter = bvNone
     BevelOuter = bvNone
     BorderWidth = 3
     BorderWidth = 3
@@ -473,12 +329,8 @@ object MainForm: TMainForm
     object ProgressBar: TProgressBar
     object ProgressBar: TProgressBar
       Left = 3
       Left = 3
       Top = 3
       Top = 3
-      Width = 720
-      Height = 19
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 575
+      Height = 14
       Align = alClient
       Align = alClient
       Smooth = True
       Smooth = True
       Step = 1
       Step = 1
@@ -486,17 +338,13 @@ object MainForm: TMainForm
     end
     end
   end
   end
   object CBFlipRotate: TComboBox
   object CBFlipRotate: TComboBox
-    Left = 560
-    Top = 230
-    Width = 141
-    Height = 24
+    Left = 448
+    Top = 184
+    Width = 113
+    Height = 21
     Hint = 
     Hint = 
       'Rotate and/or flip the input data. (Use Rotate 270 for DTED data' +
       'Rotate and/or flip the input data. (Use Rotate 270 for DTED data' +
       '.)'
       '.)'
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
     Style = csDropDownList
     Style = csDropDownList
     TabOrder = 6
     TabOrder = 6
     Visible = False
     Visible = False

+ 481 - 389
Demos/utilities/HTFUtils/fTerrainPackD.pas

@@ -4,34 +4,36 @@ interface
 
 
 uses
 uses
   Winapi.Windows,
   Winapi.Windows,
-  System.SysUtils, 
-  System.Classes, 
-  System.Actions, 
+  System.SysUtils,
+  System.Classes,
+  System.Actions,
   System.Math,
   System.Math,
-  Vcl.Graphics, 
-  Vcl.Controls, 
-  Vcl.Forms, 
-  Vcl.Dialogs, 
-  ValEdit, 
-  Vcl.Grids, 
-  Vcl.Menus, 
-  Vcl.StdCtrls, 
-  Vcl.ComCtrls, 
-  Vcl.ToolWin, 
-  Vcl.ExtCtrls, 
-  Vcl.ActnList, 
+  System.ImageList,
+  Vcl.Graphics,
+  Vcl.Controls,
+  Vcl.Forms,
+  Vcl.Dialogs,
+  ValEdit,
+  Vcl.Grids,
+  Vcl.Menus,
+  Vcl.StdCtrls,
+  Vcl.ComCtrls,
+  Vcl.ToolWin,
+  Vcl.ExtCtrls,
+  Vcl.ActnList,
   Vcl.ImgList,
   Vcl.ImgList,
-  
-  GLS.HeightTileFileHDS, System.ImageList;
+
+  GLS.HeightTileFileHDS;
 
 
 type
 type
-   TSrc = record
-      fs : TFileStream;
-      x, y, w, h : Integer;
-      format : Integer;
-      FlipRotate : Integer;
-   end;
-   PSrc = ^TSrc;
+  TSrc = record
+    fs: TFileStream;
+    x, y, w, h: Integer;
+    format: Integer;
+    FlipRotate: Integer;
+  end;
+
+  PSrc = ^TSrc;
 
 
   TMainForm = class(TForm)
   TMainForm = class(TForm)
     MainMenu: TMainMenu;
     MainMenu: TMainMenu;
@@ -123,20 +125,22 @@ type
     procedure EDZFilterChange(Sender: TObject);
     procedure EDZFilterChange(Sender: TObject);
     procedure EDZScaleChange(Sender: TObject);
     procedure EDZScaleChange(Sender: TObject);
   private
   private
-     
-    sources : array of TSrc;
-    defaultZ : SmallInt;
-    filterZ : SmallInt;
-    zScale : Single;
+
+    sources: array of TSrc;
+    defaultZ: SmallInt;
+    filterZ: SmallInt;
+    zScale: Single;
 
 
     procedure Parse;
     procedure Parse;
     procedure Cleanup;
     procedure Cleanup;
-    procedure SrcExtractFlip(src : PSrc; relX, relY, len : Integer; dest : PSmallInt);
-    procedure SrcExtract(src : PSrc; relX, relY, len : Integer; dest : PSmallInt; DiagFlip:boolean=false);
-    procedure WorldExtract(x, y, len : Integer; dest : PSmallInt);
+    procedure SrcExtractFlip(src: PSrc; relX, relY, len: Integer;
+      dest: PSmallInt);
+    procedure SrcExtract(src: PSrc; relX, relY, len: Integer; dest: PSmallInt;
+      DiagFlip: Boolean = false);
+    procedure WorldExtract(x, y, len: Integer; dest: PSmallInt);
 
 
   public
   public
-     
+
   end;
   end;
 
 
 var
 var
@@ -145,479 +149,567 @@ var
 implementation
 implementation
 
 
 uses
 uses
-  FViewerForm;
+  fViewerD;
 
 
 {$R *.dfm}
 {$R *.dfm}
 
 
 procedure TMainForm.FormCreate(Sender: TObject);
 procedure TMainForm.FormCreate(Sender: TObject);
 var
 var
-   i : Integer;
+  i: Integer;
 begin
 begin
-   with ActionList do
-      for i:=0 to ActionCount-1 do with TAction(Actions[i]) do
-         Hint:=Caption;
-   with StringGrid do begin
-      Cells[0, 0]:='File Name';           ColWidths[0]:=140;
-      Cells[1, 0]:='World Offset';        ColWidths[1]:=80;
-      Cells[2, 0]:='Size (rotated)';      ColWidths[2]:=80;
-      Cells[3, 0]:='Data type';           ColWidths[3]:=120;
-      Cells[4, 0]:='Flip and Rotate';     ColWidths[4]:=110;
-      Row:=0;
-   end;
-   zScale:=1;
+  with ActionList do
+    for i := 0 to ActionCount - 1 do
+      with TAction(Actions[i]) do
+        Hint := Caption;
+  with StringGrid do
+  begin
+    Cells[0, 0] := 'File Name';
+    ColWidths[0] := 140;
+    Cells[1, 0] := 'World Offset';
+    ColWidths[1] := 80;
+    Cells[2, 0] := 'Size (rotated)';
+    ColWidths[2] := 80;
+    Cells[3, 0] := 'Data type';
+    ColWidths[3] := 120;
+    Cells[4, 0] := 'Flip and Rotate';
+    ColWidths[4] := 110;
+    Row := 0;
+  end;
+  zScale := 1;
 end;
 end;
 
 
 procedure TMainForm.FormDestroy(Sender: TObject);
 procedure TMainForm.FormDestroy(Sender: TObject);
 begin
 begin
-   Cleanup;
+  Cleanup;
 end;
 end;
 
 
 procedure TMainForm.ACExitExecute(Sender: TObject);
 procedure TMainForm.ACExitExecute(Sender: TObject);
 begin
 begin
-   Close;
+  Close;
 end;
 end;
 
 
 procedure TMainForm.BUDEMPathClick(Sender: TObject);
 procedure TMainForm.BUDEMPathClick(Sender: TObject);
 begin
 begin
-   ODPath.InitialDir:=EDDEMPath.Text;
-   ODPath.FileName:=EDDEMPath.Text+'pick a dummy.file';
-   if ODPath.Execute then
-      EDDEMPath.Text:=ExtractFilePath(ODPath.FileName);
+  ODPath.InitialDir := EDDEMPath.Text;
+  ODPath.FileName := EDDEMPath.Text + 'pick a dummy.file';
+  if ODPath.Execute then
+    EDDEMPath.Text := ExtractFilePath(ODPath.FileName);
 end;
 end;
 
 
 procedure TMainForm.BUPickHTFClick(Sender: TObject);
 procedure TMainForm.BUPickHTFClick(Sender: TObject);
 begin
 begin
-   SDHTF.FileName:=EDHTFName.Text;
-   if SDHTF.Execute then
-      EDHTFName.Text:=SDHTF.FileName;
+  SDHTF.FileName := EDHTFName.Text;
+  if SDHTF.Execute then
+    EDHTFName.Text := SDHTF.FileName;
 end;
 end;
 
 
 procedure TMainForm.MIAboutClick(Sender: TObject);
 procedure TMainForm.MIAboutClick(Sender: TObject);
 begin
 begin
-   ShowMessage(Caption+#13#10#13#10
-               +'HTF Generation Utility'#13#10
-               +'Part of GLScene library.'#13#10#13#10
-               +'http://glscene.org');
+  ShowMessage(Caption + #13#10#13#10 + 'HTF Generation Utility'#13#10 +
+    'Part of GLScene library.'#13#10#13#10 + 'http://glscene.org');
 end;
 end;
 
 
 procedure TMainForm.ActionListUpdate(Action: TBasicAction;
 procedure TMainForm.ActionListUpdate(Action: TBasicAction;
   var Handled: Boolean);
   var Handled: Boolean);
 begin
 begin
-   ACRemoveDEM.Enabled:=(StringGrid.RowCount>2);
+  ACRemoveDEM.Enabled := (StringGrid.RowCount > 2);
 end;
 end;
 
 
 procedure TMainForm.ACNewDEMExecute(Sender: TObject);
 procedure TMainForm.ACNewDEMExecute(Sender: TObject);
 begin
 begin
-   StringGrid.RowCount:=StringGrid.RowCount+1;
+  StringGrid.RowCount := StringGrid.RowCount + 1;
 end;
 end;
 
 
 procedure TMainForm.ACRemoveDEMExecute(Sender: TObject);
 procedure TMainForm.ACRemoveDEMExecute(Sender: TObject);
 var
 var
-   i : Integer;
+  i: Integer;
 begin
 begin
-   with StringGrid do begin
-      i:=Row;
-      if i<RowCount-1 then begin
-         while i<RowCount-1 do begin
-            Rows[i]:=Rows[i+1];
-            Inc(i);
-         end;
-      end else Row:=i-1;
-      RowCount:=RowCount-1;
-   end;
+  with StringGrid do
+  begin
+    i := Row;
+    if i < RowCount - 1 then
+    begin
+      while i < RowCount - 1 do
+      begin
+        Rows[i] := Rows[i + 1];
+        Inc(i);
+      end;
+    end
+    else
+      Row := i - 1;
+    RowCount := RowCount - 1;
+  end;
 end;
 end;
 
 
-procedure TMainForm.StringGridSelectCell(Sender: TObject; ACol,
-  ARow: Integer; var CanSelect: Boolean);
-
-   procedure SetCB(const cb : TComboBox);
-   var
-      r : TRect;
-      i : Integer;
-   begin
-      r:=StringGrid.CellRect(ACol, ARow);
-      cb.Left:=r.Left+StringGrid.Left;
-      cb.Top:=r.Top+StringGrid.Top;
-      cb.Width:=r.Right+1-r.Left;
-      i:=cb.Items.IndexOf(StringGrid.Cells[ACol, ARow]);
-      if i>=0 then
-         cb.ItemIndex:=i
-      else cb.Text:=StringGrid.Cells[ACol, ARow];
-      if Visible then
-         cb.SetFocus;
-   end;
+procedure TMainForm.StringGridSelectCell(Sender: TObject; ACol, ARow: Integer;
+  var CanSelect: Boolean);
+
+  procedure SetCB(const cb: TComboBox);
+  var
+    r: TRect;
+    i: Integer;
+  begin
+    r := StringGrid.CellRect(ACol, ARow);
+    cb.Left := r.Left + StringGrid.Left;
+    cb.Top := r.Top + StringGrid.Top;
+    cb.Width := r.Right + 1 - r.Left;
+    i := cb.Items.IndexOf(StringGrid.Cells[ACol, ARow]);
+    if i >= 0 then
+      cb.ItemIndex := i
+    else
+      cb.Text := StringGrid.Cells[ACol, ARow];
+    if Visible then
+      cb.SetFocus;
+  end;
 
 
 begin
 begin
-   if ARow>0 then begin
-      if ACol=0 then begin
-         CBFile.Visible:=True;
-         SetCB(CBFile);
-      end else CBFile.Visible:=False;
-      if ACol=3 then begin
-         CBType.Visible:=True;
-         SetCB(CBType);
-      end else CBType.Visible:=False;
-      if ACol=4 then begin
-         CBFlipRotate.Visible:=True;
-         SetCB(CBFlipRotate);
-      end else CBFlipRotate.Visible:=False;
-      CanSelect:=True;
-   end;
+  if ARow > 0 then
+  begin
+    if ACol = 0 then
+    begin
+      CBFile.Visible := True;
+      SetCB(CBFile);
+    end
+    else
+      CBFile.Visible := false;
+    if ACol = 3 then
+    begin
+      CBType.Visible := True;
+      SetCB(CBType);
+    end
+    else
+      CBType.Visible := false;
+    if ACol = 4 then
+    begin
+      CBFlipRotate.Visible := True;
+      SetCB(CBFlipRotate);
+    end
+    else
+      CBFlipRotate.Visible := false;
+    CanSelect := True;
+  end;
 end;
 end;
 
 
 procedure TMainForm.CBTypeChange(Sender: TObject);
 procedure TMainForm.CBTypeChange(Sender: TObject);
 begin
 begin
-   with StringGrid do
-      Cells[Col, Row]:=(Sender as TComboBox).Text;
+  with StringGrid do
+    Cells[Col, Row] := (Sender as TComboBox).Text;
 end;
 end;
 
 
 procedure TMainForm.ACSaveExecute(Sender: TObject);
 procedure TMainForm.ACSaveExecute(Sender: TObject);
 var
 var
-   i : Integer;
-   sl, sg : TStringList;
+  i: Integer;
+  sl, sg: TStringList;
 begin
 begin
-   if SDTerrainPack.Execute then begin
-      sl:=TStringList.Create;
-      with sl do begin
-         Values['HTFName']:=EDHTFName.Text;
-         Values['WorldSizeX']:=EDSizeX.Text;
-         Values['WorldSizeY']:=EDSizeY.Text;
-         Values['TileSize']:=EDTileSize.Text;
-         Values['TileOverlap']:=EDTileOverlap.Text;
-         Values['DefaultZ']:=EDDefaultZ.Text;
-         Values['FilterZ']:=EDZFilter.Text;
-         Values['ZScale']:=EDZScale.Text;
-         Values['DEMPath']:=EDDEMPath.Text;
-         Values['WholeTiles']:=IntToStr(Integer(CBWholeOnly.Checked));
-         sg:=TStringList.Create;
-         for i:=1 to StringGrid.RowCount-1 do
-            sg.Add(StringGrid.Rows[i].CommaText);
-         Values['DEMs']:=sg.CommaText;
-         sg.Free;
-      end;
-      sl.SaveToFile(SDTerrainPack.FileName);
-      sl.Free;
-   end;
+  if SDTerrainPack.Execute then
+  begin
+    sl := TStringList.Create;
+    with sl do
+    begin
+      Values['HTFName'] := EDHTFName.Text;
+      Values['WorldSizeX'] := EDSizeX.Text;
+      Values['WorldSizeY'] := EDSizeY.Text;
+      Values['TileSize'] := EDTileSize.Text;
+      Values['TileOverlap'] := EDTileOverlap.Text;
+      Values['DefaultZ'] := EDDefaultZ.Text;
+      Values['FilterZ'] := EDZFilter.Text;
+      Values['ZScale'] := EDZScale.Text;
+      Values['DEMPath'] := EDDEMPath.Text;
+      Values['WholeTiles'] := IntToStr(Integer(CBWholeOnly.Checked));
+      sg := TStringList.Create;
+      for i := 1 to StringGrid.RowCount - 1 do
+        sg.Add(StringGrid.Rows[i].CommaText);
+      Values['DEMs'] := sg.CommaText;
+      sg.Free;
+    end;
+    sl.SaveToFile(SDTerrainPack.FileName);
+    sl.Free;
+  end;
 end;
 end;
 
 
 procedure TMainForm.ACOpenExecute(Sender: TObject);
 procedure TMainForm.ACOpenExecute(Sender: TObject);
 var
 var
-   i : Integer;
-   sl, sg : TStringList;
+  i: Integer;
+  sl, sg: TStringList;
 begin
 begin
-   if ODTerrainPack.Execute then begin
-      sl:=TStringList.Create;
-      sl.LoadFromFile(ODTerrainPack.FileName);
-      with sl do begin
-         EDHTFName.Text:=Values['HTFName'];
-         EDSizeX.Text:=Values['WorldSizeX'];
-         EDSizeY.Text:=Values['WorldSizeY'];
-         EDTileSize.Text:=Values['TileSize'];
-         EDTileOverlap.Text:=Values['TileOverlap'];
-         EDDefaultZ.Text:=Values['DefaultZ'];
-         EDZFilter.Text:=Values['FilterZ'];
-         EDZScale.Text:=Values['ZScale'];
-         EDDEMPath.Text:=Values['DEMPath'];
-         CBWholeOnly.Checked:=(Values['WholeTiles']='1');
-         sg:=TStringList.Create;
-         sg.CommaText:=Values['DEMs'];
-         StringGrid.RowCount:=sg.Count+1;
-         for i:=0 to sg.Count-1 do
-            StringGrid.Rows[i+1].CommaText:=sg[i];
-         sg.Free;
-      end;
-      sl.Free;
-      SDTerrainPack.FileName:=ODTerrainPack.FileName;
-   end;
+  if ODTerrainPack.Execute then
+  begin
+    sl := TStringList.Create;
+    sl.LoadFromFile(ODTerrainPack.FileName);
+    with sl do
+    begin
+      EDHTFName.Text := Values['HTFName'];
+      EDSizeX.Text := Values['WorldSizeX'];
+      EDSizeY.Text := Values['WorldSizeY'];
+      EDTileSize.Text := Values['TileSize'];
+      EDTileOverlap.Text := Values['TileOverlap'];
+      EDDefaultZ.Text := Values['DefaultZ'];
+      EDZFilter.Text := Values['FilterZ'];
+      EDZScale.Text := Values['ZScale'];
+      EDDEMPath.Text := Values['DEMPath'];
+      CBWholeOnly.Checked := (Values['WholeTiles'] = '1');
+      sg := TStringList.Create;
+      sg.CommaText := Values['DEMs'];
+      StringGrid.RowCount := sg.Count + 1;
+      for i := 0 to sg.Count - 1 do
+        StringGrid.Rows[i + 1].CommaText := sg[i];
+      sg.Free;
+    end;
+    sl.Free;
+    SDTerrainPack.FileName := ODTerrainPack.FileName;
+  end;
 end;
 end;
 
 
 procedure TMainForm.EDDEMPathChange(Sender: TObject);
 procedure TMainForm.EDDEMPathChange(Sender: TObject);
 var
 var
-   f : TSearchRec;
-   r : Integer;
+  f: TSearchRec;
+  r: Integer;
 begin
 begin
-   CBFile.Items.Clear;
-   r:=FindFirst(EDDEMPath.Text+'\*.*', faAnyFile, f);
-   while r=0 do begin
-      if (f.Attr and faDirectory)=0 then
-         CBFile.Items.Add(f.Name);
-      r:=FindNext(f);
-   end;
-   FindClose(f);
+  CBFile.Items.Clear;
+  r := FindFirst(EDDEMPath.Text + '\*.*', faAnyFile, f);
+  while r = 0 do
+  begin
+    if (f.Attr and faDirectory) = 0 then
+      CBFile.Items.Add(f.Name);
+    r := FindNext(f);
+  end;
+  FindClose(f);
 end;
 end;
 
 
 procedure TMainForm.EDDefaultZChange(Sender: TObject);
 procedure TMainForm.EDDefaultZChange(Sender: TObject);
 begin
 begin
-   defaultZ:=StrToIntDef(EDDefaultZ.Text, 0);
-   if EDZFilter.Text='' then
-      filterZ:=defaultZ;
+  defaultZ := StrToIntDef(EDDefaultZ.Text, 0);
+  if EDZFilter.Text = '' then
+    filterZ := defaultZ;
 end;
 end;
 
 
 procedure TMainForm.EDZFilterChange(Sender: TObject);
 procedure TMainForm.EDZFilterChange(Sender: TObject);
 begin
 begin
-   filterZ:=StrToIntDef(EDZFilter.Text, defaultZ);
+  filterZ := StrToIntDef(EDZFilter.Text, defaultZ);
 end;
 end;
 
 
 procedure TMainForm.EDZScaleChange(Sender: TObject);
 procedure TMainForm.EDZScaleChange(Sender: TObject);
 begin
 begin
-   zScale:=StrToFloatDef(EDZScale.Text, 1.0);
+  zScale := StrToFloatDef(EDZScale.Text, 1.0);
 end;
 end;
 
 
 procedure TMainForm.Parse;
 procedure TMainForm.Parse;
 var
 var
-   i, p : Integer;
-   row : TStrings;
+  i, p: Integer;
+  Row: TStrings;
 begin
 begin
-   Cleanup;
-   SetLength(sources, StringGrid.RowCount-1);
-   for i:=0 to High(sources) do begin
-      row:=StringGrid.Rows[i+1];
-      sources[i].fs:=TFileStream.Create(EDDEMPath.Text+'\'+row[0], fmOpenRead+fmShareDenyNone);
-      p:=Pos(',', row[1]);
-      sources[i].x:=StrToInt(Copy(row[1], 1, p-1));
-      sources[i].y:=StrToInt(Copy(row[1], p+1, MaxInt));
-      p:=Pos('x', row[2]);
-      sources[i].w:=StrToInt(Copy(row[2], 1, p-1));
-      sources[i].h:=StrToInt(Copy(row[2], p+1, MaxInt));
-      sources[i].format:=CBType.Items.IndexOf(row[3]);           //File format
-      sources[i].FlipRotate:=CBFlipRotate.Items.IndexOf(row[4]); //Flip and Rotate
-   end;
+  Cleanup;
+  SetLength(sources, StringGrid.RowCount - 1);
+  for i := 0 to High(sources) do
+  begin
+    Row := StringGrid.Rows[i + 1];
+    sources[i].fs := TFileStream.Create(EDDEMPath.Text + '\' + Row[0],
+      fmOpenRead + fmShareDenyNone);
+    p := Pos(',', Row[1]);
+    sources[i].x := StrToInt(Copy(Row[1], 1, p - 1));
+    sources[i].y := StrToInt(Copy(Row[1], p + 1, MaxInt));
+    p := Pos('x', Row[2]);
+    sources[i].w := StrToInt(Copy(Row[2], 1, p - 1));
+    sources[i].h := StrToInt(Copy(Row[2], p + 1, MaxInt));
+    sources[i].format := CBType.Items.IndexOf(Row[3]); // File format
+    sources[i].FlipRotate := CBFlipRotate.Items.IndexOf(Row[4]);
+    // Flip and Rotate
+  end;
 end;
 end;
 
 
 procedure TMainForm.Cleanup;
 procedure TMainForm.Cleanup;
 var
 var
-   i : Integer;
+  i: Integer;
 begin
 begin
-   for i:=0 to High(sources) do
-      sources[i].fs.Free;
-   SetLength(sources, 0);
+  for i := 0 to High(sources) do
+    sources[i].fs.Free;
+  SetLength(sources, 0);
 end;
 end;
 
 
-procedure TMainForm.SrcExtractFlip(src : PSrc; relX, relY, len : Integer; dest : PSmallInt);
-var i:integer;
-    val:SmallInt;
+procedure TMainForm.SrcExtractFlip(src: PSrc; relX, relY, len: Integer;
+  dest: PSmallInt);
+var
+  i: Integer;
+  val: SmallInt;
 begin
 begin
-  if src.FlipRotate<=0 then SrcExtract(src,relX, relY, len, dest)  //None
-  else begin
-    for i:=0 to len-1 do begin
+  if src.FlipRotate <= 0 then
+    SrcExtract(src, relX, relY, len, dest) // None
+  else
+  begin
+    for i := 0 to len - 1 do
+    begin
       case src.FlipRotate of
       case src.FlipRotate of
-      //0 : SrcExtract(src,relX, relY+i,1,@val);                   //No change                  (    )
-        1 : SrcExtract(src,src.w-(relX+i),relY,1,@val);            //H-Flip                     (Flip)
-        2 : SrcExtract(src,relY,src.w-(relX+i),1,@val,true);       //DiagFlip + H-Flip          (90deg)
-        3 : SrcExtract(src,src.w-(relX+i),src.h-relY,1,@val);      //H-Flip   + V-Flip          (180deg)
-        4 : SrcExtract(src,src.h-relY,(relX+i),1,@val,true);       //DiagFlip + V-Flip          (270deg)
-        5 : SrcExtract(src,src.h-relY,src.w-(relX+i),1,@val,true); //DiagFlip + V-Flip + H-Flip (Flip-90deg)
-        6 : SrcExtract(src,relX+i,src.h-relY,1,@val);              //V-FLIP                     (Flip-180deg)
-        7 : SrcExtract(src,relY, relX+i,1,@val,true);              //DiagFlip                   (Flip-270deg)
+        // 0 : SrcExtract(src,relX, relY+i,1,@val);                   //No change                  (    )
+        1:
+          SrcExtract(src, src.w - (relX + i), relY, 1, @val);
+          // H-Flip                     (Flip)
+        2:
+          SrcExtract(src, relY, src.w - (relX + i), 1, @val, True);
+          // DiagFlip + H-Flip          (90deg)
+        3:
+          SrcExtract(src, src.w - (relX + i), src.h - relY, 1, @val);
+          // H-Flip   + V-Flip          (180deg)
+        4:
+          SrcExtract(src, src.h - relY, (relX + i), 1, @val, True);
+          // DiagFlip + V-Flip          (270deg)
+        5:
+          SrcExtract(src, src.h - relY, src.w - (relX + i), 1, @val, True);
+          // DiagFlip + V-Flip + H-Flip (Flip-90deg)
+        6:
+          SrcExtract(src, relX + i, src.h - relY, 1, @val);
+          // V-FLIP                     (Flip-180deg)
+        7:
+          SrcExtract(src, relY, relX + i, 1, @val, True);
+          // DiagFlip                   (Flip-270deg)
       end;
       end;
-      PSmallIntArray(dest)[i]:=val;
+      PSmallIntArray(dest)[i] := val;
     end;
     end;
   end;
   end;
 end;
 end;
 
 
-
-procedure TMainForm.SrcExtract(src : PSrc; relX, relY, len : Integer; dest : PSmallInt; DiagFlip:boolean=false);
+procedure TMainForm.SrcExtract(src: PSrc; relX, relY, len: Integer;
+  dest: PSmallInt; DiagFlip: Boolean = false);
 var
 var
-   i, c : Integer;
-   wd : Word;
-   buf : array of Single;
-   bmp : TBitmap;
-   rw    : integer; //rotated width
+  i, c: Integer;
+  wd: Word;
+  buf: array of Single;
+  bmp: TBitmap;
+  rw: Integer; // rotated width
 begin
 begin
-   if DiagFlip then rw:=src.h else rw:=src.w;
-
-   with src^ do begin
-      case format of
-         0 : begin // 16bits Intel
-            fs.Position:=(relX+relY*rw)*2;
-            fs.Read(dest^, len*2);
-         end;
-         1 : begin // 16bits unsigned Intel
-            fs.Position:=(relX+relY*rw)*2;
-            fs.Read(dest^, len*2);
-            for i:=0 to len-1 do begin
-               wd:=PWord(Integer(dest)+i*2)^;
-               PSmallInt(Integer(dest)+i*2)^:=Integer(wd)-32768;
-            end;
-         end;
-         2 : begin // 16bits non-Intel
-            fs.Position:=(relX+relY*rw)*2;
-            fs.Read(dest^, len*2);
-            for i:=0 to len-1 do begin
-               wd:=PWord(Integer(dest)+i*2)^;
-               PWord(Integer(dest)+i*2)^:=((wd and 255) shl 8)+(wd shr 8);
-            end;
-         end;
-         3 : begin // VTP's BT single
-            fs.Position:=(relX+relY*rw)*4+256;
-            SetLength(buf, len);
-            fs.Read(buf[0], len*4);
-            for i:=0 to len-1 do
-               PSmallInt(Integer(dest)+i*2)^:=Round(buf[i]);
-         end;
-         4 : begin // windows BMP
-            bmp:=TBitmap.Create;
-            try
-               fs.Position:=0;
-               bmp.LoadFromStream(fs);
-               if DiagFlip then rw:=bmp.Width else rw:=bmp.Height;
-               for i:=0 to len-1 do begin
-                  c:=bmp.Canvas.Pixels[relX+i, rw-relY-1];
-                  PSmallInt(Integer(dest)+i*2)^:=(GetGValue(c)-128) shl 7;
-               end;
-            finally
-               bmp.Free;
-            end;
-         end;
-         5 : begin // 32bits FP Intel
-            fs.Position:=(relX+relY*rw)*4;
-            SetLength(buf, len);
-            fs.Read(buf[0], len*4);
-            for i:=0 to len-1 do
-               PSmallInt(Integer(dest)+i*2)^:=Round((buf[i]-0.5)*32000);
-         end;
-         6 : begin // DTED
-            fs.Position:=3434+(relX+relY*rw)*2 +(relY*12);
-            fs.Read(dest^, len*2);
-            for i:=0 to len-1 do begin
-               wd:=PWord(Integer(dest)+i*2)^;
-               PWord(Integer(dest)+i*2)^:=((wd and 255) shl 8)+(wd shr 8);
+  if DiagFlip then
+    rw := src.h
+  else
+    rw := src.w;
+
+  with src^ do
+  begin
+    case format of
+      0:
+        begin // 16bits Intel
+          fs.Position := (relX + relY * rw) * 2;
+          fs.Read(dest^, len * 2);
+        end;
+      1:
+        begin // 16bits unsigned Intel
+          fs.Position := (relX + relY * rw) * 2;
+          fs.Read(dest^, len * 2);
+          for i := 0 to len - 1 do
+          begin
+            wd := PWord(Integer(dest) + i * 2)^;
+            PSmallInt(Integer(dest) + i * 2)^ := Integer(wd) - 32768;
+          end;
+        end;
+      2:
+        begin // 16bits non-Intel
+          fs.Position := (relX + relY * rw) * 2;
+          fs.Read(dest^, len * 2);
+          for i := 0 to len - 1 do
+          begin
+            wd := PWord(Integer(dest) + i * 2)^;
+            PWord(Integer(dest) + i * 2)^ := ((wd and 255) shl 8) + (wd shr 8);
+          end;
+        end;
+      3:
+        begin // VTP's BT single
+          fs.Position := (relX + relY * rw) * 4 + 256;
+          SetLength(buf, len);
+          fs.Read(buf[0], len * 4);
+          for i := 0 to len - 1 do
+            PSmallInt(Integer(dest) + i * 2)^ := Round(buf[i]);
+        end;
+      4:
+        begin // windows BMP
+          bmp := TBitmap.Create;
+          try
+            fs.Position := 0;
+            bmp.LoadFromStream(fs);
+            if DiagFlip then
+              rw := bmp.Width
+            else
+              rw := bmp.Height;
+            for i := 0 to len - 1 do
+            begin
+              c := bmp.Canvas.Pixels[relX + i, rw - relY - 1];
+              PSmallInt(Integer(dest) + i * 2)^ := (GetGValue(c) - 128) shl 7;
             end;
             end;
-         end;
-      end;
-   end;
+          finally
+            bmp.Free;
+          end;
+        end;
+      5:
+        begin // 32bits FP Intel
+          fs.Position := (relX + relY * rw) * 4;
+          SetLength(buf, len);
+          fs.Read(buf[0], len * 4);
+          for i := 0 to len - 1 do
+            PSmallInt(Integer(dest) + i * 2)^ := Round((buf[i] - 0.5) * 32000);
+        end;
+      6:
+        begin // DTED
+          fs.Position := 3434 + (relX + relY * rw) * 2 + (relY * 12);
+          fs.Read(dest^, len * 2);
+          for i := 0 to len - 1 do
+          begin
+            wd := PWord(Integer(dest) + i * 2)^;
+            PWord(Integer(dest) + i * 2)^ := ((wd and 255) shl 8) + (wd shr 8);
+          end;
+        end;
+    end;
+  end;
 end;
 end;
 
 
-procedure TMainForm.WorldExtract(x, y, len : Integer; dest : PSmallInt);
+procedure TMainForm.WorldExtract(x, y, len: Integer; dest: PSmallInt);
 var
 var
-   i, n, rx, ry : Integer;
-   src : PSrc;
+  i, n, rx, ry: Integer;
+  src: PSrc;
 begin
 begin
-   while len>0 do begin
-      src:=nil;
-      for i:=0 to High(sources) do begin
-         if (sources[i].x<=x) and (sources[i].y<=y)
-               and (x<sources[i].x+sources[i].w)
-               and (y<sources[i].y+sources[i].h) then begin
-            src:=@sources[i];
-            Break;
-         end;
+  while len > 0 do
+  begin
+    src := nil;
+    for i := 0 to High(sources) do
+    begin
+      if (sources[i].x <= x) and (sources[i].y <= y) and
+        (x < sources[i].x + sources[i].w) and (y < sources[i].y + sources[i].h)
+      then
+      begin
+        src := @sources[i];
+        Break;
+      end;
+    end;
+    if Assigned(src) then
+    begin
+      rx := x - src.x;
+      ry := y - src.y;
+      n := len;
+      if rx + n > src.w then
+        n := src.w - rx;
+      SrcExtractFlip(src, rx, ry, n, dest);
+      if filterZ <> defaultZ then
+      begin
+        for i := 0 to n - 1 do
+          if PSmallIntArray(dest)[i] = filterZ then
+            PSmallIntArray(dest)[i] := defaultZ;
       end;
       end;
-      if Assigned(src) then begin
-         rx:=x-src.x;
-         ry:=y-src.y;
-         n:=len;
-         if rx+n>src.w then
-            n:=src.w-rx;
-         SrcExtractFlip(src, rx, ry, n, dest);
-         if filterZ<>defaultZ then begin
-            for i:=0 to n-1 do
-               if PSmallIntArray(dest)[i]=filterZ then
-                  PSmallIntArray(dest)[i]:=defaultZ;
-         end;
-         if zScale<>1 then begin
-            for i:=0 to n-1 do
-               PSmallIntArray(dest)[i]:=Round(PSmallIntArray(dest)[i]*zScale);
-         end;
-         Dec(len, n);
-         Inc(dest, n);
-         Inc(x, n);
-      end else begin
-         dest^:=defaultZ;
-         Inc(dest);
-         Dec(len);
-         Inc(x);
+      if zScale <> 1 then
+      begin
+        for i := 0 to n - 1 do
+          PSmallIntArray(dest)[i] := Round(PSmallIntArray(dest)[i] * zScale);
       end;
       end;
-   end;
+      Dec(len, n);
+      Inc(dest, n);
+      Inc(x, n);
+    end
+    else
+    begin
+      dest^ := defaultZ;
+      Inc(dest);
+      Dec(len);
+      Inc(x);
+    end;
+  end;
 end;
 end;
 
 
 procedure TMainForm.ACProcessExecute(Sender: TObject);
 procedure TMainForm.ACProcessExecute(Sender: TObject);
 var
 var
-   x, y, wx, wy, ts, tx, ty, i, j, overlap : Integer;
-   n, maxN : Cardinal;
-   htf : TGLHeightTileFile;
-   buf : array of SmallInt;
-   f : file of Byte;
+  x, y, wx, wy, ts, tx, ty, i, j, overlap: Integer;
+  n, maxN: Cardinal;
+  htf: TGLHeightTileFile;
+  buf: array of SmallInt;
+  f: file of Byte;
 begin
 begin
-   Screen.Cursor:=crHourGlass;
-
-   wx:=StrToInt(EDSizeX.Text);
-   wy:=StrToInt(EDSizeY.Text);
-   ts:=StrToInt(EDTileSize.Text);
-   overlap:=StrToInt(EDTileOverlap.Text);
-   Parse;
-   SetLength(buf, ts*ts);
-   htf:=TGLHeightTileFile.CreateNew(EDHTFName.Text, wx, wy, ts);
-   htf.DefaultZ:=defaultZ;
-   ProgressBar.Max:=1000;
-   maxN:=Ceil(wx/ts)*Ceil(wy/ts);
-   n:=0;
-   ProgressBar.Position:=0;
-   y:=0; while y<wy do begin
-      ty:=wy+overlap-y;
-      if ty>ts then
-         ty:=ts;
-      x:=0; while x<wx do begin
-         tx:=wx+overlap-x;
-         if (not CBWholeOnly.Checked) or ((tx>=ts) and ((wy-y)>=ts)) then begin
-            if tx>ts then
-               tx:=ts;
-            for i:=0 to ty-1 do begin
-               WorldExtract(x, y+i, tx, @buf[i*ts]);
-               if overlap>0 then begin
-                  for j:=tx to ts-1 do
-                     buf[i*ts+j]:=buf[i*ts+tx-1];
-               end else begin
-                  for j:=tx to ts-1 do
-                     buf[i*ts+j]:=defaultZ;
-               end;
-            end;
-            if overlap>0 then begin
-               for i:=ty to ts-1 do for j:=0 to ts-1 do
-                  buf[i*ts+j]:=buf[(i-1)*ts+j];
-            end else begin
-               for i:=ty to ts-1 do for j:=0 to ts-1 do
-                  buf[i*ts+j]:=defaultZ;
-            end;
-            htf.CompressTile(x, y, ts, ts, @buf[0]);
-         end;
-         Inc(x, ts-overlap);
-         Inc(n);
-         ProgressBar.Position:=(n*1000) div maxN;
-         if (n and 15)=0 then begin
-            Application.ProcessMessages;
-         end;
+  Screen.Cursor := crHourGlass;
+
+  wx := StrToInt(EDSizeX.Text);
+  wy := StrToInt(EDSizeY.Text);
+  ts := StrToInt(EDTileSize.Text);
+  overlap := StrToInt(EDTileOverlap.Text);
+  Parse;
+  SetLength(buf, ts * ts);
+  htf := TGLHeightTileFile.CreateNew(EDHTFName.Text, wx, wy, ts);
+  htf.defaultZ := defaultZ;
+  ProgressBar.Max := 1000;
+  maxN := Ceil(wx / ts) * Ceil(wy / ts);
+  n := 0;
+  ProgressBar.Position := 0;
+  y := 0;
+  while y < wy do
+  begin
+    ty := wy + overlap - y;
+    if ty > ts then
+      ty := ts;
+    x := 0;
+    while x < wx do
+    begin
+      tx := wx + overlap - x;
+      if (not CBWholeOnly.Checked) or ((tx >= ts) and ((wy - y) >= ts)) then
+      begin
+        if tx > ts then
+          tx := ts;
+        for i := 0 to ty - 1 do
+        begin
+          WorldExtract(x, y + i, tx, @buf[i * ts]);
+          if overlap > 0 then
+          begin
+            for j := tx to ts - 1 do
+              buf[i * ts + j] := buf[i * ts + tx - 1];
+          end
+          else
+          begin
+            for j := tx to ts - 1 do
+              buf[i * ts + j] := defaultZ;
+          end;
+        end;
+        if overlap > 0 then
+        begin
+          for i := ty to ts - 1 do
+            for j := 0 to ts - 1 do
+              buf[i * ts + j] := buf[(i - 1) * ts + j];
+        end
+        else
+        begin
+          for i := ty to ts - 1 do
+            for j := 0 to ts - 1 do
+              buf[i * ts + j] := defaultZ;
+        end;
+        htf.CompressTile(x, y, ts, ts, @buf[0]);
       end;
       end;
-      Inc(y, ts-overlap);
-   end;
-   htf.Free;
-   Cleanup;
+      Inc(x, ts - overlap);
+      Inc(n);
+      ProgressBar.Position := (n * 1000) div maxN;
+      if (n and 15) = 0 then
+      begin
+        Application.ProcessMessages;
+      end;
+    end;
+    Inc(y, ts - overlap);
+  end;
+  htf.Free;
+  Cleanup;
 
 
-   Screen.Cursor:=crDefault;
+  Screen.Cursor := crDefault;
 
 
-   AssignFile(f, EDHTFName.Text);
-   Reset(f);
-   i:=FileSize(f);
-   CloseFile(f);
+  AssignFile(f, EDHTFName.Text);
+  Reset(f);
+  i := FileSize(f);
+  CloseFile(f);
 
 
-   ShowMessage( 'HTF file created.'#13#10#13#10
-               +IntToStr(i)+' bytes in file'#13#10
-               +'('+IntToStr(wx*wy*2)+' raw bytes)');
+  ShowMessage('HTF file created.'#13#10#13#10 + IntToStr(i) +
+    ' bytes in file'#13#10 + '(' + IntToStr(wx * wy * 2) + ' raw bytes)');
 end;
 end;
 
 
 procedure TMainForm.ACViewerExecute(Sender: TObject);
 procedure TMainForm.ACViewerExecute(Sender: TObject);
 var
 var
-   viewer : TViewerForm;
+  viewer: TViewerForm;
 begin
 begin
-   viewer:=TViewerForm.Create(nil);
-   try
-      Viewer.htf:=TGLHeightTileFile.Create(EDHTFName.Text);                   //R
-      Viewer.Caption:='HTFViewer - '+ExtractFileName(EDHTFName.Text);       //R
-
-      viewer.ShowModal;
-   finally
-      viewer.Free;
-   end;
+  viewer := TViewerForm.Create(nil);
+  try
+    viewer.htf := TGLHeightTileFile.Create(EDHTFName.Text); // R
+    viewer.Caption := 'HTFViewer - ' + ExtractFileName(EDHTFName.Text); // R
+
+    viewer.ShowModal;
+  finally
+    viewer.Free;
+  end;
 end;
 end;
 
 
 end.
 end.

+ 38 - 90
Demos/utilities/HTFUtils/fViewer.dfm → Demos/utilities/HTFUtils/fViewerD.dfm

@@ -2,81 +2,56 @@ object ViewerForm: TViewerForm
   Left = 99
   Left = 99
   Top = 98
   Top = 98
   Caption = 'HTFViewer'
   Caption = 'HTFViewer'
-  ClientHeight = 602
-  ClientWidth = 786
+  ClientHeight = 482
+  ClientWidth = 629
   Color = clBtnFace
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
   Font.Color = clWindowText
-  Font.Height = -14
+  Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   Font.Style = []
   Position = poScreenCenter
   Position = poScreenCenter
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   OnDestroy = FormDestroy
-  PixelsPerInch = 120
-  TextHeight = 16
+  TextHeight = 13
   object ToolBar: TToolBar
   object ToolBar: TToolBar
     Left = 0
     Left = 0
     Top = 0
     Top = 0
-    Width = 786
-    Height = 58
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Width = 629
+    Height = 56
     AutoSize = True
     AutoSize = True
     BorderWidth = 1
     BorderWidth = 1
-    ButtonWidth = 246
+    ButtonWidth = 197
     Caption = 'ToolBar'
     Caption = 'ToolBar'
     Images = ImageList
     Images = ImageList
     TabOrder = 0
     TabOrder = 0
     object ToolButton1: TToolButton
     object ToolButton1: TToolButton
       Left = 0
       Left = 0
       Top = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACOpen
       Action = ACOpen
     end
     end
     object ToolButton3: TToolButton
     object ToolButton3: TToolButton
-      Left = 246
+      Left = 197
       Top = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACExit
       Action = ACExit
     end
     end
     object ToolButton2: TToolButton
     object ToolButton2: TToolButton
-      Left = 492
+      Left = 394
       Top = 0
       Top = 0
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 8
       Caption = 'ToolButton2'
       Caption = 'ToolButton2'
       ImageIndex = 1
       ImageIndex = 1
       Style = tbsSeparator
       Style = tbsSeparator
     end
     end
     object ToolButton6: TToolButton
     object ToolButton6: TToolButton
-      Left = 502
+      Left = 402
       Top = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACNavMap
       Action = ACNavMap
     end
     end
     object ToolButton5: TToolButton
     object ToolButton5: TToolButton
       Left = 0
       Left = 0
       Top = 0
       Top = 0
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 8
       Caption = 'ToolButton5'
       Caption = 'ToolButton5'
       ImageIndex = 3
       ImageIndex = 3
       Wrap = True
       Wrap = True
@@ -84,12 +59,8 @@ object ViewerForm: TViewerForm
     end
     end
     object TBGrid: TToolButton
     object TBGrid: TToolButton
       Left = 0
       Left = 0
-      Top = 32
+      Top = 30
       Hint = 'Toggle Grid'
       Hint = 'Toggle Grid'
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Caption = 'TBGrid'
       Caption = 'TBGrid'
       Down = True
       Down = True
       ImageIndex = 3
       ImageIndex = 3
@@ -97,41 +68,29 @@ object ViewerForm: TViewerForm
       OnClick = TBGridClick
       OnClick = TBGridClick
     end
     end
     object ToolButton7: TToolButton
     object ToolButton7: TToolButton
-      Left = 246
-      Top = 32
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 197
+      Top = 30
       Action = ACPalette
       Action = ACPalette
       DropdownMenu = PMPalettes
       DropdownMenu = PMPalettes
       Style = tbsDropDown
       Style = tbsDropDown
     end
     end
     object ToolButton4: TToolButton
     object ToolButton4: TToolButton
-      Left = 511
-      Top = 32
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 413
+      Top = 30
+      Width = 8
       Caption = 'ToolButton4'
       Caption = 'ToolButton4'
       ImageIndex = 2
       ImageIndex = 2
       Style = tbsSeparator
       Style = tbsSeparator
     end
     end
     object LAMap: TLabel
     object LAMap: TLabel
-      Left = 521
-      Top = 32
-      Width = 61
-      Height = 22
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 421
+      Top = 30
+      Width = 49
+      Height = 16
       Caption = ' No map'
       Caption = ' No map'
       Font.Charset = ANSI_CHARSET
       Font.Charset = ANSI_CHARSET
       Font.Color = clWindowText
       Font.Color = clWindowText
-      Font.Height = -16
+      Font.Height = -13
       Font.Name = 'Arial'
       Font.Name = 'Arial'
       Font.Style = [fsItalic]
       Font.Style = [fsItalic]
       ParentFont = False
       ParentFont = False
@@ -140,60 +99,49 @@ object ViewerForm: TViewerForm
   end
   end
   object PaintBox: TPaintBox32
   object PaintBox: TPaintBox32
     Left = 0
     Left = 0
-    Top = 58
-    Width = 786
-    Height = 520
+    Top = 56
+    Width = 629
+    Height = 406
     Cursor = crCross
     Cursor = crCross
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
     Align = alClient
     Align = alClient
     TabOrder = 1
     TabOrder = 1
     OnMouseDown = PaintBoxMouseDown
     OnMouseDown = PaintBoxMouseDown
     OnMouseMove = PaintBoxMouseMove
     OnMouseMove = PaintBoxMouseMove
     OnMouseUp = PaintBoxMouseUp
     OnMouseUp = PaintBoxMouseUp
     OnResize = PaintBoxResize
     OnResize = PaintBoxResize
-    ExplicitTop = 1452
-    ExplicitWidth = 721
-    ExplicitHeight = 456
+    ExplicitTop = 46
+    ExplicitHeight = 416
   end
   end
   object StatusBar: TStatusBar
   object StatusBar: TStatusBar
     Left = 0
     Left = 0
-    Top = 578
-    Width = 786
-    Height = 24
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Top = 462
+    Width = 629
+    Height = 20
     Font.Charset = ANSI_CHARSET
     Font.Charset = ANSI_CHARSET
     Font.Color = clBtnText
     Font.Color = clBtnText
-    Font.Height = -14
+    Font.Height = -11
     Font.Name = 'Arial'
     Font.Name = 'Arial'
     Font.Style = []
     Font.Style = []
     Panels = <
     Panels = <
       item
       item
-        Width = 81
+        Width = 65
       end
       end
       item
       item
-        Width = 81
+        Width = 65
       end
       end
       item
       item
-        Width = 81
+        Width = 65
       end
       end
       item
       item
-        Width = 81
+        Width = 65
       end
       end
       item
       item
-        Width = 131
+        Width = 105
       end
       end
       item
       item
-        Width = 63
+        Width = 50
       end>
       end>
     UseSystemFont = False
     UseSystemFont = False
-    ExplicitTop = 489
-    ExplicitWidth = 721
   end
   end
   object ImageList: TImageList
   object ImageList: TImageList
     Left = 40
     Left = 40

+ 7 - 5
Demos/utilities/HTFUtils/fViewer.pas → Demos/utilities/HTFUtils/fViewerD.pas

@@ -1,4 +1,4 @@
-unit fViewer;
+unit fViewerD;
 
 
 interface
 interface
 
 
@@ -7,6 +7,7 @@ uses
   System.SysUtils,
   System.SysUtils,
   System.Classes,
   System.Classes,
   System.Actions,
   System.Actions,
+  System.ImageList,
   Vcl.Graphics,
   Vcl.Graphics,
   Vcl.Controls,
   Vcl.Controls,
   Vcl.Forms,
   Vcl.Forms,
@@ -24,7 +25,7 @@ uses
 
 
   GLS.HeightTileFileHDS,
   GLS.HeightTileFileHDS,
   GLS.VectorGeometry,
   GLS.VectorGeometry,
-  GLS.Utils, System.ImageList;
+  GLS.Utils;
 
 
 type
 type
   TViewerForm = class(TForm)
   TViewerForm = class(TForm)
@@ -85,13 +86,14 @@ implementation
 uses
 uses
   fNavD;
   fNavD;
 
 
-{ Quick'n dirty parser for palette file format '.pal', in which each line defines
+(*
+  Quick'n dirty parser for palette file format '.pal', in which each line defines
   nodes in the color ramp palette:
   nodes in the color ramp palette:
 
 
   value:red,green,blue
   value:red,green,blue
 
 
   color is then interpolated between node values (ie. between each line in the file)
   color is then interpolated between node values (ie. between each line in the file)
-}
+*)
 procedure PreparePal(const fileName: String);
 procedure PreparePal(const fileName: String);
 
 
   procedure ParseLine(buf: String; var n: Integer; var c: TAffineVector);
   procedure ParseLine(buf: String; var n: Integer; var c: TAffineVector);
@@ -224,7 +226,7 @@ var
   scanLine: PColor32Array;
   scanLine: PColor32Array;
   tileInfo: PGLHeightTileInfo;
   tileInfo: PGLHeightTileInfo;
   dataRow: PSmallIntArray;
   dataRow: PSmallIntArray;
-  tile: PHeightTile;
+  tile: PGLHeightTile;
   start, lap, stop, htfTime, drawTime, freq: Int64;
   start, lap, stop, htfTime, drawTime, freq: Int64;
   tileList: TList;
   tileList: TList;
   bmp: TBitmap32;
   bmp: TBitmap32;

+ 244 - 136
Source/GLS.Utils.pas

@@ -2,9 +2,12 @@
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
 unit GLS.Utils;
 unit GLS.Utils;
+
 (* Miscellaneous support utilities & classes for localization *)
 (* Miscellaneous support utilities & classes for localization *)
 interface
 interface
+
 {$I GLScene.inc}
 {$I GLScene.inc}
+
 uses
 uses
   Winapi.Windows,
   Winapi.Windows,
   Winapi.ShellApi,
   Winapi.ShellApi,
@@ -18,22 +21,26 @@ uses
   Vcl.ExtDlgs,
   Vcl.ExtDlgs,
   GLS.VectorGeometry,
   GLS.VectorGeometry,
   GLS.Strings;
   GLS.Strings;
+
 type
 type
   THalfFloat = type Word;
   THalfFloat = type Word;
   PHalfFloat = ^THalfFloat;
   PHalfFloat = ^THalfFloat;
   EGLOSError = EOSError;
   EGLOSError = EOSError;
   EGLUtilsException = class(Exception);
   EGLUtilsException = class(Exception);
-  TSqrt255Array = array[0..255] of Byte;
+  TSqrt255Array = array [0 .. 255] of Byte;
   PSqrt255Array = ^TSqrt255Array;
   PSqrt255Array = ^TSqrt255Array;
   TProjectTargetNameFunc = function(): string;
   TProjectTargetNameFunc = function(): string;
+
 const
 const
   FONT_CHARS_COUNT = 2024;
   FONT_CHARS_COUNT = 2024;
+
 var
 var
   IsDesignTime: Boolean = False;
   IsDesignTime: Boolean = False;
   vProjectTargetName: TProjectTargetNameFunc;
   vProjectTargetName: TProjectTargetNameFunc;
 
 
 // Copies the values of Source to Dest (converting word values to integer values)
 // Copies the values of Source to Dest (converting word values to integer values)
-procedure WordToIntegerArray(Source: PWordArray; Dest: PIntegerArray; Count: Cardinal);
+procedure WordToIntegerArray(Source: PWordArray; Dest: PIntegerArray;
+  Count: Cardinal);
 // Round ups to the nearest power of two, value must be positive
 // Round ups to the nearest power of two, value must be positive
 function RoundUpToPowerOf2(value: Integer): Integer;
 function RoundUpToPowerOf2(value: Integer): Integer;
 // Round down to the nearest power of two, value must be strictly positive
 // Round down to the nearest power of two, value must be strictly positive
@@ -45,60 +52,69 @@ function ReadCRLFString(aStream: TStream): String;
 // Write the string and a CRLF in the stream
 // Write the string and a CRLF in the stream
 procedure WriteCRLFString(aStream: TStream; const aString: String);
 procedure WriteCRLFString(aStream: TStream; const aString: String);
 // Similar to SysUtils.StrToFloatDef, but ignores user's locale
 // Similar to SysUtils.StrToFloatDef, but ignores user's locale
-function StrToFloatDef(const strValue: string; defValue: Extended = 0): Extended;
+function StrToFloatDef(const strValue: string; defValue: Extended = 0)
+  : Extended;
+// Trying to read string otherwise using '.' as Decimal Separator
+function Str2Float(const S: string): Single;
 // Converts a string into color
 // Converts a string into color
-function StringToColorAdvancedSafe(const Str: string; const Default: TColor): TColor;
+function StringToColorAdvancedSafe(const Str: string;
+  const Default: TColor): TColor;
 // Converts a string into color
 // Converts a string into color
-function TryStringToColorAdvanced(const Str: string; var OutColor: TColor): Boolean;
+function TryStringToColorAdvanced(const Str: string;
+  var OutColor: TColor): Boolean;
 // Converts a string into color
 // Converts a string into color
 function StringToColorAdvanced(const Str: string): TColor;
 function StringToColorAdvanced(const Str: string): TColor;
-(*Parses the next integer in the string. 
-   Initial non-numeric characters are skipper, p is altered, returns 0 if none
-   found. '+' and '-' are acknowledged. *)
+(* Parses the next integer in the string.
+  Initial non-numeric characters are skipper, p is altered, returns 0 if none
+  found. '+' and '-' are acknowledged. *)
 function ParseInteger(var p: PChar): Integer;
 function ParseInteger(var p: PChar): Integer;
-(* Parses the next integer in the string. 
-   Initial non-numeric characters are skipper, p is altered, returns 0 if none
-   found. Both '.' and ',' are accepted as decimal separators. *)
+(* Parses the next integer in the string.
+  Initial non-numeric characters are skipper, p is altered, returns 0 if none
+  found. Both '.' and ',' are accepted as decimal separators. *)
 function ParseFloat(var p: PChar): Extended;
 function ParseFloat(var p: PChar): Extended;
-//Saves ansistring "data" to "filename". 
+// Saves ansistring "data" to "filename".
 procedure SaveAnsiStringToFile(const fileName: string; const data: AnsiString);
 procedure SaveAnsiStringToFile(const fileName: string; const data: AnsiString);
-//Returns the ansistring content of "filename". 
+// Returns the ansistring content of "filename".
 function LoadAnsiStringFromFile(const fileName: string): AnsiString;
 function LoadAnsiStringFromFile(const fileName: string): AnsiString;
-//Saves string "data" to "filename". 
+// Saves string "data" to "filename".
 procedure SaveStringToFile(const fileName: string; const data: String);
 procedure SaveStringToFile(const fileName: string; const data: String);
-//Returns the string content of "filename". 
+// Returns the string content of "filename".
 function LoadStringFromFile(const fileName: string): String;
 function LoadStringFromFile(const fileName: string): String;
-//Saves component to a file.
-procedure SaveComponentToFile(const Component: TComponent; const FileName: string; const AsText: Boolean = True);
+// Saves component to a file.
+procedure SaveComponentToFile(const Component: TComponent;
+  const fileName: string; const AsText: Boolean = True);
 // Loads component from a file.
 // Loads component from a file.
-procedure LoadComponentFromFile(const Component: TComponent; const FileName: string; const AsText: Boolean = True);
-(* Returns the size of "filename". 
-   Returns 0 (zero) is file does not exists. *)
+procedure LoadComponentFromFile(const Component: TComponent;
+  const fileName: string; const AsText: Boolean = True);
+(* Returns the size of "filename".
+  Returns 0 (zero) is file does not exists. *)
 function SizeOfFile(const fileName: string): Int64;
 function SizeOfFile(const fileName: string): Int64;
-// Returns a pointer to an array containing the results of "255*sqrt(i/255)". 
+// Returns a pointer to an array containing the results of "255*sqrt(i/255)".
 function GetSqrt255Array: PSqrt255Array;
 function GetSqrt255Array: PSqrt255Array;
-// Pops up a simple dialog with msg and an Ok button. 
+// Pops up a simple dialog with msg and an Ok button.
 procedure InformationDlg(const msg: string);
 procedure InformationDlg(const msg: string);
 (* Pops up a simple question dialog with msg and yes/no buttons.
 (* Pops up a simple question dialog with msg and yes/no buttons.
-   Returns True if answer was "yes". *)
+  Returns True if answer was "yes". *)
 function QuestionDlg(const msg: string): Boolean;
 function QuestionDlg(const msg: string): Boolean;
 // Posp a simple dialog with a string input.
 // Posp a simple dialog with a string input.
 function InputDlg(const aCaption, aPrompt, aDefault: string): string;
 function InputDlg(const aCaption, aPrompt, aDefault: string): string;
 // Pops up a simple save picture dialog.
 // Pops up a simple save picture dialog.
-function SavePictureDialog(var aFileName: string; const aTitle: string = ''): Boolean;
+function SavePictureDialog(var aFileName: string;
+  const aTitle: string = ''): Boolean;
 // Pops up a simple open picture dialog.
 // Pops up a simple open picture dialog.
-function OpenPictureDialog(var aFileName: string; const aTitle: string = ''): Boolean;
+function OpenPictureDialog(var aFileName: string;
+  const aTitle: string = ''): Boolean;
 procedure SetGLSceneMediaDir();
 procedure SetGLSceneMediaDir();
-//------------------ from CrossPlatform -----------------------
+// ------------------ from CrossPlatform -----------------------
 function GetGLRect(const aLeft, aTop, aRight, aBottom: Integer): TRect;
 function GetGLRect(const aLeft, aTop, aRight, aBottom: Integer): TRect;
 (* Increases or decreases the width and height of the specified rectangle.
 (* Increases or decreases the width and height of the specified rectangle.
-   Adds dx units to the left and right ends of the rectangle and dy units to
-   the top and bottom. *)
+  Adds dx units to the left and right ends of the rectangle and dy units to
+  the top and bottom. *)
 procedure InflateGLRect(var aRect: TRect; dx, dy: Integer);
 procedure InflateGLRect(var aRect: TRect; dx, dy: Integer);
 procedure IntersectGLRect(var aRect: TRect; const rect2: TRect);
 procedure IntersectGLRect(var aRect: TRect; const rect2: TRect);
 procedure RaiseLastOSError;
 procedure RaiseLastOSError;
 (* Number of pixels per logical inch along the screen width for the device.
 (* Number of pixels per logical inch along the screen width for the device.
-   Under Win32 awaits a HDC and returns its LOGPIXELSX. *)
+  Under Win32 awaits a HDC and returns its LOGPIXELSX. *)
 function GetDeviceLogicalPixelsX(device: HDC): Integer;
 function GetDeviceLogicalPixelsX(device: HDC): Integer;
 // Number of bits per pixel for the current desktop resolution.
 // Number of bits per pixel for the current desktop resolution.
 function GetCurrentColorDepth: Integer;
 function GetCurrentColorDepth: Integer;
@@ -109,20 +125,20 @@ procedure FixPathDelimiter(var S: string);
 // Remove if possible part of path witch leads to project executable.
 // Remove if possible part of path witch leads to project executable.
 function RelativePath(const S: string): string;
 function RelativePath(const S: string): string;
 (* Returns the current value of the highest-resolution counter.
 (* Returns the current value of the highest-resolution counter.
-   If the platform has none, should return a value derived from the highest
-   precision time reference available, avoiding, if possible, timers that
-   allocate specific system resources. *)
+  If the platform has none, should return a value derived from the highest
+  precision time reference available, avoiding, if possible, timers that
+  allocate specific system resources. *)
 procedure QueryPerformanceCounter(out val: Int64);
 procedure QueryPerformanceCounter(out val: Int64);
 (* Returns the frequency of the counter used by QueryPerformanceCounter.
 (* Returns the frequency of the counter used by QueryPerformanceCounter.
-   Return value is in ticks per second (Hz), returns False if no precision
-   counter is available. *)
+  Return value is in ticks per second (Hz), returns False if no precision
+  counter is available. *)
 function QueryPerformanceFrequency(out val: Int64): Boolean;
 function QueryPerformanceFrequency(out val: Int64): Boolean;
 (* Starts a precision timer.
 (* Starts a precision timer.
-   Returned value should just be considered as 'handle', even if it ain't so.
-   Default platform implementation is to use QueryPerformanceCounter and
-   QueryPerformanceFrequency, if higher precision references are available,
-   they should be used. The timer will and must be stopped/terminated/released
-   with StopPrecisionTimer. *)
+  Returned value should just be considered as 'handle', even if it ain't so.
+  Default platform implementation is to use QueryPerformanceCounter and
+  QueryPerformanceFrequency, if higher precision references are available,
+  they should be used. The timer will and must be stopped/terminated/released
+  with StopPrecisionTimer. *)
 function StartPrecisionTimer: Int64;
 function StartPrecisionTimer: Int64;
 // Computes time elapsed since timer start. Return time lap in seconds.
 // Computes time elapsed since timer start. Return time lap in seconds.
 function PrecisionTimerLap(const precisionTimer: Int64): Double;
 function PrecisionTimerLap(const precisionTimer: Int64): Double;
@@ -132,35 +148,40 @@ function StopPrecisionTimer(const precisionTimer: Int64): Double;
 function AppTime: Double;
 function AppTime: Double;
 // Returns the number of CPU cycles since startup. Use the similarly named CPU instruction.
 // Returns the number of CPU cycles since startup. Use the similarly named CPU instruction.
 function GLOKMessageBox(const Text, Caption: string): Integer;
 function GLOKMessageBox(const Text, Caption: string): Integer;
-procedure GLLoadBitmapFromInstance(Instance: LongInt; ABitmap: TBitmap; const AName: string);
+procedure GLLoadBitmapFromInstance(Instance: LongInt; ABitmap: TBitmap;
+  const AName: string);
 procedure ShowHTMLUrl(const Url: string);
 procedure ShowHTMLUrl(const Url: string);
 procedure SetExeDirectory;
 procedure SetExeDirectory;
 // StrUtils.pas
 // StrUtils.pas
 function AnsiStartsText(const ASubText, AText: string): Boolean;
 function AnsiStartsText(const ASubText, AText: string): Boolean;
 // Classes.pas
 // Classes.pas
 function IsSubComponent(const AComponent: TComponent): Boolean; inline;
 function IsSubComponent(const AComponent: TComponent): Boolean; inline;
-procedure MakeSubComponent(const AComponent: TComponent; const Value: Boolean);
+procedure MakeSubComponent(const AComponent: TComponent; const value: Boolean);
 function FindUnitName(anObject: TObject): string; overload;
 function FindUnitName(anObject: TObject): string; overload;
 function FindUnitName(aClass: TClass): string; overload;
 function FindUnitName(aClass: TClass): string; overload;
 function FloatToHalf(Float: Single): THalfFloat;
 function FloatToHalf(Float: Single): THalfFloat;
 function HalfToFloat(Half: THalfFloat): Single;
 function HalfToFloat(Half: THalfFloat): Single;
-function GetValueFromStringsIndex(const AStrings: TStrings; const AIndex: Integer): string;
+function GetValueFromStringsIndex(const AStrings: TStrings;
+  const AIndex: Integer): string;
 // Determine if the directory is writable.
 // Determine if the directory is writable.
 function IsDirectoryWriteable(const AName: string): Boolean;
 function IsDirectoryWriteable(const AName: string): Boolean;
 function CharToWideChar(const AChar: AnsiChar): WideChar;
 function CharToWideChar(const AChar: AnsiChar): WideChar;
 
 
-(* 
+(*
   Added by PAL to fix problem with decimal separator in not En-US configurations
   Added by PAL to fix problem with decimal separator in not En-US configurations
-  Decimal separator in text descriptions of meshes for import/export is always '.' char 
+  Decimal separator in text descriptions of meshes for import/export is always '.' char
   But in System.SysUtils.TextToFloat is Windows char, maybe ',' or others...
   But in System.SysUtils.TextToFloat is Windows char, maybe ',' or others...
 *)
 *)
-function GLStrToFloatDef(const S: string; const Default: Extended; fs: TFormatSettings): Extended; overload;
-function GLStrToFloatDef(const S: string; const Default: Extended): Extended; overload;
+function GLStrToFloatDef(const S: string; const Default: Extended;
+  fs: TFormatSettings): Extended; overload;
+function GLStrToFloatDef(const S: string; const Default: Extended)
+  : Extended; overload;
 function GLStrToFloatDef(const S: string): Extended; overload;
 function GLStrToFloatDef(const S: string): Extended; overload;
 
 
-//------------------------------------------------------
+// ------------------------------------------------------
 implementation
 implementation
-//------------------------------------------------------
+
+// ------------------------------------------------------
 
 
 var
 var
   vSqrt255: TSqrt255Array;
   vSqrt255: TSqrt255Array;
@@ -168,20 +189,23 @@ var
   vInvPerformanceCounterFrequencyReady: Boolean = False;
   vInvPerformanceCounterFrequencyReady: Boolean = False;
   vLastProjectTargetName: string;
   vLastProjectTargetName: string;
 
 
-//---------------from Utils -----------------------
-procedure WordToIntegerArray(Source: PWordArray; Dest: PIntegerArray; Count: Cardinal);
+  // ---------------from Utils -----------------------
+procedure WordToIntegerArray(Source: PWordArray; Dest: PIntegerArray;
+  Count: Cardinal);
 var
 var
-  i: integer;
+  i: Integer;
 begin
 begin
   for i := 0 to Count - 1 do
   for i := 0 to Count - 1 do
     Dest^[i] := Source^[i];
     Dest^[i] := Source^[i];
 end;
 end;
+
 function RoundUpToPowerOf2(value: Integer): Integer;
 function RoundUpToPowerOf2(value: Integer): Integer;
 begin
 begin
   Result := 1;
   Result := 1;
   while (Result < value) do
   while (Result < value) do
     Result := Result shl 1;
     Result := Result shl 1;
 end;
 end;
+
 function RoundDownToPowerOf2(value: Integer): Integer;
 function RoundDownToPowerOf2(value: Integer): Integer;
 begin
 begin
   if value > 0 then
   if value > 0 then
@@ -193,10 +217,12 @@ begin
   else
   else
     Result := 1;
     Result := 1;
 end;
 end;
+
 function IsPowerOf2(value: Integer): Boolean;
 function IsPowerOf2(value: Integer): Boolean;
 begin
 begin
   Result := (RoundUpToPowerOf2(value) = value);
   Result := (RoundUpToPowerOf2(value) = value);
 end;
 end;
+
 function ReadCRLFString(aStream: TStream): String;
 function ReadCRLFString(aStream: TStream): String;
 var
 var
   c: Char;
   c: Char;
@@ -209,6 +235,7 @@ begin
   end;
   end;
   Result := Copy(Result, 1, Length(Result) - 2);
   Result := Copy(Result, 1, Length(Result) - 2);
 end;
 end;
+
 procedure WriteCRLFString(aStream: TStream; const aString: String);
 procedure WriteCRLFString(aStream: TStream; const aString: String);
 const
 const
   cCRLF: Integer = $0A0D;
   cCRLF: Integer = $0A0D;
@@ -220,46 +247,65 @@ begin
   end;
   end;
 end;
 end;
 
 
-function StrToFloatDef(const strValue: string; defValue: Extended = 0): Extended;
+function StrToFloatDef(const strValue: string; defValue: Extended = 0)
+  : Extended;
 begin
 begin
   if not TryStrToFloat(strValue, Result) then
   if not TryStrToFloat(strValue, Result) then
-    result := defValue;
+    Result := defValue;
 end;
 end;
-function StringToColorAdvancedSafe(const Str: string; const Default: TColor): TColor;
+
+function Str2Float(const S: string): Single;
+var
+  fs: TFormatSettings;
+begin                                                                                                           fs.DecimalSeparator := ',';
+  if not TryStrToFloat(S, Result, fs) then
+  begin
+    fs.DecimalSeparator := '.';
+    if not TryStrToFloat(S, Result, fs) then
+      Result := 0;
+  end;
+end;
+
+function StringToColorAdvancedSafe(const Str: string;
+  const Default: TColor): TColor;
 begin
 begin
   if not TryStringToColorAdvanced(Str, Result) then
   if not TryStringToColorAdvanced(Str, Result) then
     Result := Default;
     Result := Default;
 end;
 end;
+
 function StringToColorAdvanced(const Str: string): TColor;
 function StringToColorAdvanced(const Str: string): TColor;
 begin
 begin
   if not TryStringToColorAdvanced(Str, Result) then
   if not TryStringToColorAdvanced(Str, Result) then
     raise EGLUtilsException.CreateResFmt(@strInvalidColor, [Str]);
     raise EGLUtilsException.CreateResFmt(@strInvalidColor, [Str]);
 end;
 end;
-function TryStringToColorAdvanced(const Str: string; var OutColor: TColor): Boolean;
+
+function TryStringToColorAdvanced(const Str: string;
+  var OutColor: TColor): Boolean;
 var
 var
-  Code, I: Integer;
+  Code, i: Integer;
   Temp: string;
   Temp: string;
 begin
 begin
   Result := True;
   Result := True;
   Temp := Str;
   Temp := Str;
-  Val(Temp, I, Code); //to see if it is a number
+  val(Temp, i, Code); // to see if it is a number
   if Code = 0 then
   if Code = 0 then
-    OutColor := TColor(I) //Str = $0000FF
+    OutColor := TColor(i) // Str = $0000FF
   else
   else
   begin
   begin
-    if not IdentToColor(Temp, Longint(OutColor)) then //Str = clRed
+    if not IdentToColor(Temp, LongInt(OutColor)) then // Str = clRed
     begin
     begin
-      if AnsiStartsText('clr', Temp) then //Str = clrRed
+      if AnsiStartsText('clr', Temp) then // Str = clrRed
       begin
       begin
         Delete(Temp, 3, 1);
         Delete(Temp, 3, 1);
-        if not IdentToColor(Temp, Longint(OutColor)) then
+        if not IdentToColor(Temp, LongInt(OutColor)) then
           Result := False;
           Result := False;
       end
       end
-      else if not IdentToColor('cl' + Temp, Longint(OutColor)) then //Str = Red
+      else if not IdentToColor('cl' + Temp, LongInt(OutColor)) then // Str = Red
         Result := False;
         Result := False;
     end;
     end;
   end;
   end;
 end;
 end;
+
 function ParseInteger(var p: PChar): Integer;
 function ParseInteger(var p: PChar): Integer;
 var
 var
   neg: Boolean;
   neg: Boolean;
@@ -270,7 +316,7 @@ begin
     Exit;
     Exit;
   neg := False;
   neg := False;
   // skip non-numerics
   // skip non-numerics
-  while not CharInSet(p^, [#0, '0'..'9', '+', '-']) do
+  while not CharInSet(p^, [#0, '0' .. '9', '+', '-']) do
     Inc(p);
     Inc(p);
   c := p^;
   c := p^;
   if c = '+' then
   if c = '+' then
@@ -284,7 +330,7 @@ begin
   while True do
   while True do
   begin
   begin
     c := p^;
     c := p^;
-    if not CharInSet(c, ['0'..'9']) then
+    if not CharInSet(c, ['0' .. '9']) then
       Break;
       Break;
     Result := Result * 10 + Integer(c) - Integer('0');
     Result := Result * 10 + Integer(c) - Integer('0');
     Inc(p);
     Inc(p);
@@ -292,6 +338,7 @@ begin
   if neg then
   if neg then
     Result := -Result;
     Result := -Result;
 end;
 end;
+
 function ParseFloat(var p: PChar): Extended;
 function ParseFloat(var p: PChar): Extended;
 var
 var
   decimals, expSign, exponent: Integer;
   decimals, expSign, exponent: Integer;
@@ -302,7 +349,7 @@ begin
   if p = nil then
   if p = nil then
     Exit;
     Exit;
   // skip non-numerics
   // skip non-numerics
-  while not CharInSet(p^, [#0, '0'..'9', '+', '-']) do
+  while not CharInSet(p^, [#0, '0' .. '9', '+', '-']) do
     Inc(p);
     Inc(p);
   c := p^;
   c := p^;
   if c = '+' then
   if c = '+' then
@@ -318,7 +365,7 @@ begin
   else
   else
     neg := False;
     neg := False;
   // parse numbers
   // parse numbers
-  while CharInSet(p^, ['0'..'9']) do
+  while CharInSet(p^, ['0' .. '9']) do
   begin
   begin
     Result := Result * 10 + (Integer(p^) - Integer('0'));
     Result := Result * 10 + (Integer(p^) - Integer('0'));
     Inc(p);
     Inc(p);
@@ -328,7 +375,7 @@ begin
   if (p^ = '.') then
   if (p^ = '.') then
   begin
   begin
     Inc(p);
     Inc(p);
-    while CharInSet(p^, ['0'..'9']) do
+    while CharInSet(p^, ['0' .. '9']) do
     begin
     begin
       Result := Result * 10 + (Integer(p^) - Integer('0'));
       Result := Result * 10 + (Integer(p^) - Integer('0'));
       Inc(p);
       Inc(p);
@@ -355,7 +402,7 @@ begin
       expSign := 1;
       expSign := 1;
     // parse exponent
     // parse exponent
     exponent := 0;
     exponent := 0;
-    while CharInSet(p^, ['0'..'9']) do
+    while CharInSet(p^, ['0' .. '9']) do
     begin
     begin
       exponent := exponent * 10 + (Integer(p^) - Integer('0'));
       exponent := exponent * 10 + (Integer(p^) - Integer('0'));
       Inc(p);
       Inc(p);
@@ -367,6 +414,7 @@ begin
   if neg then
   if neg then
     Result := -Result;
     Result := -Result;
 end;
 end;
+
 procedure SaveAnsiStringToFile(const fileName: string; const data: AnsiString);
 procedure SaveAnsiStringToFile(const fileName: string; const data: AnsiString);
 var
 var
   n: Cardinal;
   n: Cardinal;
@@ -381,6 +429,7 @@ begin
     fs.Free;
     fs.Free;
   end;
   end;
 end;
 end;
+
 function LoadAnsiStringFromFile(const fileName: string): AnsiString;
 function LoadAnsiStringFromFile(const fileName: string): AnsiString;
 var
 var
   n: Cardinal;
   n: Cardinal;
@@ -401,6 +450,7 @@ begin
   else
   else
     Result := '';
     Result := '';
 end;
 end;
+
 procedure SaveStringToFile(const fileName: string; const data: String);
 procedure SaveStringToFile(const fileName: string; const data: String);
 var
 var
   n: Cardinal;
   n: Cardinal;
@@ -415,6 +465,7 @@ begin
     fs.Free;
     fs.Free;
   end;
   end;
 end;
 end;
+
 function LoadStringFromFile(const fileName: string): String;
 function LoadStringFromFile(const fileName: string): String;
 var
 var
   n: Cardinal;
   n: Cardinal;
@@ -436,12 +487,13 @@ begin
     Result := '';
     Result := '';
 end;
 end;
 
 
-procedure SaveComponentToFile(const Component: TComponent; const FileName: string; const AsText: Boolean);
+procedure SaveComponentToFile(const Component: TComponent;
+  const fileName: string; const AsText: Boolean);
 var
 var
   Stream: TStream;
   Stream: TStream;
   MemStream: TMemoryStream;
   MemStream: TMemoryStream;
 begin
 begin
-  Stream := TFileStream.Create(FileName, fmCreate);
+  Stream := TFileStream.Create(fileName, fmCreate);
   try
   try
     if AsText then
     if AsText then
     begin
     begin
@@ -460,12 +512,14 @@ begin
     Stream.Free;
     Stream.Free;
   end;
   end;
 end;
 end;
-procedure LoadComponentFromFile(const Component: TComponent; const FileName: string; const AsText: Boolean = True);
+
+procedure LoadComponentFromFile(const Component: TComponent;
+  const fileName: string; const AsText: Boolean = True);
 var
 var
   Stream: TStream;
   Stream: TStream;
   MemStream: TMemoryStream;
   MemStream: TMemoryStream;
 begin
 begin
-  Stream := TFileStream.Create(FileName, fmOpenRead);
+  Stream := TFileStream.Create(fileName, fmOpenRead);
   try
   try
     if AsText then
     if AsText then
     begin
     begin
@@ -484,6 +538,7 @@ begin
     Stream.Free;
     Stream.Free;
   end;
   end;
 end;
 end;
+
 function SizeOfFile(const fileName: string): Int64;
 function SizeOfFile(const fileName: string): Int64;
 var
 var
   fs: TStream;
   fs: TStream;
@@ -500,6 +555,7 @@ begin
   else
   else
     Result := 0;
     Result := 0;
 end;
 end;
+
 function GetSqrt255Array: PSqrt255Array;
 function GetSqrt255Array: PSqrt255Array;
 const
 const
   cOneDiv255 = 1 / 255;
   cOneDiv255 = 1 / 255;
@@ -513,19 +569,24 @@ begin
   end;
   end;
   Result := @vSqrt255;
   Result := @vSqrt255;
 end;
 end;
+
 procedure InformationDlg(const msg: string);
 procedure InformationDlg(const msg: string);
 begin
 begin
   ShowMessage(msg);
   ShowMessage(msg);
 end;
 end;
+
 function QuestionDlg(const msg: string): Boolean;
 function QuestionDlg(const msg: string): Boolean;
 begin
 begin
   Result := (MessageDlg(msg, mtConfirmation, [mbYes, mbNo], 0) = mrYes);
   Result := (MessageDlg(msg, mtConfirmation, [mbYes, mbNo], 0) = mrYes);
 end;
 end;
+
 function InputDlg(const aCaption, aPrompt, aDefault: string): string;
 function InputDlg(const aCaption, aPrompt, aDefault: string): string;
 begin
 begin
   Result := InputBox(aCaption, aPrompt, aDefault);
   Result := InputBox(aCaption, aPrompt, aDefault);
 end;
 end;
-function SavePictureDialog(var aFileName: string; const aTitle: string = ''): Boolean;
+
+function SavePictureDialog(var aFileName: string;
+  const aTitle: string = ''): Boolean;
 var
 var
   saveDialog: TSavePictureDialog;
   saveDialog: TSavePictureDialog;
 begin
 begin
@@ -536,16 +597,18 @@ begin
       Options := [ofHideReadOnly, ofNoReadOnlyReturn];
       Options := [ofHideReadOnly, ofNoReadOnlyReturn];
       if aTitle <> '' then
       if aTitle <> '' then
         Title := aTitle;
         Title := aTitle;
-      FileName := aFileName;
+      fileName := aFileName;
       Result := Execute;
       Result := Execute;
       if Result then
       if Result then
-        aFileName := FileName;
+        aFileName := fileName;
     end;
     end;
   finally
   finally
     saveDialog.Free;
     saveDialog.Free;
   end;
   end;
 end;
 end;
-function OpenPictureDialog(var aFileName: string; const aTitle: string = ''): Boolean;
+
+function OpenPictureDialog(var aFileName: string;
+  const aTitle: string = ''): Boolean;
 var
 var
   openDialog: TOpenPictureDialog;
   openDialog: TOpenPictureDialog;
 begin
 begin
@@ -556,28 +619,29 @@ begin
       Options := [ofHideReadOnly, ofNoReadOnlyReturn];
       Options := [ofHideReadOnly, ofNoReadOnlyReturn];
       if aTitle <> '' then
       if aTitle <> '' then
         Title := aTitle;
         Title := aTitle;
-      FileName := aFileName;
+      fileName := aFileName;
       Result := Execute;
       Result := Execute;
       if Result then
       if Result then
-        aFileName := FileName;
+        aFileName := fileName;
     end;
     end;
   finally
   finally
     openDialog.Free;
     openDialog.Free;
   end;
   end;
 end;
 end;
+
 procedure SetGLSceneMediaDir();
 procedure SetGLSceneMediaDir();
 var
 var
   path: String;
   path: String;
   p: Integer;
   p: Integer;
 begin
 begin
-   path := ParamStr(0);
-   path := LowerCase(ExtractFilePath(path));
-   p := Pos('demos', path);
-   Delete(path, p+5, Length(path));
-   path := IncludeTrailingPathDelimiter(path) + 'media';
-   SetCurrentDir(path);
+  path := ParamStr(0);
+  path := LowerCase(ExtractFilePath(path));
+  p := Pos('demos', path);
+  Delete(path, p + 5, Length(path));
+  path := IncludeTrailingPathDelimiter(path) + 'media';
+  SetCurrentDir(path);
 end;
 end;
-//------------ from CrossPfatform -------------------
+// ------------ from CrossPfatform -------------------
 
 
 procedure RaiseLastOSError;
 procedure RaiseLastOSError;
 var
 var
@@ -586,30 +650,38 @@ begin
   e := EGLOSError.Create('OS Error : ' + SysErrorMessage(GetLastError));
   e := EGLOSError.Create('OS Error : ' + SysErrorMessage(GetLastError));
   raise e;
   raise e;
 end;
 end;
+
 function IsSubComponent(const AComponent: TComponent): Boolean;
 function IsSubComponent(const AComponent: TComponent): Boolean;
 begin
 begin
   Result := (csSubComponent in AComponent.ComponentStyle);
   Result := (csSubComponent in AComponent.ComponentStyle);
 end;
 end;
-procedure MakeSubComponent(const AComponent: TComponent; const Value: Boolean);
+
+procedure MakeSubComponent(const AComponent: TComponent; const value: Boolean);
 begin
 begin
-  AComponent.SetSubComponent(Value);
+  AComponent.SetSubComponent(value);
 end;
 end;
+
 function AnsiStartsText(const ASubText, AText: string): Boolean;
 function AnsiStartsText(const ASubText, AText: string): Boolean;
 begin
 begin
   Result := AnsiStartsText(ASubText, AText);
   Result := AnsiStartsText(ASubText, AText);
 end;
 end;
+
 function GLOKMessageBox(const Text, Caption: string): Integer;
 function GLOKMessageBox(const Text, Caption: string): Integer;
 begin
 begin
   Result := Application.MessageBox(PChar(Text), PChar(Caption), MB_OK);
   Result := Application.MessageBox(PChar(Text), PChar(Caption), MB_OK);
 end;
 end;
-procedure GLLoadBitmapFromInstance(Instance: LongInt; ABitmap: TBitmap; const AName: string);
+
+procedure GLLoadBitmapFromInstance(Instance: LongInt; ABitmap: TBitmap;
+  const AName: string);
 begin
 begin
   ABitmap.Handle := LoadBitmap(Instance, PChar(AName));
   ABitmap.Handle := LoadBitmap(Instance, PChar(AName));
 end;
 end;
+
 procedure ShowHTMLUrl(const Url: string);
 procedure ShowHTMLUrl(const Url: string);
 begin
 begin
   ShellExecute(0, 'open', PChar(Url), nil, nil, SW_SHOW);
   ShellExecute(0, 'open', PChar(Url), nil, nil, SW_SHOW);
 end;
 end;
+
 function GetGLRect(const aLeft, aTop, aRight, aBottom: Integer): TRect;
 function GetGLRect(const aLeft, aTop, aRight, aBottom: Integer): TRect;
 begin
 begin
   Result.Left := aLeft;
   Result.Left := aLeft;
@@ -617,6 +689,7 @@ begin
   Result.Right := aRight;
   Result.Right := aRight;
   Result.Bottom := aBottom;
   Result.Bottom := aBottom;
 end;
 end;
+
 procedure InflateGLRect(var aRect: TRect; dx, dy: Integer);
 procedure InflateGLRect(var aRect: TRect; dx, dy: Integer);
 begin
 begin
   aRect.Left := aRect.Left - dx;
   aRect.Left := aRect.Left - dx;
@@ -628,12 +701,13 @@ begin
   if aRect.Bottom < aRect.Top then
   if aRect.Bottom < aRect.Top then
     aRect.Bottom := aRect.Top;
     aRect.Bottom := aRect.Top;
 end;
 end;
+
 procedure IntersectGLRect(var aRect: TRect; const rect2: TRect);
 procedure IntersectGLRect(var aRect: TRect; const rect2: TRect);
 var
 var
   a: Integer;
   a: Integer;
 begin
 begin
-  if (aRect.Left > rect2.Right) or (aRect.Right < rect2.Left)
-    or (aRect.Top > rect2.Bottom) or (aRect.Bottom < rect2.Top) then
+  if (aRect.Left > rect2.Right) or (aRect.Right < rect2.Left) or
+    (aRect.Top > rect2.Bottom) or (aRect.Bottom < rect2.Top) then
   begin
   begin
     // no intersection
     // no intersection
     a := 0;
     a := 0;
@@ -654,59 +728,72 @@ begin
       aRect.Bottom := rect2.Bottom;
       aRect.Bottom := rect2.Bottom;
   end;
   end;
 end;
 end;
+
 type
 type
   TDeviceCapabilities = record
   TDeviceCapabilities = record
-    Xdpi, Ydpi: integer; // Number of pixels per logical inch.
-    Depth: integer; // The bit depth.
-    NumColors: integer; // Number of entries in the device's color table.
+    Xdpi, Ydpi: Integer; // Number of pixels per logical inch.
+    Depth: Integer; // The bit depth.
+    NumColors: Integer; // Number of entries in the device's color table.
   end;
   end;
+
 function GetDeviceCapabilities: TDeviceCapabilities;
 function GetDeviceCapabilities: TDeviceCapabilities;
 var
 var
-  Device: HDC;
+  device: HDC;
 begin
 begin
-  Device := GetDC(0);
+  device := GetDC(0);
   try
   try
-    result.Xdpi := GetDeviceCaps(Device, LOGPIXELSX);
-    result.Ydpi := GetDeviceCaps(Device, LOGPIXELSY);
-    result.Depth := GetDeviceCaps(Device, BITSPIXEL);
-    result.NumColors := GetDeviceCaps(Device, NUMCOLORS);
+    Result.Xdpi := GetDeviceCaps(device, LOGPIXELSX);
+    Result.Ydpi := GetDeviceCaps(device, LOGPIXELSY);
+    Result.Depth := GetDeviceCaps(device, BITSPIXEL);
+    Result.NumColors := GetDeviceCaps(device, NumColors);
   finally
   finally
-    ReleaseDC(0, Device);
+    ReleaseDC(0, device);
   end;
   end;
 end;
 end;
+
 function GetDeviceLogicalPixelsX(device: HDC): Integer;
 function GetDeviceLogicalPixelsX(device: HDC): Integer;
 begin
 begin
-  result := GetDeviceCapabilities().Xdpi;
+  Result := GetDeviceCapabilities().Xdpi;
 end;
 end;
+
 function GetCurrentColorDepth: Integer;
 function GetCurrentColorDepth: Integer;
 begin
 begin
-  result := GetDeviceCapabilities().Depth;
+  Result := GetDeviceCapabilities().Depth;
 end;
 end;
+
 function PixelFormatToColorBits(aPixelFormat: TPixelFormat): Integer;
 function PixelFormatToColorBits(aPixelFormat: TPixelFormat): Integer;
 begin
 begin
   case aPixelFormat of
   case aPixelFormat of
     pfCustom{$IFDEF WIN32}, pfDevice{$ENDIF}: // use current color depth
     pfCustom{$IFDEF WIN32}, pfDevice{$ENDIF}: // use current color depth
       Result := GetCurrentColorDepth;
       Result := GetCurrentColorDepth;
-    pf1bit: Result := 1;
+    pf1bit:
+      Result := 1;
 {$IFDEF WIN32}
 {$IFDEF WIN32}
-    pf4bit: Result := 4;
-    pf15bit: Result := 15;
+    pf4bit:
+      Result := 4;
+    pf15bit:
+      Result := 15;
 {$ENDIF}
 {$ENDIF}
-    pf8bit: Result := 8;
-    pf16bit: Result := 16;
-    pf32bit: Result := 32;
+    pf8bit:
+      Result := 8;
+    pf16bit:
+      Result := 16;
+    pf32bit:
+      Result := 32;
   else
   else
     Result := 24;
     Result := 24;
   end;
   end;
 end;
 end;
+
 procedure FixPathDelimiter(var S: string);
 procedure FixPathDelimiter(var S: string);
 var
 var
-  I: Integer;
+  i: Integer;
 begin
 begin
-  for I := Length(S) downto 1 do
-    if (S[I] = '/') or (S[I] = '\') then
-      S[I] := PathDelim;
+  for i := Length(S) downto 1 do
+    if (S[i] = '/') or (S[i] = '\') then
+      S[i] := PathDelim;
 end;
 end;
+
 function RelativePath(const S: string): string;
 function RelativePath(const S: string): string;
 var
 var
   path: string;
   path: string;
@@ -716,7 +803,7 @@ begin
   begin
   begin
     if Assigned(vProjectTargetName) then
     if Assigned(vProjectTargetName) then
     begin
     begin
-      path :=  vProjectTargetName();
+      path := vProjectTargetName();
       if Length(path) = 0 then
       if Length(path) = 0 then
         path := vLastProjectTargetName
         path := vLastProjectTargetName
       else
       else
@@ -724,7 +811,7 @@ begin
       path := IncludeTrailingPathDelimiter(ExtractFilePath(path));
       path := IncludeTrailingPathDelimiter(ExtractFilePath(path));
     end
     end
     else
     else
-      exit;
+      Exit;
   end
   end
   else
   else
   begin
   begin
@@ -734,23 +821,28 @@ begin
   if Pos(path, S) = 1 then
   if Pos(path, S) = 1 then
     Delete(Result, 1, Length(path));
     Delete(Result, 1, Length(path));
 end;
 end;
+
 procedure QueryPerformanceCounter(out val: Int64);
 procedure QueryPerformanceCounter(out val: Int64);
 begin
 begin
   Winapi.Windows.QueryPerformanceCounter(val);
   Winapi.Windows.QueryPerformanceCounter(val);
 end;
 end;
+
 function QueryPerformanceFrequency(out val: Int64): Boolean;
 function QueryPerformanceFrequency(out val: Int64): Boolean;
 begin
 begin
   Result := Boolean(Winapi.Windows.QueryPerformanceFrequency(val));
   Result := Boolean(Winapi.Windows.QueryPerformanceFrequency(val));
 end;
 end;
+
 function StartPrecisionTimer: Int64;
 function StartPrecisionTimer: Int64;
 begin
 begin
   QueryPerformanceCounter(Result);
   QueryPerformanceCounter(Result);
 end;
 end;
+
 function PrecisionTimerLap(const precisionTimer: Int64): Double;
 function PrecisionTimerLap(const precisionTimer: Int64): Double;
 begin
 begin
   // we can do this, because we don't really stop anything
   // we can do this, because we don't really stop anything
   Result := StopPrecisionTimer(precisionTimer);
   Result := StopPrecisionTimer(precisionTimer);
 end;
 end;
+
 function StopPrecisionTimer(const precisionTimer: Int64): Double;
 function StopPrecisionTimer(const precisionTimer: Int64): Double;
 var
 var
   cur, freq: Int64;
   cur, freq: Int64;
@@ -764,31 +856,34 @@ begin
   end;
   end;
   Result := (cur - precisionTimer) * vInvPerformanceCounterFrequency;
   Result := (cur - precisionTimer) * vInvPerformanceCounterFrequency;
 end;
 end;
+
 var
 var
-  vSStartTime : TDateTime;
+  vSStartTime: TDateTime;
   vLastTime: TDateTime;
   vLastTime: TDateTime;
   vDeltaMilliSecond: TDateTime;
   vDeltaMilliSecond: TDateTime;
+
 function AppTime: Double;
 function AppTime: Double;
 var
 var
   SystemTime: TSystemTime;
   SystemTime: TSystemTime;
 begin
 begin
   GetLocalTime(SystemTime);
   GetLocalTime(SystemTime);
   with SystemTime do
   with SystemTime do
-    Result := (wHour * (MinsPerHour * SecsPerMin * MSecsPerSec) +
-             wMinute * (SecsPerMin * MSecsPerSec) +
-               wSecond * MSecsPerSec +
-             wMilliSeconds) - vSStartTime;
+    Result := (wHour * (MinsPerHour * SecsPerMin * MSecsPerSec) + wMinute *
+      (SecsPerMin * MSecsPerSec) + wSecond * MSecsPerSec + wMilliSeconds) -
+      vSStartTime;
   // Hack to fix time precession
   // Hack to fix time precession
   if Result - vLastTime = 0 then
   if Result - vLastTime = 0 then
   begin
   begin
     Result := Result + vDeltaMilliSecond;
     Result := Result + vDeltaMilliSecond;
     vDeltaMilliSecond := vDeltaMilliSecond + 0.1;
     vDeltaMilliSecond := vDeltaMilliSecond + 0.1;
   end
   end
-  else begin
+  else
+  begin
     vLastTime := Result;
     vLastTime := Result;
     vDeltaMilliSecond := 0.1;
     vDeltaMilliSecond := 0.1;
   end;
   end;
 end;
 end;
+
 function FindUnitName(anObject: TObject): string;
 function FindUnitName(anObject: TObject): string;
 begin
 begin
   if Assigned(anObject) then
   if Assigned(anObject) then
@@ -796,6 +891,7 @@ begin
   else
   else
     Result := '';
     Result := '';
 end;
 end;
+
 function FindUnitName(aClass: TClass): string;
 function FindUnitName(aClass: TClass): string;
 begin
 begin
   if Assigned(aClass) then
   if Assigned(aClass) then
@@ -803,6 +899,7 @@ begin
   else
   else
     Result := '';
     Result := '';
 end;
 end;
+
 procedure SetExeDirectory;
 procedure SetExeDirectory;
 var
 var
   path: string;
   path: string;
@@ -811,7 +908,7 @@ begin
   begin
   begin
     if Assigned(vProjectTargetName) then
     if Assigned(vProjectTargetName) then
     begin
     begin
-      path :=  vProjectTargetName();
+      path := vProjectTargetName();
       if Length(path) = 0 then
       if Length(path) = 0 then
         path := vLastProjectTargetName
         path := vLastProjectTargetName
       else
       else
@@ -828,10 +925,12 @@ begin
   end;
   end;
 end;
 end;
 
 
-function GetValueFromStringsIndex(const AStrings: TStrings; const AIndex: Integer): string;
+function GetValueFromStringsIndex(const AStrings: TStrings;
+  const AIndex: Integer): string;
 begin
 begin
   Result := AStrings.ValueFromIndex[AIndex];
   Result := AStrings.ValueFromIndex[AIndex];
 end;
 end;
+
 function IsDirectoryWriteable(const AName: string): Boolean;
 function IsDirectoryWriteable(const AName: string): Boolean;
 var
 var
   LFileName: String;
   LFileName: String;
@@ -898,7 +997,7 @@ begin
     // +/- infinity
     // +/- infinity
     Dst := (Sign shl 31) or $7F800000;
     Dst := (Sign shl 31) or $7F800000;
   end
   end
-  else //if (Exp = 31) and (Mantisa <> 0) then
+  else // if (Exp = 31) and (Mantisa <> 0) then
   begin
   begin
     // not a number - preserve sign and mantissa
     // not a number - preserve sign and mantissa
     Dst := (Sign shl 31) or $7F800000 or (Mantissa shl 13);
     Dst := (Sign shl 31) or $7F800000 or (Mantissa shl 13);
@@ -906,6 +1005,7 @@ begin
   // reinterpret LongWord as Single
   // reinterpret LongWord as Single
   Result := PSingle(@Dst)^;
   Result := PSingle(@Dst)^;
 end;
 end;
+
 function FloatToHalf(Float: Single): THalfFloat;
 function FloatToHalf(Float: Single): THalfFloat;
 var
 var
   Src: LongWord;
   Src: LongWord;
@@ -986,31 +1086,39 @@ begin
   end;
   end;
 end;
 end;
 
 
-//By PAL, added to fix problem with decimal separator in non En configurations
-function GLStrToFloatDef(const S: string; const Default: Extended; fs: TFormatSettings): Extended; overload;
+// By PAL, added to fix problem with decimal separator in non En configurations
+function GLStrToFloatDef(const S: string; const Default: Extended;
+  fs: TFormatSettings): Extended; overload;
 begin
 begin
   fs.DecimalSeparator := '.';
   fs.DecimalSeparator := '.';
-  if not System.SysUtils.TextToFloat(S, Result, fs) then
+  if not TextToFloat(S, Result, fs) then
     Result := Default;
     Result := Default;
 end;
 end;
-//By PAL, added to fix problem with decimal separator in non En configurations
-function GLStrToFloatDef(const S: string; const Default: Extended): Extended; overload;
-  var fs: TFormatSettings;
+
+// By PAL, added to fix problem with decimal separator in non En configurations
+function GLStrToFloatDef(const S: string; const Default: Extended)
+  : Extended; overload;
+var
+  fs: TFormatSettings;
 begin
 begin
   fs.DecimalSeparator := '.';
   fs.DecimalSeparator := '.';
-  if not System.SysUtils.TextToFloat(S, Result, fs) then
+  if not TextToFloat(S, Result, fs) then
     Result := Default;
     Result := Default;
 end;
 end;
-//By PAL, added to fix problem with decimal separator in non En configurations
+
+// By PAL, added to fix problem with decimal separator in non En configurations
 function GLStrToFloatDef(const S: string): Extended; overload;
 function GLStrToFloatDef(const S: string): Extended; overload;
-  var fs: TFormatSettings;
+var
+  fs: TFormatSettings;
 begin
 begin
   fs.DecimalSeparator := '.';
   fs.DecimalSeparator := '.';
-  if not System.SysUtils.TextToFloat(S, Result, fs) then
+  if not TextToFloat(S, Result, fs) then
     Result := 0;
     Result := 0;
 end;
 end;
-//----------------------------------------
+
+// ----------------------------------------
 initialization
 initialization
-//----------------------------------------
-  vSStartTime := AppTime;
+// ----------------------------------------
+vSStartTime := AppTime;
+
 end.
 end.