unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
OpenGLContext, glcanvas, gl;
type
{ TForm1 }
TForm1 = class(TForm)
OpenGLControl1: TOpenGLControl;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure OpenGLControl1Paint(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
public
end;
var
Form1: TForm1;
tex: GLuint;
tex_w, tex_h: integer;
rot: single;
implementation
{$R *.lfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
glInit(OpenGLControl1); // initialisation OpenGL
glEnableVSync(true); // synchro verticale activée
tex := glLoadPNGToTexture('girl7.png', tex_w, tex_h); // exemple de texture
rot := 0.0;
end;
procedure TForm1.OpenGLControl1Paint(Sender: TObject);
begin
glFillScreen(OpenGLControl1, 0.2, 0.2, 0.2, 1.0);
glMoveToTexture2D(-800, 700, 1600, 700, 3.0, tex_w, tex_h, tex, 0.5, 0.5, 0, 1.0, 1.0, 1.0, 1.0,False, False, true, etLinear);
glMoveToTexture2D(-800, 600, 1600, 600, 3.0, tex_w, tex_h, tex, 0.5, 0.5, 0, 1.0, 1.0, 1.0, 1.0,False, False, true, etEaseIn);
glMoveToTexture2D(-800, 500, 1600, 500, 3.0, tex_w, tex_h, tex, 0.5, 0.5, 0, 1.0, 1.0, 1.0, 1.0,False, False, true, etEaseOut);
glMoveToTexture2D(-800, 400, 1600, 400, 3.0, tex_w, tex_h, tex, 0.5, 0.5, 0, 1.0, 1.0, 1.0, 1.0,False, False, true, etEaseInOut);
glMoveToTexture2D(-800, 300, 1600, 300, 3.0, tex_w, tex_h, tex, 0.5, 0.5, 0, 1.0, 1.0, 1.0, 1.0,False, False, true, etBounceOut);
glMoveToTexture2D(-800, 200, 1600, 200, 3.0, tex_w, tex_h, tex, 0.5, 0.5, 0, 1.0, 1.0, 1.0, 1.0,False, False, true, etElasticOut);
glMoveToTexture2D(-800, 100, 1600, 100, 3.0, tex_w, tex_h, tex, 0.5, 0.5, 0, 1.0, 1.0, 1.0, 1.0,False, False, true, etBackOut);
//etLinear,etEaseIn,etEaseOut,etEaseInOut,etBounceOut,etElasticOut,etBackOut
glMovementTexture2D(800, 300, 0,300, 10.0, mtLinear, tex_w, tex_h, tex,0.5,0.5,rot, 1.0,1.0,0.0,1.0);
glMovementTexture2D(800, 200, 600,200, 10.0, mtSinus, tex_w, tex_h, tex,0.5,0.5,-rot,0.0,1.0,0.0,1.0);
glMovementTexture2D(800, 200, 600,200, 10.0, mtCircular, tex_w, tex_h, tex,0.5,0.5);
glMovementTexture2D(800, 200, 600,200, 10.0, mtSpiral, tex_w, tex_h, tex,0.5,0.5);
glMovementTexture2D(800, 200, 600,200, 10.0, mtFigure8, tex_w, tex_h, tex,0.5,0.5);
glMovementTexture2D(800, 200, 600,200, 10.0, mtZigZag, tex_w, tex_h, tex,0.5,0.5);
glMovementTexture2D(800, 200, 600,200, 10.0, mtOrbital, tex_w, tex_h, tex,0.5,0.5);
//mtLinear, mtSinus, mtCircular, mtSpiral, mtFigure8, mtZigZag,mtOrbital
glDrawText3D(600,200,'GL MOVETO AND MOVEMENT DEMO',4,4,1.0,1.0,1.0,1.0,0.8,0.8,0.8,'Impact',34,[],rot,true);
OpenGLControl1.SwapBuffers;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
rot += 1.2; // incrémente l'angle
OpenGLControl1.Invalidate; // redessine
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
glClearAllTextures; // libère toutes les textures
glClearTextCache;
end;
end.