Стартовый пул
BIN
bgrabitmap/test/test4other/arial.ttf
Normal file
BIN
bgrabitmap/test/test4other/test4fpgui.ico
Normal file
After Width: | Height: | Size: 3.6 KiB |
87
bgrabitmap/test/test4other/test4fpgui.lpi
Normal file
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="test4fpgui"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="BGRABitmapPack4fpGUI"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="fpgui_toolkit"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="test4fpgui.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="test4fpgui"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
<VariablesInRegisters Value="True"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
97
bgrabitmap/test/test4other/test4fpgui.lpr
Normal file
@@ -0,0 +1,97 @@
|
||||
program test4fpgui;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Classes, SysUtils,
|
||||
fpg_base, fpg_main, fpg_form,
|
||||
BGRABitmapTypes, BGRABitmap;
|
||||
|
||||
type
|
||||
|
||||
{ TMainForm }
|
||||
|
||||
TMainForm = class(TfpgForm)
|
||||
procedure FormPaint(Sender: TObject);
|
||||
protected
|
||||
FBmp: TBGRABitmap;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure AfterCreate; override;
|
||||
end;
|
||||
|
||||
procedure DrawEllipseHello(bmp: TBGRABitmap);
|
||||
begin
|
||||
bmp.Fill(BGRABlack);
|
||||
bmp.CustomPenStyle := BGRAPenStyle(2,1);
|
||||
bmp.FillEllipseLinearColorAntialias(bmp.Width/2,bmp.Height/2,bmp.Width/2-5,bmp.Height/2-5, BGRAPixelTransparent, BGRAWhite);
|
||||
bmp.EllipseAntialias(bmp.Width/2,bmp.Height/2,bmp.Width/2-5,bmp.Height/2-5,CSSRed,5);
|
||||
if bmp.Height div 10 < 10 then
|
||||
bmp.FontHeight := 10
|
||||
else
|
||||
bmp.FontHeight := bmp.Height div 10;
|
||||
with bmp.FontPixelMetric do
|
||||
bmp.TextOut(bmp.Width/2,bmp.Height/2 - (CapLine+Baseline)/2,'Hello world', BGRABlack, taCenter);
|
||||
bmp.Canvas.Pen.Color := clBlue;
|
||||
bmp.Canvas.MoveTo(0,0);
|
||||
bmp.Canvas.LineTo(bmp.Width,bmp.Height);
|
||||
end;
|
||||
|
||||
{ TMainForm }
|
||||
|
||||
procedure TMainForm.FormPaint(Sender: TObject);
|
||||
begin
|
||||
FBmp.SetSize(Width,Height);
|
||||
DrawEllipseHello(FBmp);
|
||||
FBmp.Draw(Canvas,0,0);
|
||||
end;
|
||||
|
||||
constructor TMainForm.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FBmp := TBGRABitmap.Create;
|
||||
end;
|
||||
|
||||
destructor TMainForm.Destroy;
|
||||
begin
|
||||
FBmp.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TMainForm.AfterCreate;
|
||||
begin
|
||||
{%region 'Auto-generated GUI code' -fold}
|
||||
{@VFD_BODY_BEGIN: MainForm}
|
||||
Name := 'MainForm';
|
||||
SetPosition(50, 50, 500, 400);
|
||||
WindowTitle := 'BGRABitmap and fpGUI';
|
||||
Hint := '';
|
||||
WindowPosition := wpOneThirdDown;
|
||||
OnPaint := @FormPaint;
|
||||
{@VFD_BODY_END: MainForm}
|
||||
{%endregion}
|
||||
end;
|
||||
|
||||
procedure MainProc;
|
||||
var
|
||||
frm: TMainForm;
|
||||
begin
|
||||
fpgApplication.Initialize;
|
||||
TBGRABitmap.AddFreeTypeFontFolder(GetCurrentDir);
|
||||
frm := TMainForm.Create(nil);
|
||||
frm.Show;
|
||||
fpgApplication.Run;
|
||||
frm.Free;
|
||||
end;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
MainProc;
|
||||
end.
|
||||
|
||||
|
BIN
bgrabitmap/test/test4other/test4nogui.ico
Normal file
After Width: | Height: | Size: 3.6 KiB |
83
bgrabitmap/test/test4other/test4nogui.lpi
Normal file
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="TestBGRANoGui"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="BGRABitmapPack4NoGUI"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="test4nogui.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="test4nogui"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
<VariablesInRegisters Value="True"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
84
bgrabitmap/test/test4other/test4nogui.lpr
Normal file
@@ -0,0 +1,84 @@
|
||||
program test4nogui;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Classes, SysUtils, CustApp,
|
||||
BGRAGraphics,
|
||||
BGRABitmap,
|
||||
BGRABitmapTypes;
|
||||
|
||||
type
|
||||
|
||||
{ TTestBGRANoGui }
|
||||
|
||||
TTestBGRANoGui = class(TCustomApplication)
|
||||
protected
|
||||
procedure DoRun; override;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
procedure DrawEllipseHello(bmp: TBGRABitmap);
|
||||
begin
|
||||
bmp.Fill(BGRABlack);
|
||||
bmp.CustomPenStyle := BGRAPenStyle(2,1);
|
||||
bmp.FillEllipseLinearColorAntialias(bmp.Width/2,bmp.Height/2,bmp.Width/2-5,bmp.Height/2-5, BGRAPixelTransparent, BGRAWhite);
|
||||
bmp.EllipseAntialias(bmp.Width/2,bmp.Height/2,bmp.Width/2-5,bmp.Height/2-5,CSSRed,5);
|
||||
if bmp.Height div 10 < 10 then
|
||||
bmp.FontHeight := 10
|
||||
else
|
||||
bmp.FontHeight := bmp.Height div 10;
|
||||
with bmp.FontPixelMetric do
|
||||
begin
|
||||
bmp.TextOut(bmp.Width/2,bmp.Height/2 - (CapLine+Baseline)/2,'Hello world', BGRABlack, taCenter);
|
||||
bmp.TextOutAngle(bmp.Width/6,bmp.Height/2 - (CapLine+Baseline)/2, -300, 'Going down!', BGRABlack, taLeftJustify);
|
||||
bmp.TextOutAngle(bmp.Width*5/6,bmp.Height/2 - (CapLine+Baseline)/2, 300, 'Going up!', BGRABlack, taRightJustify);
|
||||
end;
|
||||
bmp.Canvas.Pen.Color := clBlue;
|
||||
bmp.Canvas.MoveTo(0,0);
|
||||
bmp.Canvas.LineTo(bmp.Width,bmp.Height);
|
||||
end;
|
||||
|
||||
{ TTestBGRANoGui }
|
||||
|
||||
procedure TTestBGRANoGui.DoRun;
|
||||
var
|
||||
bmp: TBGRABitmap;
|
||||
begin
|
||||
TBGRABitmap.AddFreeTypeFontFolder(GetCurrentDir);
|
||||
|
||||
bmp := TBGRABitmap.Create(800,600,BGRABlack);
|
||||
DrawEllipseHello(bmp);
|
||||
bmp.SaveToFile('test.png');
|
||||
bmp.free;
|
||||
|
||||
Terminate;
|
||||
end;
|
||||
|
||||
constructor TTestBGRANoGui.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
end;
|
||||
|
||||
destructor TTestBGRANoGui.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
var
|
||||
Application: TTestBGRANoGui;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application:=TTestBGRANoGui.Create(nil);
|
||||
Application.Title:='TestBGRANoGui';
|
||||
Application.Run;
|
||||
Application.Free;
|
||||
end.
|
||||
|
BIN
bgrabitmap/test/test4other/test4nolcl.ico
Normal file
After Width: | Height: | Size: 3.6 KiB |
67
bgrabitmap/test/test4other/test4nolcl.lpi
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="TestBGRANoLCL"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages>
|
||||
<Item>
|
||||
<PackageName Value="BGRABitmapPack4NoLCL"/>
|
||||
</Item>
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="test4nolcl.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="test4nolcl"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Other>
|
||||
<ConfigFile>
|
||||
<WriteConfigFilePath Value=""/>
|
||||
</ConfigFile>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions>
|
||||
<Item>
|
||||
<Name Value="EAbort"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
74
bgrabitmap/test/test4other/test4nolcl.lpr
Normal file
@@ -0,0 +1,74 @@
|
||||
program test4nolcl_freetype;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}
|
||||
cthreads, cwstring,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, CustApp,
|
||||
BGRAGraphics,
|
||||
BGRABitmap,
|
||||
BGRABitmapTypes;
|
||||
|
||||
type
|
||||
|
||||
{ TTestBGRANoLCL }
|
||||
|
||||
TTestBGRANoLCL = class(TCustomApplication)
|
||||
protected
|
||||
procedure DoRun; override;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
procedure DrawEllipseHello(bmp: TBGRABitmap);
|
||||
begin
|
||||
bmp.Fill(BGRABlack);
|
||||
bmp.CustomPenStyle := BGRAPenStyle(2,1);
|
||||
bmp.FillEllipseLinearColorAntialias(bmp.Width/2,bmp.Height/2,bmp.Width/2-5,bmp.Height/2-5, BGRAPixelTransparent, BGRAWhite);
|
||||
bmp.EllipseAntialias(bmp.Width/2,bmp.Height/2,bmp.Width/2-5,bmp.Height/2-5,CSSRed,5);
|
||||
bmp.Canvas.Pen.Color := clBlue;
|
||||
bmp.Canvas.MoveTo(0,0);
|
||||
bmp.Canvas.LineTo(bmp.Width,bmp.Height);
|
||||
end;
|
||||
|
||||
{ TTestBGRANoLCL }
|
||||
|
||||
procedure TTestBGRANoLCL.DoRun;
|
||||
var
|
||||
bmp: TBGRABitmap;
|
||||
begin
|
||||
bmp := TBGRABitmap.Create(800,600,BGRABlack);
|
||||
DrawEllipseHello(bmp);
|
||||
bmp.SaveToFile(ExtractFilePath(ExeName)+'test.png');
|
||||
bmp.free;
|
||||
|
||||
// stop program loop
|
||||
Terminate;
|
||||
end;
|
||||
|
||||
constructor TTestBGRANoLCL.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
StopOnException:=True;
|
||||
end;
|
||||
|
||||
destructor TTestBGRANoLCL.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
var
|
||||
Application: TTestBGRANoLCL;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application:=TTestBGRANoLCL.Create(nil);
|
||||
Application.Title:='TestBGRANoLCL';
|
||||
Application.Run;
|
||||
Application.Free;
|
||||
end.
|
||||
|
BIN
bgrabitmap/test/test4other/test4nolcl_freetype.ico
Normal file
After Width: | Height: | Size: 3.6 KiB |
68
bgrabitmap/test/test4other/test4nolcl_freetype.lpi
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="TestBGRANoLCL_FreeType"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages>
|
||||
<Item>
|
||||
<PackageName Value="BGRABitmapPack4NoLCL_FreeType"/>
|
||||
</Item>
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="test4nolcl_freetype.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="test4nolcl_freetype"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Other>
|
||||
<ConfigFile>
|
||||
<WriteConfigFilePath Value=""/>
|
||||
</ConfigFile>
|
||||
<CustomOptions Value="-dBGRABITMAP_DONT_USE_LCL"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions>
|
||||
<Item>
|
||||
<Name Value="EAbort"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
84
bgrabitmap/test/test4other/test4nolcl_freetype.lpr
Normal file
@@ -0,0 +1,84 @@
|
||||
program test4nolcl;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}
|
||||
cthreads, cwstring,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, CustApp,
|
||||
BGRAGraphics,
|
||||
BGRABitmap,
|
||||
BGRABitmapTypes;
|
||||
|
||||
type
|
||||
|
||||
{ TTestBGRANoLCL }
|
||||
|
||||
TTestBGRANoLCL = class(TCustomApplication)
|
||||
protected
|
||||
procedure DoRun; override;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
procedure DrawEllipseHello(bmp: TBGRABitmap);
|
||||
begin
|
||||
bmp.Fill(BGRABlack);
|
||||
bmp.CustomPenStyle := BGRAPenStyle(2,1);
|
||||
bmp.FillEllipseLinearColorAntialias(bmp.Width/2,bmp.Height/2,bmp.Width/2-5,bmp.Height/2-5, BGRAPixelTransparent, BGRAWhite);
|
||||
bmp.EllipseAntialias(bmp.Width/2,bmp.Height/2,bmp.Width/2-5,bmp.Height/2-5,CSSRed,5);
|
||||
if bmp.Height div 10 < 10 then
|
||||
bmp.FontHeight := 10
|
||||
else
|
||||
bmp.FontHeight := bmp.Height div 10;
|
||||
with bmp.FontPixelMetric do
|
||||
bmp.TextOut(bmp.Width/2,bmp.Height/2 - (CapLine+Baseline)/2,'Hello world', BGRABlack, taCenter);
|
||||
bmp.Canvas.Pen.Color := clBlue;
|
||||
bmp.Canvas.MoveTo(0,0);
|
||||
bmp.Canvas.LineTo(bmp.Width,bmp.Height);
|
||||
end;
|
||||
|
||||
{ TTestBGRANoLCL }
|
||||
|
||||
procedure TTestBGRANoLCL.DoRun;
|
||||
var
|
||||
bmp: TBGRABitmap;
|
||||
begin
|
||||
bmp := TBGRABitmap.Create(800,600,BGRABlack);
|
||||
DrawEllipseHello(bmp);
|
||||
bmp.SaveToFile(ExtractFilePath(ExeName)+'test.png');
|
||||
bmp.free;
|
||||
|
||||
// stop program loop
|
||||
Terminate;
|
||||
end;
|
||||
|
||||
constructor TTestBGRANoLCL.Create(TheOwner: TComponent);
|
||||
var
|
||||
fs: TFileStream;
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
fs:= TFileStream.Create(ExtractFilePath(ExeName)+'arial.ttf', fmOpenRead);
|
||||
TBGRABitmap.AddFreeTypeFontStream(fs, true);
|
||||
StopOnException:=True;
|
||||
end;
|
||||
|
||||
destructor TTestBGRANoLCL.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
var
|
||||
Application: TTestBGRANoLCL;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application:=TTestBGRANoLCL.Create(nil);
|
||||
Application.Title:='TestBGRANoLCL_FreeType';
|
||||
Application.Run;
|
||||
Application.Free;
|
||||
end.
|
||||
|
After Width: | Height: | Size: 56 KiB |
@@ -0,0 +1,150 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Release" Default="True"/>
|
||||
<Item2 Name="Debug">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/$(TargetCPU)-$(TargetOS)/demo06"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
<VerifyObjMethodCallValidity Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="0"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="BGRABitmapPack4NoGUI"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="demo06.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/$(TargetCPU)-$(TargetOS)/demo06"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
<StripSymbols Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@@ -0,0 +1,135 @@
|
||||
program demo06;
|
||||
|
||||
{$I zglCustomConfig.cfg}
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
{$R *.res}
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
Classes,BGRAGraphics,
|
||||
BGRABitmapTypes,
|
||||
BGRAZenGL in '..\BGRAZenGL.pas',
|
||||
{$IFDEF USE_ZENGL_STATIC}
|
||||
zgl_main,
|
||||
zgl_screen,
|
||||
zgl_window,
|
||||
zgl_timers,
|
||||
zgl_keyboard,
|
||||
zgl_render_2d,
|
||||
zgl_fx,
|
||||
zgl_primitives_2d,
|
||||
zgl_math_2d,
|
||||
zgl_utils
|
||||
{$ELSE}
|
||||
zglHeader
|
||||
{$ENDIF}
|
||||
;
|
||||
|
||||
var
|
||||
dirRes : UTF8String {$IFNDEF MACOSX} = '../data/' {$ENDIF};
|
||||
fntMain : IBGLFont;
|
||||
|
||||
procedure Init;
|
||||
//var
|
||||
// i : Integer;
|
||||
begin
|
||||
// RU: Загружаем данные о шрифте.
|
||||
// EN: Load the font.
|
||||
fntMain := BGLZenFont( dirRes + 'font.zfi' );
|
||||
//fntMain.Clipped := true;
|
||||
// RU: Если же текстуры именуются без использования маски вида "$(имя_шрифта)FontName-page$(номер).$(расширение)", то загрузку можно произвести следующим образом(для png):
|
||||
// EN: If textures were named without special mask - "$(font_name)-page$(number).$(extension)", then use this method to load them(for png):
|
||||
//for i := 0 to fntMain.Count.Pages - 1 do
|
||||
// fntMain.Pages[ i ] := tex_LoadFromFile( dirRes + 'font-page' + u_IntToStr( i ) + '.png' );
|
||||
end;
|
||||
|
||||
procedure Draw;
|
||||
var
|
||||
r : zglTRect;
|
||||
s : UTF8String;
|
||||
begin
|
||||
batch2d_Begin();
|
||||
|
||||
// RU: ZenGL работает исключительно с кодировкой UTF-8, поэтому весь текст должен быть в UTF-8.
|
||||
// EN: ZenGL works only with UTF-8 encoding, so all text should be encoded with UTF-8.
|
||||
|
||||
fntMain.TextOut(400, 25, 'String with center alignment', taCenter);
|
||||
|
||||
fntMain.Scale := 2;
|
||||
fntMain.TextOut(400, 65, 'Scaling', taCenter);
|
||||
fntMain.Scale := 1;
|
||||
|
||||
fntMain.SetGradientColors(CSSRed,CSSLime,CSSBlue,CSSWhite);
|
||||
fntMain.TextOut( 400, 125, 'Gradient color for every symbol', taCenter);
|
||||
fntMain.GradientColors := false;
|
||||
|
||||
r.X := 0;
|
||||
r.Y := 300 - 128;
|
||||
r.W := 192;
|
||||
r.H := 256;
|
||||
with r do fntMain.TextRect(X,Y,W,H, 'Simple text rendering in rectangle' );
|
||||
pr2d_Rect( r.X, r.Y, r.W, r.H, $FF0000 );
|
||||
|
||||
r.X := 800 - 192;
|
||||
r.Y := 300 - 128;
|
||||
r.W := 192;
|
||||
r.H := 256;
|
||||
with r do fntMain.TextRect(X,Y,W,H, 'Text rendering using horizontal right alignment and vertical bottom alignment', taRightJustify, tlBottom);
|
||||
pr2d_Rect( r.X, r.Y, r.W, r.H, $FF0000 );
|
||||
|
||||
r.X := 400 - 192;
|
||||
r.Y := 300 - 128;
|
||||
r.W := 384-200;
|
||||
r.H := 256-190;
|
||||
fntMain.Clipped:= true;
|
||||
fntMain.Justify:= true;
|
||||
with r do fntMain.TextRect(X,Y,W,H, 'This text uses justify alignment and centered vertically. Text which doesn''t fit inside the rectangle will be cropped.',
|
||||
tlCenter);
|
||||
fntMain.Justify:= false;
|
||||
fntMain.Clipped:= false;
|
||||
pr2d_Rect( r.X, r.Y, r.W, r.H, $FF0000 );
|
||||
|
||||
r.X := 400 - 320;
|
||||
r.Y := 300 + 160;
|
||||
r.W := 640;
|
||||
r.H := 128;
|
||||
with r do fntMain.TextRect(X,Y,W,H, 'For starting new line LF symbol can be used' + #10 + 'code of which is equal to 10 and named in Unicode as "Line Feed"',
|
||||
taCenter, tlCenter);
|
||||
pr2d_Rect( r.X, r.Y, r.W, r.H, $FF0000 );
|
||||
|
||||
// RU: Выводим количество FPS в правом углу
|
||||
// EN: Render FPS in the top right corner
|
||||
s := 'FPS: ' + u_IntToStr( zgl_Get( RENDER_FPS ) );
|
||||
fntMain.TextOut(800,0, s, taRightJustify);
|
||||
|
||||
batch2d_End();
|
||||
end;
|
||||
|
||||
procedure Timer;
|
||||
begin
|
||||
if key_Press( K_ESCAPE ) Then zgl_Exit();
|
||||
|
||||
key_ClearState();
|
||||
end;
|
||||
|
||||
Begin
|
||||
{$IFNDEF USE_ZENGL_STATIC}
|
||||
if not zglLoad( libZenGL ) Then exit;
|
||||
{$ENDIF}
|
||||
|
||||
randomize();
|
||||
|
||||
timer_Add( @Timer, 16 );
|
||||
|
||||
zgl_Reg( SYS_LOAD, @Init );
|
||||
zgl_Reg( SYS_DRAW, @Draw );
|
||||
|
||||
wnd_SetCaption( '06 - Text' );
|
||||
|
||||
wnd_ShowCursor( TRUE );
|
||||
|
||||
scr_SetOptions( 800, 600, REFRESH_MAXIMUM, FALSE, FALSE );
|
||||
|
||||
zgl_Init();
|
||||
End.
|
@@ -0,0 +1,163 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Release" Default="True"/>
|
||||
<Item2 Name="Debug">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/demo06"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
<VerifyObjMethodCallValidity Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="0"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<PassLinkerOptions Value="True"/>
|
||||
<LinkerOptions Value="-macosx_version_min 10.4"/>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
<ExecuteAfter>
|
||||
<Command Value="sh macosx_postbuild.sh"/>
|
||||
</ExecuteAfter>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="demo06.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="demo06"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/demo06"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
<StripSymbols Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<PassLinkerOptions Value="True"/>
|
||||
<LinkerOptions Value="-macosx_version_min 10.4"/>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
<ExecuteAfter>
|
||||
<Command Value="sh macosx_postbuild.sh"/>
|
||||
</ExecuteAfter>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>demo06</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>demo06</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>demo06</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>zengl.demo06</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>demo</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
@@ -0,0 +1,8 @@
|
||||
# copy resources
|
||||
cp ../../../bin/data/font* ../../../bin/demo06.app/Contents/Resources/
|
||||
# copy binary into bundle
|
||||
rm ../../../bin/demo06.app/Contents/MacOS/demo06
|
||||
cp ../../../bin/demo06 ../../../bin/demo06.app/Contents/MacOS/demo06
|
||||
# make Info.plist and copy icon
|
||||
cp -f demo06_macosx.plist ../../../bin/demo06.app/Contents/Info.plist
|
||||
cp ../../../bin/data/zengl.icns ../../../bin/demo06.app/Contents/Resources/demo06.icns
|
After Width: | Height: | Size: 56 KiB |
@@ -0,0 +1,149 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Release" Default="True"/>
|
||||
<Item2 Name="Debug">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/$(TargetCPU)-$(TargetOS)/demo07"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="0"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="BGRABitmapPack4NoGUI"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="demo07.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/$(TargetCPU)-$(TargetOS)/demo07"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
<StripSymbols Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@@ -0,0 +1,336 @@
|
||||
program demo07;
|
||||
|
||||
{$I zglCustomConfig.cfg}
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
{$R *.res}
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
Classes,sysutils,
|
||||
BGRABitmapTypes,BGRAGraphics,
|
||||
BGRAZenGL in '..\BGRAZenGl.pas',
|
||||
{$IFDEF USE_ZENGL_STATIC}
|
||||
zgl_main,
|
||||
zgl_screen,
|
||||
zgl_window,
|
||||
zgl_timers,
|
||||
zgl_keyboard,
|
||||
zgl_camera_2d,
|
||||
zgl_render_2d
|
||||
{$ELSE}
|
||||
zglHeader
|
||||
{$ENDIF}
|
||||
;
|
||||
|
||||
type
|
||||
TTux = record
|
||||
Texture : IBGLTexture;
|
||||
Frame : Integer;
|
||||
Pos : TPointF;
|
||||
end;
|
||||
|
||||
const
|
||||
tuxSpeech : array[0..10] of string =
|
||||
('Hello!', '', 'This is an example with BGRABitmap and ZenGL.', 'Text bubbles are rendered with BGRABitmap and LazFreeType.',
|
||||
'Then they are used as textures in OpenGL', '', 'In order to keep a high frame rate,',
|
||||
'textures are rather prepared in advance.', 'However, some textures can be generated on the fly',
|
||||
'as long as they are small enough.', '');
|
||||
|
||||
var
|
||||
dirRes : UTF8String {$IFNDEF MACOSX} = '../data/' {$ENDIF};
|
||||
texBack : IBGLTexture;
|
||||
texLogo : IBGLTexture;
|
||||
texGround : IBGLTexture;
|
||||
texTuxWalk : IBGLTexture;
|
||||
texTuxStand : IBGLTexture;
|
||||
texBublRed : IBGLTexture;
|
||||
texBublBig : IBGLTexture;
|
||||
texBublGhost: IBGLTexture;
|
||||
texSpeech : IBGLTexture;
|
||||
bmpTime : TBGLBitmap;
|
||||
fntMain : IBGLFont;
|
||||
tux : array[ 0..20 ] of TTux;
|
||||
speechIndex : integer;
|
||||
camMain : zglTCamera2D;
|
||||
time : Integer;
|
||||
tuxHorizMargin: single;
|
||||
|
||||
function CreateTextBubble(AText: string): IBGLTexture;
|
||||
const horizMargin = 6; vertMargin = 4;
|
||||
var bmp: TBGLBitmap;
|
||||
begin
|
||||
bmp := TBGLBitmap.Create;
|
||||
bmp.FontHeight := 14;
|
||||
bmp.FontStyle := [fsBold];
|
||||
bmp.SetSize(((bmp.TextSize(AText).cx+2*horizMargin+2)+1) and not 1, bmp.FontPixelMetric.DescentLine+vertMargin*2+2);
|
||||
bmp.FillTransparent;
|
||||
bmp.RoundRectAntialias(1,1,bmp.Width-2,bmp.Height-2,12,12, BGRABlack, 1, BGRA(255,255,250));
|
||||
bmp.TextOut(horizMargin+1,vertMargin+1,AText, BGRABlack);
|
||||
result := bmp.MakeTextureAndFree;
|
||||
end;
|
||||
|
||||
procedure Init;
|
||||
const rectBorder=1;
|
||||
var
|
||||
i : Integer;
|
||||
begin
|
||||
TBGLBitmap.AddFreeTypeFontFolder(StringReplace(dirRes, '/', PathDelim, [rfReplaceAll]), true);
|
||||
|
||||
// RU: Т.к. по умолчанию вся структура камеры заполняется нулями, следует инициализировать её стандартными значениями.
|
||||
// EN: Camera must be initialized, because camera structure is zero-filled by default.
|
||||
cam2d_Init( camMain );
|
||||
|
||||
texLogo := BGLTexture(dirRes + 'zengl.png');
|
||||
texBack := BGLTexture(dirRes + 'back01.jpg');
|
||||
|
||||
texGround := BGLTexture(dirRes + 'ground.png');
|
||||
// RU: Указываем размер кадра в текстуре.
|
||||
// EN: Set the size of single frame for texture.
|
||||
texGround.SetFrameSize(32,32);
|
||||
|
||||
texTuxWalk := BGLTexture( dirRes + 'tux_walking.png' );
|
||||
texTuxWalk.SetFrameSize( 64, 64 );
|
||||
|
||||
texBublRed := CreateTextBubble('I''m so red...');
|
||||
texBublBig := CreateTextBubble('I''m so big...');
|
||||
texBublGhost := CreateTextBubble('???');
|
||||
|
||||
texTuxStand := BGLTexture( dirRes + 'tux_stand.png' );
|
||||
texTuxStand.SetFrameSize( 64, 64 );
|
||||
|
||||
speechIndex := -1;
|
||||
texSpeech := nil;
|
||||
|
||||
tuxHorizMargin:= 10*96 - 800;
|
||||
for i := 0 to 9 do
|
||||
begin
|
||||
tux[ i ].Texture := texTuxWalk;
|
||||
tux[ i ].Frame := random( 19 ) + 2;
|
||||
tux[ i ].Pos.X := i * 96 - tuxHorizMargin/2;
|
||||
tux[ i ].Pos.Y := 32 + 64;
|
||||
end;
|
||||
for i := 10 to 19 do
|
||||
begin
|
||||
tux[ i ].Texture := texTuxWalk;
|
||||
tux[ i ].Frame := random( 19 ) + 2;
|
||||
tux[ i ].Pos.X := ( i - 9 ) * 96 - tuxHorizMargin/2;
|
||||
tux[ i ].Pos.Y := 600 - 32;
|
||||
end;
|
||||
tux[ 20 ].Texture := texTuxStand;
|
||||
tux[ 20 ].Frame := random( 19 ) + 2;
|
||||
tux[ 20 ].Pos.X := 400;
|
||||
tux[ 20 ].Pos.Y := 300 - 4;
|
||||
|
||||
fntMain := BGLFont('Arial', 20, BGRAWhite,BGRABlack);
|
||||
end;
|
||||
|
||||
procedure ExitProg;
|
||||
begin
|
||||
bmpTime.Free;
|
||||
end;
|
||||
|
||||
procedure UpdateBmpTime;
|
||||
var
|
||||
x : Single;
|
||||
timeMask: TBGLBitmap;
|
||||
begin
|
||||
//prepare texture for rotating text
|
||||
if bmpTime = nil then
|
||||
bmpTime := TBGLBitmap.Create(256,32);
|
||||
//draw gradient background
|
||||
bmpTime.GradientFill(0,0,bmpTime.Width,bmpTime.Height, BGRABlack,BGRAPixelTransparent, gtReflected,
|
||||
PointF(0,bmpTime.Height/2),PointF(0,0),dmSet);
|
||||
bmpTime.FontHeight := bmpTime.Height;
|
||||
x := time - trunc(time/(2*bmpTime.width))*bmpTime.width*2;
|
||||
if x > bmpTime.Width then x := 2*bmpTime.width-x;
|
||||
bmpTime.TextOut(x, bmpTime.Height/2 - bmpTime.FontFullHeight/2, TimeToStr(Now), BGRAWhite, taCenter);
|
||||
//apply alpha gradient
|
||||
timeMask := TBGLBitmap.Create(bmpTime.width,bmpTime.Height);
|
||||
timeMask.GradientFill(0,0,timeMask.width,timeMask.Height, BGRAWhite,BGRABlack, gtLinear, PointF(timeMask.Width-64,0),PointF(timeMask.Width,0),dmSet,false);
|
||||
bmpTime.ApplyMask(timeMask,Rect(0,0,bmpTime.Width,bmpTime.Height),Point(0,0));
|
||||
timeMask.Free;
|
||||
end;
|
||||
|
||||
procedure Draw;
|
||||
var
|
||||
i : Integer;
|
||||
a,t : Single;
|
||||
pt : TPointF;
|
||||
newSpeechIndex: Integer;
|
||||
begin
|
||||
batch2d_Begin();
|
||||
if time > 255 Then
|
||||
begin
|
||||
// RU: Для увеличения быстродействия можно отключить очистку буфера цвета, учитывая что экран полностью заполнен.
|
||||
// EN: Rendering perfomance can be increased by disabling clearing the color buffer. This is a good idea because screen is full of objects.
|
||||
zgl_Disable( COLOR_BUFFER_CLEAR );
|
||||
|
||||
|
||||
// RU: Рисуем задний фон с размерами 800х600 используя текстуру "texBack".
|
||||
// EN: Render the background with size 800x600 and using texture "texBack".
|
||||
texBack.StretchDraw(0,0,800,600);
|
||||
|
||||
UpdateBmpTime;
|
||||
|
||||
//draw in four directions
|
||||
if time > 512 then
|
||||
a := (time-512)/3
|
||||
else
|
||||
a := 0;
|
||||
pt := PointF(0,bmpTime.Height*0.5);
|
||||
bmpTime.Texture.DrawAngle(400,300, 0 + a, pt, False, CSSOrange);
|
||||
bmpTime.Texture.Mask.DrawAngle(400,300, 90 + a, pt, False, CSSSkyBlue);
|
||||
bmpTime.Texture.DrawAngle(400,300, 180 + a, pt, False, CSSYellowGreen);
|
||||
bmpTime.Texture.Mask.DrawAngle(400,300, 270 + a, pt, False);
|
||||
|
||||
// RU: Установить текущую камеру.
|
||||
// EN: Set the current camera.
|
||||
cam2d_Set( @camMain );
|
||||
|
||||
// RU: Рисуем землю.
|
||||
// EN: Render the ground.
|
||||
for i := -2 to 800 div texGround.FrameWidth + 1 do
|
||||
texGround.Frame[2].Draw(i * texGround.FrameWidth, 96 - 12);
|
||||
for i := -2 to 800 div texGround.FrameWidth + 1 do
|
||||
texGround.Frame[2].Draw(i * texGround.FrameWidth, 600 - texGround.FrameHeight - 12);
|
||||
|
||||
// RU: Рисуем шагающих пингвинов.
|
||||
// EN: Render penguins
|
||||
for i := 0 to 9 do
|
||||
if i = 2 Then
|
||||
begin
|
||||
// RU: Рисуем надпись в "рамочке" над пингвином.
|
||||
// EN: Render the text in frame over penguins.
|
||||
texBublRed.StretchDrawAngle(tux[ i ].Pos.X, tux[ i ].Pos.Y - tux[i].Texture.FrameHeight, texBublRed.Width*1.5,texBublRed.Height*1.5, sin(time*Pi/500)*30, taCenter,tlBottom);
|
||||
// RU: Рисуем красного пингвина
|
||||
// EN: Render red penguin
|
||||
tux[i].Texture.SetGradientColors(CSSWhite,CSSWhite,CSSRed,CSSRed);
|
||||
tux[i].Texture.Frame[tux[ i ].Frame div 2].Draw(tux[ i ].Pos.X, tux[ i ].Pos.Y, taCenter,tlBottom);
|
||||
tux[i].Texture.GradientColors := false;
|
||||
end else
|
||||
if i = 7 Then
|
||||
begin
|
||||
texBublGhost.Draw(tux[ i ].Pos.X, tux[ i ].Pos.Y - tux[i].Texture.FrameHeight,taCenter,tlBottom,128);
|
||||
// RU: Рисуем пингвина приведение
|
||||
// EN: Render penguin ghost
|
||||
tux[i].Texture.Frame[tux[ i ].Frame div 2].Mask.Draw(tux[ i ].Pos.X, tux[ i ].Pos.Y, taCenter,tlBottom, 155);
|
||||
end else
|
||||
tux[i].Texture.Frame[tux[ i ].Frame div 2].Draw(tux[ i ].Pos.X, tux[ i ].Pos.Y, taCenter,tlBottom);
|
||||
|
||||
// RU: Рисуем пингвинов шагающих в обратную сторону
|
||||
// EN: Render penguins, that go another way
|
||||
for i := 10 to 19 do
|
||||
if i = 13 Then
|
||||
begin
|
||||
texBublBig.Draw(tux[ i ].Pos.X, tux[ i ].Pos.Y-80, taCenter,tlBottom);
|
||||
// RU: Рисуем "большего" пингвина
|
||||
// EN: Render "big" penguin
|
||||
tux[i].Texture.Frame[tux[ i ].Frame div 2].FlipX.StretchDraw(tux[ i ].Pos.X, tux[ i ].Pos.Y, 80, 80, taCenter, tlBottom);
|
||||
end else
|
||||
if i = 17 Then
|
||||
begin
|
||||
// RU: Рисуем "высокого" пингвина
|
||||
// EN: Render "tall" penguin
|
||||
tux[i].Texture.Frame[tux[ i ].Frame div 2].FlipX.StretchDraw(tux[ i ].Pos.X, tux[ i ].Pos.Y, 64, 80, taCenter, tlBottom);
|
||||
end else
|
||||
tux[i].Texture.Frame[tux[ i ].Frame div 2].FlipX.Draw(tux[ i ].Pos.X, tux[ i ].Pos.Y, taCenter, tlBottom);
|
||||
|
||||
// RU: Сбросить камеру.
|
||||
// EN: Reset the camera.
|
||||
cam2d_Set( nil );
|
||||
|
||||
// RU: Рисуем участок земли по центру экрана.
|
||||
// EN: Render piece of ground in the center of screen.
|
||||
texGround.Frame[1].Draw(11 * texGround.FrameWidth, 300 - 16);
|
||||
texGround.Frame[2].Draw(12 * texGround.FrameWidth, 300 - 16);
|
||||
texGround.Frame[3].Draw(13 * texGround.FrameWidth, 300 - 16);
|
||||
|
||||
newSpeechIndex := trunc(time/500) mod length(tuxSpeech);
|
||||
if newSpeechIndex <> speechIndex then
|
||||
begin
|
||||
if texSpeech<> nil then
|
||||
begin
|
||||
texSpeech.FreeMemory;
|
||||
texSpeech := nil;
|
||||
end;
|
||||
speechIndex:= newSpeechIndex;
|
||||
if tuxSpeech[speechIndex]<>'' then
|
||||
texSpeech := CreateTextBubble(tuxSpeech[speechIndex]);
|
||||
end;
|
||||
if texSpeech <> nil then texSpeech.Draw(tux[ 20 ].Pos.X, tux[ 20 ].Pos.Y - tux[ 20 ].Texture.FrameHeight, taCenter, tlBottom);
|
||||
|
||||
tux[ 20 ].Texture.Frame[tux[ 20 ].Frame div 2].Draw(tux[ 20 ].Pos.X, tux[ 20 ].Pos.Y, taCenter, tlBottom);
|
||||
end;
|
||||
|
||||
if time <= 255 Then
|
||||
texLogo.Draw(400,300, taCenter,tlCenter, time)
|
||||
else
|
||||
if time < 510 Then
|
||||
begin
|
||||
BGLCanvas.FillRect(RectF( 0, 0, 800, 600), BGRA(0,0,0,510 - time));
|
||||
texLogo.Draw(400,300, taCenter,tlCenter, 510-time);
|
||||
end;
|
||||
|
||||
if time > 255 Then
|
||||
fntMain.TextOut(0, 0, 'FPS: ' + IntToStr( zgl_Get( RENDER_FPS ) ));
|
||||
batch2d_End();
|
||||
end;
|
||||
|
||||
procedure Timer;
|
||||
var
|
||||
i : Integer;
|
||||
begin
|
||||
INC( time, 2 );
|
||||
|
||||
if time > 1000*Pi then
|
||||
camMain.Angle := camMain.Angle + cos( time / 1000 ) / 10;
|
||||
|
||||
for i := 0 to 20 do
|
||||
if (i <> 20) or (texSpeech <> nil) then
|
||||
begin
|
||||
INC( tux[ i ].Frame );
|
||||
if tux[ i ].Frame > 20 Then
|
||||
tux[ i ].Frame := 2;
|
||||
end;
|
||||
for i := 0 to 9 do
|
||||
begin
|
||||
tux[ i ].Pos.X := tux[ i ].Pos.X + 1.5;
|
||||
if tux[ i ].Pos.X >= 800 + tuxHorizMargin/2 Then
|
||||
tux[ i ].Pos.X := -tuxHorizMargin/2;
|
||||
end;
|
||||
for i := 10 to 19 do
|
||||
begin
|
||||
tux[ i ].Pos.X := tux[ i ].Pos.X - 1.5;
|
||||
if tux[ i ].Pos.X <= -tuxHorizMargin/2 Then
|
||||
tux[ i ].Pos.X := 800+tuxHorizMargin/2;
|
||||
end;
|
||||
|
||||
if key_Press( K_ESCAPE ) Then zgl_Exit();
|
||||
key_ClearState();
|
||||
end;
|
||||
|
||||
Begin
|
||||
{$IFNDEF USE_ZENGL_STATIC}
|
||||
if not zglLoad( libZenGL ) Then exit;
|
||||
{$ENDIF}
|
||||
|
||||
if not FileExists(dirRes+'arial.ttf') then
|
||||
raise exception.Create('Please copy "arial.ttf" in directory "'+dirRes+'"');
|
||||
|
||||
randomize();
|
||||
|
||||
timer_Add( @Timer, 16 );
|
||||
|
||||
zgl_Reg( SYS_LOAD, @Init );
|
||||
zgl_Reg( SYS_DRAW, @Draw );
|
||||
zgl_Reg( SYS_EXIT, @ExitProg );
|
||||
|
||||
wnd_SetCaption( '07 - Sprites' );
|
||||
|
||||
wnd_ShowCursor( TRUE );
|
||||
|
||||
scr_SetOptions( 800, 600, REFRESH_MAXIMUM, FALSE, FALSE );
|
||||
|
||||
zgl_Init();
|
||||
End.
|
@@ -0,0 +1,163 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Release" Default="True"/>
|
||||
<Item2 Name="Debug">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/demo07"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
<VerifyObjMethodCallValidity Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="0"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<PassLinkerOptions Value="True"/>
|
||||
<LinkerOptions Value="-macosx_version_min 10.4"/>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
<ExecuteAfter>
|
||||
<Command Value="sh macosx_postbuild.sh"/>
|
||||
</ExecuteAfter>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="demo07.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="demo07"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/demo07"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
<StripSymbols Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<PassLinkerOptions Value="True"/>
|
||||
<LinkerOptions Value="-macosx_version_min 10.4"/>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
<ExecuteAfter>
|
||||
<Command Value="sh macosx_postbuild.sh"/>
|
||||
</ExecuteAfter>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>demo07</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>demo07</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>demo07</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>zengl.demo07</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>demo</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
@@ -0,0 +1,13 @@
|
||||
# copy resources
|
||||
cp ../../../bin/data/zengl.png ../../../bin/demo07.app/Contents/Resources/
|
||||
cp ../../../bin/data/back01.jpg ../../../bin/demo07.app/Contents/Resources/
|
||||
cp ../../../bin/data/ground.png ../../../bin/demo07.app/Contents/Resources/
|
||||
cp ../../../bin/data/tux_walking.png ../../../bin/demo07.app/Contents/Resources/
|
||||
cp ../../../bin/data/tux_stand.png ../../../bin/demo07.app/Contents/Resources/
|
||||
cp ../../../bin/data/font* ../../../bin/demo07.app/Contents/Resources/
|
||||
# copy binary into bundle
|
||||
rm ../../../bin/demo07.app/Contents/MacOS/demo07
|
||||
cp ../../../bin/demo07 ../../../bin/demo07.app/Contents/MacOS/demo07
|
||||
# make Info.plist and copy icon
|
||||
cp -f demo07_macosx.plist ../../../bin/demo07.app/Contents/Info.plist
|
||||
cp ../../../bin/data/zengl.icns ../../../bin/demo07.app/Contents/Resources/demo07.icns
|
After Width: | Height: | Size: 56 KiB |
@@ -0,0 +1,149 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Release" Default="True"/>
|
||||
<Item2 Name="Debug">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/$(TargetCPU)-$(TargetOS)/demo08"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="0"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="BGRABitmapPack4NoGUI"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="demo08.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/$(TargetCPU)-$(TargetOS)/demo08"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
<StripSymbols Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@@ -0,0 +1,210 @@
|
||||
program demo08;
|
||||
|
||||
{$I zglCustomConfig.cfg}
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
{$R *.res}
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
BGRAZenGL in '..\BGRAZenGL.pas',
|
||||
BGRABitmapTypes,
|
||||
{$IFDEF USE_ZENGL_STATIC}
|
||||
zgl_main,
|
||||
zgl_screen,
|
||||
zgl_window,
|
||||
zgl_timers,
|
||||
zgl_keyboard,
|
||||
zgl_render_2d,
|
||||
zgl_primitives_2d,
|
||||
zgl_utils
|
||||
{$ELSE}
|
||||
zglHeader
|
||||
{$ENDIF}
|
||||
;
|
||||
|
||||
type
|
||||
{ TMikuSprite }
|
||||
|
||||
TMikuSprite = class(TBGLSprite)
|
||||
Speed: TPointF;
|
||||
procedure OnInit; override;
|
||||
procedure OnTimer; override;
|
||||
procedure OnDraw; override;
|
||||
end;
|
||||
|
||||
var
|
||||
dirRes : UTF8String {$IFNDEF MACOSX} = '../data/' {$ENDIF};
|
||||
fntMain : IBGLFont;
|
||||
texLogo : IBGLTexture;
|
||||
texMiku : IBGLTexture;
|
||||
time : Integer;
|
||||
|
||||
{ TMikuSprite }
|
||||
|
||||
procedure TMikuSprite.OnInit;
|
||||
var ratio: single;
|
||||
begin
|
||||
X := 800 + random( 800 ) + W/2;
|
||||
Y := random( 600 - round(H) ) + H/2;
|
||||
HorizontalAlign:= taCenter;
|
||||
VerticalAlign:= tlCenter;
|
||||
|
||||
// RU: Задаем скорость движения.
|
||||
// EN: Set the moving speed.
|
||||
Speed.X := -random( 10 ) / 5 - 0.5;
|
||||
Speed.Y := ( random( 10 ) - 5 ) / 5;
|
||||
|
||||
ratio := (Layer+3)/(9+3);
|
||||
W := W*ratio;
|
||||
H := H*ratio;
|
||||
|
||||
Color := BGRA(round(255*ratio),round(255*ratio),round(255*ratio));
|
||||
end;
|
||||
|
||||
procedure TMikuSprite.OnTimer;
|
||||
begin
|
||||
Location := Location + Speed;
|
||||
Frame := Frame + ( abs( speed.X ) + abs( speed.Y ) ) / 25;
|
||||
if Frame >= 8.49 Then
|
||||
Frame := 0.51;
|
||||
|
||||
// RU: Если спрайт выходит за пределы по X, сразу же удаляем его.
|
||||
// EN: Delete the sprite if it goes beyond X.
|
||||
if X < -W/2 Then QueryDestroy;
|
||||
|
||||
// RU: Если спрайт выходит за пределы по Y, ставим его в очередь на удаление.
|
||||
// EN: Add sprite to queue for delete if it goes beyond Y.
|
||||
if Y < -H/2 Then QueryDestroy;
|
||||
if Y > 600+H/2 Then QueryDestroy;
|
||||
end;
|
||||
|
||||
procedure TMikuSprite.OnDraw;
|
||||
begin
|
||||
if Layer = 9 then
|
||||
Texture.BlendMode := obmAdd
|
||||
else
|
||||
Texture.BlendMode := obmNormal;
|
||||
inherited OnDraw;
|
||||
end;
|
||||
|
||||
// RU: Добавить 100 спрайтов.
|
||||
// EN: Add 100 sprites.
|
||||
procedure AddMiku;
|
||||
var
|
||||
i : Integer;
|
||||
begin
|
||||
for i := 1 to 100 do
|
||||
TMikuSprite.Create( texMiku, random( 91 ) div 10 );
|
||||
end;
|
||||
|
||||
// RU: Удалить 100 спрайтов.
|
||||
// EN: Delete 100 sprites.
|
||||
procedure DelMiku;
|
||||
var
|
||||
i : Integer;
|
||||
begin
|
||||
// RU: Удалим 100 спрайтов со случайным ID.
|
||||
// EN: Delete 100 sprites with random ID.
|
||||
for i := 1 to 100 do
|
||||
BGLSpriteEngine.Delete( random( BGLSpriteEngine.Count ));
|
||||
end;
|
||||
|
||||
procedure Init;
|
||||
var
|
||||
i : Integer;
|
||||
begin
|
||||
texLogo := BGLTexture( dirRes + 'zengl.png' );
|
||||
|
||||
texMiku := BGLTexture( dirRes + 'miku.png' );
|
||||
texMiku.SetFrameSize( 128, 128 );
|
||||
|
||||
// RU: Создадим 200 спрайтов Miku-chan :)
|
||||
// EN: Create 200 sprites of Miku-chan :)
|
||||
for i := 1 to 2 do
|
||||
AddMiku();
|
||||
|
||||
fntMain := BGLZenFont( dirRes + 'font.zfi' );
|
||||
end;
|
||||
|
||||
procedure Draw;
|
||||
begin
|
||||
batch2d_Begin();
|
||||
// RU: Рисуем все спрайты находящиеся в текущем спрайтовом менеджере.
|
||||
// EN: Render all sprites contained in current sprite engine.
|
||||
if time > 255 Then
|
||||
begin
|
||||
BGLSpriteEngine.OnDraw;
|
||||
BGLCanvas.BlendMode := obmAdd;
|
||||
BGLCanvas.FillEllipse(400,300,100,100, BGRA(255,0,0,128),False);
|
||||
BGLCanvas.BlendMode := obmNormal;
|
||||
end;
|
||||
|
||||
if time <= 255 Then
|
||||
texLogo.Draw( 400, 300, taCenter, tlCenter, time )
|
||||
else
|
||||
if time < 510 Then
|
||||
begin
|
||||
BGLCanvas.FillRect(RectF(0, 0, 800, 600), BGRA(0,0,0,510 - time));
|
||||
texLogo.Draw( 400, 300, taCenter, tlCenter, 510 - time)
|
||||
end;
|
||||
|
||||
if time > 255 Then
|
||||
begin
|
||||
BGLCanvas.FillRect(RectF(0, 0, fntMain.TextWidth('Up/Down - Add/Delete Miku :)')+4, 64), BGRA(0,0,0,200));
|
||||
|
||||
fntMain.TextOut( 0, 0, 'FPS: ' + u_IntToStr( zgl_Get( RENDER_FPS ) ) );
|
||||
fntMain.TextOut( 0, 20, 'Sprites: ' + u_IntToStr( BGLSpriteEngine.Count ) );
|
||||
fntMain.TextOut( 0, 40, 'Up/Down - Add/Delete Miku :)' );
|
||||
end;
|
||||
batch2d_End();
|
||||
end;
|
||||
|
||||
procedure Timer;
|
||||
begin
|
||||
INC( time, 2 );
|
||||
|
||||
// RU: Выполняем обработку всех спрайтов в текущем спрайтовом менеджере.
|
||||
// EN: Process all sprites contained in current sprite engine.
|
||||
BGLSpriteEngine.OnTimer;
|
||||
|
||||
// RU: По нажатию пробела очистить все спрайты.
|
||||
// EN: Delete all sprites if space was pressed.
|
||||
if key_Press( K_SPACE ) Then BGLSpriteEngine.Clear;
|
||||
if key_Press( K_UP ) Then AddMiku();
|
||||
if key_Press( K_DOWN ) Then DelMiku();
|
||||
|
||||
if key_Press( K_ESCAPE ) Then zgl_Exit();
|
||||
|
||||
key_ClearState();
|
||||
end;
|
||||
|
||||
procedure Quit;
|
||||
begin
|
||||
// RU: Очищаем память от созданных спрайтов.
|
||||
// EN: Free allocated memory for sprites.
|
||||
BGLSpriteEngine.Clear;
|
||||
end;
|
||||
|
||||
Begin
|
||||
{$IFNDEF USE_ZENGL_STATIC}
|
||||
if not zglLoad( libZenGL ) Then exit;
|
||||
{$ENDIF}
|
||||
|
||||
randomize;
|
||||
|
||||
timer_Add( @Timer, 16 );
|
||||
timer_Add( @AddMiku, 1000 );
|
||||
|
||||
zgl_Reg( SYS_LOAD, @Init );
|
||||
zgl_Reg( SYS_DRAW, @Draw );
|
||||
zgl_Reg( SYS_EXIT, @Quit );
|
||||
|
||||
wnd_SetCaption( '08 - Sprite Engine' );
|
||||
|
||||
wnd_ShowCursor( TRUE );
|
||||
|
||||
scr_SetOptions( 800, 600, REFRESH_MAXIMUM, FALSE, FALSE );
|
||||
|
||||
zgl_Init();
|
||||
End.
|
@@ -0,0 +1,163 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Release" Default="True"/>
|
||||
<Item2 Name="Debug">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/demo08"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
<VerifyObjMethodCallValidity Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="0"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<PassLinkerOptions Value="True"/>
|
||||
<LinkerOptions Value="-macosx_version_min 10.4"/>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
<ExecuteAfter>
|
||||
<Command Value="sh macosx_postbuild.sh"/>
|
||||
</ExecuteAfter>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="demo08.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="demo08"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/demo08"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir);../../../headers"/>
|
||||
<OtherUnitFiles Value="../../../headers;../../../extra;../../../src;../../../lib/jpeg/$(TargetCPU)-$(TargetOS);../../../lib/msvcrt/$(TargetCPU);../../../lib/ogg/$(TargetCPU)-$(TargetOS);../../../lib/theora/$(TargetCPU)-$(TargetOS);../../../lib/zlib/$(TargetCPU)-$(TargetOS);../../../lib/zip/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../tmp/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
<StripSymbols Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<PassLinkerOptions Value="True"/>
|
||||
<LinkerOptions Value="-macosx_version_min 10.4"/>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<Verbosity>
|
||||
<ShowNotes Value="False"/>
|
||||
<ShowHints Value="False"/>
|
||||
<ShowGenInfo Value="False"/>
|
||||
</Verbosity>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
<ExecuteAfter>
|
||||
<Command Value="sh macosx_postbuild.sh"/>
|
||||
</ExecuteAfter>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>demo08</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>demo08</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>demo08</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>zengl.demo08</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>demo</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
@@ -0,0 +1,10 @@
|
||||
# copy resources
|
||||
cp ../../../bin/data/zengl.png ../../../bin/demo08.app/Contents/Resources/
|
||||
cp ../../../bin/data/miku.png ../../../bin/demo08.app/Contents/Resources/
|
||||
cp ../../../bin/data/font* ../../../bin/demo08.app/Contents/Resources/
|
||||
# copy binary into bundle
|
||||
rm ../../../bin/demo08.app/Contents/MacOS/demo08
|
||||
cp ../../../bin/demo08 ../../../bin/demo08.app/Contents/MacOS/demo08
|
||||
# make Info.plist and copy icon
|
||||
cp -f demo08_macosx.plist ../../../bin/demo08.app/Contents/Info.plist
|
||||
cp ../../../bin/data/zengl.icns ../../../bin/demo08.app/Contents/Resources/demo08.icns
|
1496
bgrabitmap/test/test4other/zengl/bgrazengl.pas
Normal file
5
bgrabitmap/test/test4other/zengl/readme.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Copy the files in ZenGL folder in the "demos\Lazarus" subfolder.
|
||||
|
||||
Open BGRABitmapPack4NoGUI_OpenGL package and then open one of the demos.
|
||||
|
||||
Note that one demo requires "arial.ttf" to be copied next to the executable.
|