of TglTexture ;, lightdif, lightpos, light2pos, light2dif, pos, light3dif, light4pos, light4dif, fogcolor: array [0..3] of GLfloat ;: TParticleEngine ;, CubeList, BackList: GLuint; direction: boolean ;: single ;: integer; LoadFileToMemStream (const Filename: string): TMemoryStream; LoadglTexImage2DFromPNG (PNGFilename: string ;: TglTexture): boolean; LoadFileToMemStream (const Filename: string): TMemoryStream; FileStream: TFileStream;:=TMemoryStream.Create;:=TFileStream.Create (UTF8ToSys (Filename), fmOpenRead);.CopyFrom(FileStream,FileStream.Size);.Position:=0;.Free;;.Free;:=nil;;;LoadglTexImage2DFromPNG(PNGFilename: string; Image: TglTexture
): boolean ;: TPortableNetworkGraphic ;: TLazIntfImage ;: Integer ;: Integer ;: TFPColor ;: PByte;:=false;:=TPortableNetworkGraphic.Create;:=nil;.LoadFromFile(PNGFilename);:=png.CreateIntfImage;.Width:=IntfImg.Width;.Height:=IntfImg.Height;(Image.Data,Image.Width*Image.Height * 3);:=PByte (Image.Data); y:=0 to IntfImg.Height - 1 do beginx:=0 to IntfImg.Width - 1 do begin:=IntfImg.Colors [x, y]; ^:= c.red shr 8; (p); ^:=c.green shr 8; (p); ^:=c.blue shr 8; (p) ;;;. Free; .Free ;;:=true ;;
{TExampleForm} TExampleForm.Create (TheOwner: TComponent); CreateNew (TheOwner); LazarusResources.Find (ClassName)=nil then begin ((Screen.Width - 800) div 2, (Screen.Height- 600) div 2,800,600);:= LCL example for the TOpenGLControlraquo;;.OnIdle:=@IdleFunc;:=@FormResize;:=false;:=false;:=TParticleEngine.Create;:=TButton.Create(Self);ExitButton1 do begin:=laquo;ExitButton1raquo;;:=Self;(320,10,80,25);:=laquo;Exitraquo;;:=@ExitButton1Click;;:=TButton.Create(Self);MoveCubeButton1 do begin:=laquo;MoveCubeButton1raquo;;:=Self;(320,10,80,25);:=laquo;Moveraquo;;:=false;:=@MoveCubeButton1Click;;
//resize the components first, because the opengl context needs some time to setup (Self);:=TOpenGLControl.Create (Self); OpenGLControl1 do begin:=laquo;OpenGLControl1raquo;;:=Self;(10,90,380,200);:=@OpenGLControl1Paint;:=@OpenGLControl1Resize;;;;
//now resize (Self) ;; TExampleForm.Destroy; i: integer; i:=0 to 2 do begin[i]:=0;(MyglTextures[i]);;(ParticleEngine);Destroy;;TExampleForm.LoadTextures;LoadglTexture(Filename:string; Image: TglTexture);:=ExpandFileNameUTF8 (Filename); not LoadglTexImage2DFromPNG (Filename, Image) then begin ( File not found ,
Image file not found: + Filename ,, [mbOk], 0); Exception.Create ( Image file not found: + Filename) ;;;: Integer;
begin
for i:=0 to 2 do begin [i]:=0; [i]:=TglTexture.Create ;;
{loading the texture and setting its parameters}(laquo;data/particle.pngraquo;,MyglTextures[0]);(laquo;data/texture2.pngraquo;,MyglTextures[1]);(laquo;data/texture3.pngraquo;,MyglTextures[2]);;
//--------------------------------------------------------------------------
//Particle Engine
//-------------------------------------------------------------------------- TParticleEngine.Create; i: integer; i:=1 to 2001 do Particle [i]:=TParticle.Create;:=0 ;; TParticleEngine.Destroy; i: integer; i:=1 to 2 001 do FreeAndNil (Particle [i]); Destroy ;; TParticleEngine.DrawParticles; i: integer; i: =1 to 2 001 do begin; (Particle [i] .x, Particle [i] .y, Particle [i] .z); (ParticleList) ;;;; TParticleEngine.RespawnParticle (i: integer); (xspawn gt; 2 ) and (direction=true) then direction:=false; (xspawn lt; - 2) and (direction=false) then direction:=true; direction then:=xspawn + 0.0002 * (timer/10):=xspawn - 0.0002 * (timer/10); [i] .x:=xspawn; [i] .y:=- 0.5; [i] .z:=0; [i] .vx:=- 0.005 + GLFloat (random (2000) )/200000; [i] .vy:=0.035 + GLFloat (random (750))/100000; [i] .vz:=- 0.005+GLFloat(random(2000))/200000;[i].life:=GLFloat(random(1250))/1000+1;;TParticleEngine.MoveParticles;i: integer; i:=1 to 2 001 do beginParticle [i] .life gt; 0 then begin [i] .life:=Particle [i] .life - 0.01 * (timer/10); [i] .x:=Particle [ i] .x + Particle [i] .vx * (timer/10); [i] .vy:=Particle [i] .vy - 0.00035 * (timer/10);// gravity[i].y:=Particle[i].y+Particle[i].vy*(timer/10);[i].z:=Particle[i].z+Particle[i].vz*(timer/10);else begin (i) ;;;;
procedure TParticleEngine.Start; i: integer; i:=1 to 2001 do begin (i) ;;;
//---------------------------------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++
//---------------------------------------------------------------------------TExampleForm.IdleFunc(Sender: TObject; var Done: Boolean) ;. Invalidate;
//OpenGLControl1Paint (Self);:=false;// Tell lcl to handle messages and return immediatly;
//--------------------------------------------------...