Стартовый пул
This commit is contained in:
BIN
bgrabitmap/test/test4lcl_opengl/opengltest2/earth.png
Normal file
BIN
bgrabitmap/test/test4lcl_opengl/opengltest2/earth.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 668 KiB |
BIN
bgrabitmap/test/test4lcl_opengl/opengltest2/opengltest2.ico
Normal file
BIN
bgrabitmap/test/test4lcl_opengl/opengltest2/opengltest2.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
88
bgrabitmap/test/test4lcl_opengl/opengltest2/opengltest2.lpi
Normal file
88
bgrabitmap/test/test4lcl_opengl/opengltest2/opengltest2.lpi
Normal file
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="opengltest2"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<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"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="3">
|
||||
<Item1>
|
||||
<PackageName Value="BGRABitmapPack"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="lazopenglcontext"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="opengltest2.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="opengltest2"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
21
bgrabitmap/test/test4lcl_opengl/opengltest2/opengltest2.lpr
Normal file
21
bgrabitmap/test/test4lcl_opengl/opengltest2/opengltest2.lpr
Normal file
@@ -0,0 +1,21 @@
|
||||
program opengltest2;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, lazopenglcontext, Unit1
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
15
bgrabitmap/test/test4lcl_opengl/opengltest2/unit1.lfm
Normal file
15
bgrabitmap/test/test4lcl_opengl/opengltest2/unit1.lfm
Normal file
@@ -0,0 +1,15 @@
|
||||
object Form1: TForm1
|
||||
Left = 231
|
||||
Height = 240
|
||||
Top = 114
|
||||
Width = 320
|
||||
Caption = 'Rotate and zoom'
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '1.4.0.4'
|
||||
object Timer1: TTimer
|
||||
Interval = 15
|
||||
OnTimer = Timer1Timer
|
||||
left = 19
|
||||
top = 16
|
||||
end
|
||||
end
|
115
bgrabitmap/test/test4lcl_opengl/opengltest2/unit1.pas
Normal file
115
bgrabitmap/test/test4lcl_opengl/opengltest2/unit1.pas
Normal file
@@ -0,0 +1,115 @@
|
||||
unit Unit1;
|
||||
|
||||
{
|
||||
-If you didnt saw opengltest1, go see it first then come back
|
||||
|
||||
-OpenGL is fast, so we want to test it a bit
|
||||
-Here you will see that you can update your painting much fast without any particular cpu using or whatever
|
||||
}
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
OpenGLContext, BGRABitmap, BGRABitmapTypes, BGRAOpenGL;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Timer1: TTimer;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
TexBig,TexSmall: IBGLTexture;
|
||||
OpenGLControl: TOpenGLControl;
|
||||
DataLoaded: boolean;
|
||||
angle: single;
|
||||
GoBack: boolean;
|
||||
procedure Load;
|
||||
procedure OpenGLControlPaint(Sender: TObject);
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
OpenGLControl := TOpenGLControl.Create(Self);
|
||||
with OpenGLControl do
|
||||
begin
|
||||
Align := alClient;
|
||||
Parent := Self;
|
||||
OnPaint := @OpenGLControlPaint;
|
||||
AutoResizeViewport := True;
|
||||
end;
|
||||
DataLoaded := False;
|
||||
GoBack := False;
|
||||
angle := 0;
|
||||
WindowState := wsMaximized;
|
||||
end;
|
||||
|
||||
procedure TForm1.Timer1Timer(Sender: TObject);
|
||||
begin
|
||||
if not GoBack then
|
||||
begin
|
||||
if angle = 360 then
|
||||
GoBack := True;
|
||||
angle += 1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if angle = 0 then
|
||||
GoBack := False;
|
||||
angle -= 1;
|
||||
end;
|
||||
OpenGLControl.DoOnPaint;
|
||||
end;
|
||||
|
||||
procedure TForm1.Load;
|
||||
var bmp, bmpSmall : TBGLBitmap;
|
||||
begin
|
||||
if not DataLoaded then
|
||||
begin
|
||||
bmp := TBGLBitmap.Create(ExtractFilePath(Application.ExeName) + 'earth.png');
|
||||
bmp.ResampleFilter := rfBestQuality;
|
||||
bmpSmall := bmp.Resample(bmp.Width div 2,bmp.Height div 2) as TBGLBitmap;
|
||||
TexBig := bmp.MakeTextureAndFree;
|
||||
TexSmall := bmpSmall.MakeTextureAndFree;
|
||||
|
||||
DataLoaded := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.OpenGLControlPaint(Sender: TObject);
|
||||
var
|
||||
x, y, w: single;
|
||||
tex: IBGLTexture;
|
||||
begin
|
||||
Load;
|
||||
BGLViewPort(OpenGLControl.Width, OpenGLControl.Height, BGRABlack);
|
||||
|
||||
x := OpenGLControl.Width / 2;
|
||||
y := OpenGLControl.Height / 2;
|
||||
w := (angle / 360) * OpenGLControl.Width;
|
||||
if w < TexSmall.Width then
|
||||
tex := TexSmall
|
||||
else
|
||||
tex := TexBig;
|
||||
tex.StretchDrawAngle(x, y, w, w/tex.Width*tex.Height, angle, PointF(tex.Width/2,tex.Height/2), False);
|
||||
|
||||
OpenGLControl.SwapBuffers;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user