unit Unit1;
{$mode objfpc}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, OpenGLContext, BGRABitmap, BGRABitmapTypes, BGRAOpenGL;
{ TForm1 }
type
TForm1 = class(TForm)
Button1: TButton;
Panel1: TPanel;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure OpenGLControl1Paint(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ private declarations }
public
bgl1, bgl2: TBGLBitmap;
OpenGLControl1: TOpenGLControl;
DataLoaded: boolean;
angle: single;
procedure Load;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
OpenGLControl1 := TOpenGLControl.Create(Self);
with OpenGLControl1 do
begin
Align := alClient;
Parent := Self;
OnPaint:=@OpenGLControl1Paint;
AutoResizeViewport := True;
end;
DataLoaded := False;
end;
procedure TForm1.OpenGLControl1Paint(Sender: TObject);
var
w,h,x,y:single;
begin
Load;
BGLViewPort(OpenGLControl1.Width, OpenGLControl1.Height, BGRAWhite);
w:=OpenGLControl1.Width;
h:=OpenGLControl1.Height;
//BGLCanvas.PutImage(100, 100, bgl1.Texture);
//BGLCanvas.PutImageAngle(100, 100, bgl1.Texture, angle);
//BGLCanvas.PutImage(400, 100, bgl2.Texture);
x:=100;
Y:=100;
//BGLCanvas.PutImageAngle(x, y, bgl2.Texture, angle);
bgl2.Texture.DrawAngle(x,y,angle,PointF(x,y),True);
BGLCanvas.RoundRect(x-1,y-1,x+1,y+1,2,2,BGRA(120,120,120),BGRA(120,120,120));
OpenGLControl1.SwapBuffers;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
angle := angle + 1;
if angle = 360 then
angle := 0;
OpenGLControl1.DoOnPaint;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled := not Timer1.Enabled;
end;
procedure TForm1.Load;
begin
if not DataLoaded then
begin
//bgl1 := TBGLBitmap.Create(10, 200, BGRABlack);
bgl2 := TBGLBitmap.Create(14, 200);
bgl2.Rectangle(1, 1, bgl2.Width - 1, bgl2.Height - 1, BGRABlack, BGRABlack, dmSet);
DataLoaded := True;
end;
end;
end.