renamed example gtkglarea to openglcontrol

git-svn-id: trunk@8730 -
This commit is contained in:
mattias 2006-02-11 09:24:56 +00:00
parent a5ea07ca09
commit 86d52425ee
3 changed files with 44 additions and 64 deletions

View File

@ -29,8 +29,7 @@ interface
uses uses
Classes, SysUtils, Forms, LResources, Buttons, Classes, SysUtils, Forms, LResources, Buttons,
StdCtrls, Dialogs, NVGL, Unix, StdCtrls, Dialogs, GL, OpenGLContext;
GTKGLAreaControl;
type type
TglTexture = class TglTexture = class
@ -42,7 +41,7 @@ type
type type
TExampleForm = class(TForm) TExampleForm = class(TForm)
GTKGLAreaControl1: TGTKGLAreaControl; OpenGLControl1: TOpenGLControl;
ExitButton1: TButton; ExitButton1: TButton;
LightingButton1: TButton; LightingButton1: TButton;
BlendButton1: TButton; BlendButton1: TButton;
@ -60,8 +59,8 @@ type
procedure MoveBackgroundButton1Click(Sender: TObject); procedure MoveBackgroundButton1Click(Sender: TObject);
procedure RotateZButton1Click(Sender: TObject); procedure RotateZButton1Click(Sender: TObject);
procedure RotateZButton2Click(Sender: TObject); procedure RotateZButton2Click(Sender: TObject);
procedure GTKGLAreaControl1Paint(Sender: TObject); procedure OpenGLControl1Paint(Sender: TObject);
procedure GTKGLAreaControl1Resize(Sender: TObject); procedure OpenGLControl1Resize(Sender: TObject);
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -251,7 +250,7 @@ begin
inherited Create(TheOwner); inherited Create(TheOwner);
if LazarusResources.Find(ClassName)=nil then begin if LazarusResources.Find(ClassName)=nil then begin
SetBounds((Screen.Width-800) div 2,(Screen.Height-600) div 2,800,600); SetBounds((Screen.Width-800) div 2,(Screen.Height-600) div 2,800,600);
Caption:='LCL Example for the gtkglarea component'; Caption:='LCL example for the TOpenGLControl';
Application.OnIdle:=@IdleFunc; Application.OnIdle:=@IdleFunc;
OnResize:=@FormResize; OnResize:=@FormResize;
@ -266,7 +265,6 @@ begin
SetBounds(320,10,80,25); SetBounds(320,10,80,25);
Caption:='Exit'; Caption:='Exit';
OnClick:=@ExitButton1Click; OnClick:=@ExitButton1Click;
Visible:=true;
end; end;
LightingButton1:=TButton.Create(Self); LightingButton1:=TButton.Create(Self);
@ -276,7 +274,6 @@ begin
SetBounds(220,0,80,25); SetBounds(220,0,80,25);
Caption:='Lighting'; Caption:='Lighting';
OnClick:=@LightingButton1Click; OnClick:=@LightingButton1Click;
Visible:=true;
end; end;
BlendButton1:=TButton.Create(Self); BlendButton1:=TButton.Create(Self);
@ -286,7 +283,6 @@ begin
SetBounds(220,0,80,25); SetBounds(220,0,80,25);
Caption:='Blending'; Caption:='Blending';
OnClick:=@BlendButton1Click; OnClick:=@BlendButton1Click;
Visible:=true;
end; end;
MoveCubeButton1:=TButton.Create(Self); MoveCubeButton1:=TButton.Create(Self);
@ -297,7 +293,6 @@ begin
Caption:='Move Cube'; Caption:='Move Cube';
Checked:=false; Checked:=false;
OnClick:=@MoveCubeButton1Click; OnClick:=@MoveCubeButton1Click;
Visible:=true;
end; end;
MoveBackgroundButton1:=TButton.Create(Self); MoveBackgroundButton1:=TButton.Create(Self);
@ -308,7 +303,6 @@ begin
Caption:='Move Back'; Caption:='Move Back';
Checked:=false; Checked:=false;
OnClick:=@MoveBackgroundButton1Click; OnClick:=@MoveBackgroundButton1Click;
Visible:=true;
end; end;
RotateZButton1:=TButton.Create(Self); RotateZButton1:=TButton.Create(Self);
@ -319,7 +313,6 @@ begin
Caption:='P. Respawn'; Caption:='P. Respawn';
Checked:=false; Checked:=false;
OnClick:=@RotateZButton1Click; OnClick:=@RotateZButton1Click;
Visible:=true;
end; end;
RotateZButton2:=TButton.Create(Self); RotateZButton2:=TButton.Create(Self);
@ -330,7 +323,6 @@ begin
Caption:='P. Blending'; Caption:='P. Blending';
Checked:=false; Checked:=false;
OnClick:=@RotateZButton2Click; OnClick:=@RotateZButton2Click;
Visible:=true;
end; end;
HintLabel1:=TLabel.Create(Self); HintLabel1:=TLabel.Create(Self);
@ -339,20 +331,18 @@ begin
Parent:=Self; Parent:=Self;
SetBounds(0,0,280,50); SetBounds(0,0,280,50);
Caption:='Demo'; Caption:='Demo';
Visible:=true;
end; end;
// resize the components first, since the gtkglarea needs some time to setup // resize the components first, because the opengl context needs some time to setup
FormResize(Self); FormResize(Self);
GTKGLAreaControl1:=TGTKGLAreaControl.Create(Self); OpenGLControl1:=TOpenGLControl.Create(Self);
with GTKGLAreaControl1 do begin with OpenGLControl1 do begin
Name:='GTKGLAreaControl1'; Name:='OpenGLControl1';
Parent:=Self; Parent:=Self;
SetBounds(10,90,380,200); SetBounds(10,90,380,200);
OnPaint:=@GTKGLAreaControl1Paint; OnPaint:=@OpenGLControl1Paint;
OnResize:=@GTKGLAreaControl1Resize; OnResize:=@OpenGLControl1Resize;
Visible:=true;
end; end;
end; end;
@ -450,7 +440,7 @@ end;
procedure TExampleForm.IdleFunc(Sender: TObject; var Done: Boolean); procedure TExampleForm.IdleFunc(Sender: TObject; var Done: Boolean);
begin begin
GTKGLAreaControl1Paint(Self); OpenGLControl1Paint(Self);
Done:=false; // tell lcl to handle messages and return immediatly Done:=false; // tell lcl to handle messages and return immediatly
end; end;
@ -462,25 +452,25 @@ procedure TExampleForm.LightingButton1Click(Sender: TObject);
begin begin
if lighted then glDisable(GL_LIGHTING) else glEnable(GL_LIGHTING); if lighted then glDisable(GL_LIGHTING) else glEnable(GL_LIGHTING);
lighted:=not lighted; lighted:=not lighted;
GTKGLAreaControl1Paint(Self); OpenGLControl1Paint(Self);
end; end;
procedure TExampleForm.BlendButton1Click(Sender: TObject); procedure TExampleForm.BlendButton1Click(Sender: TObject);
begin begin
blended:=not blended; blended:=not blended;
GTKGLAreaControl1Paint(Self); OpenGLControl1Paint(Self);
end; end;
procedure TExampleForm.MoveCubeButton1Click(Sender: TObject); procedure TExampleForm.MoveCubeButton1Click(Sender: TObject);
begin begin
MoveCube:=not MoveCube; MoveCube:=not MoveCube;
GTKGLAreaControl1Paint(Self); OpenGLControl1Paint(Self);
end; end;
procedure TExampleForm.MoveBackgroundButton1Click(Sender: TObject); procedure TExampleForm.MoveBackgroundButton1Click(Sender: TObject);
begin begin
MoveBackground:=not MoveBackground; MoveBackground:=not MoveBackground;
GTKGLAreaControl1Paint(Self); OpenGLControl1Paint(Self);
end; end;
procedure TExampleForm.RotateZButton1Click(Sender: TObject); procedure TExampleForm.RotateZButton1Click(Sender: TObject);
@ -491,7 +481,7 @@ end;
procedure TExampleForm.RotateZButton2Click(Sender: TObject); procedure TExampleForm.RotateZButton2Click(Sender: TObject);
begin begin
ParticleBlended:=not ParticleBlended; ParticleBlended:=not ParticleBlended;
GTKGLAreaControl1Paint(Self); OpenGLControl1Paint(Self);
end; end;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -500,8 +490,8 @@ end;
procedure TExampleForm.FormResize(Sender: TObject); procedure TExampleForm.FormResize(Sender: TObject);
begin begin
if GTKGLAreaControl1<>nil then if OpenGLControl1<>nil then
GTKGLAreaControl1.SetBounds(10, 30, Width-120, Height-40); OpenGLControl1.SetBounds(10, 30, Width-120, Height-40);
ExitButton1.SetBounds(Width-90, 5, 80, 25); ExitButton1.SetBounds(Width-90, 5, 80, 25);
LightingButton1.SetBounds(Width-90, 180, 80, 25); LightingButton1.SetBounds(Width-90, 180, 80, 25);
BlendButton1.SetBounds(Width-90, 210, 80, 25); BlendButton1.SetBounds(Width-90, 210, 80, 25);
@ -517,7 +507,7 @@ begin
Close; Close;
end; end;
procedure TExampleForm.GTKGLAreaControl1Paint(Sender: TObject); procedure TExampleForm.OpenGLControl1Paint(Sender: TObject);
procedure myInit; procedure myInit;
begin begin
@ -749,7 +739,7 @@ var
CurTime: TDateTime; CurTime: TDateTime;
MSecs: integer; MSecs: integer;
begin begin
if GTKGLAreaControl1.MakeCurrent then if OpenGLControl1.MakeCurrent then
begin begin
if not AreaInitialized then begin if not AreaInitialized then begin
myInit; myInit;
@ -758,7 +748,7 @@ begin
glLoadIdentity (); { define the projection } glLoadIdentity (); { define the projection }
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); { transformation } glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); { transformation }
glMatrixMode (GL_MODELVIEW); { back to modelview matrix } glMatrixMode (GL_MODELVIEW); { back to modelview matrix }
glViewport (0, 0, GTKGLAreaControl1.Width, GTKGLAreaControl1.Height); glViewport (0, 0, OpenGLControl1.Width, OpenGLControl1.Height);
{ define the viewport } { define the viewport }
AreaInitialized:=true; AreaInitialized:=true;
end; end;
@ -825,15 +815,15 @@ begin
//glFlush; //glFlush;
//glFinish; //glFinish;
// Swap backbuffer to front // Swap backbuffer to front
GTKGLAreaControl1.SwapBuffers; OpenGLControl1.SwapBuffers;
end; end;
end; end;
procedure TExampleForm.GTKGLAreaControl1Resize(Sender: TObject); procedure TExampleForm.OpenGLControl1Resize(Sender: TObject);
begin begin
if (AreaInitialized) if (AreaInitialized)
and GTKGLAreaControl1.MakeCurrent then and OpenGLControl1.MakeCurrent then
glViewport (0, 0, GTKGLAreaControl1.Width, GTKGLAreaControl1.Height); glViewport (0, 0, OpenGLControl1.Width, OpenGLControl1.Height);
end; end;

View File

@ -5,38 +5,16 @@
<Version Value="5"/> <Version Value="5"/>
<General> <General>
<Flags> <Flags>
<SaveOnlyProjectUnits Value="True"/>
<MainUnitHasCreateFormStatements Value="False"/> <MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/> <MainUnitHasTitleStatement Value="False"/>
</Flags> </Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<ActiveEditorIndexAtStart Value="4"/>
<IconPath Value="./"/> <IconPath Value="./"/>
<TargetFileExt Value=""/> <TargetFileExt Value=""/>
<Title Value="gtkglarea_demo"/> <Title Value="openglcontrol_demo"/>
</General> </General>
<Units Count="2"> <LazDoc Paths=""/>
<Unit0>
<CursorPos X="15" Y="18"/>
<EditorIndex Value="0"/>
<Filename Value="gtkglarea_demo.pp"/>
<IsPartOfProject Value="True"/>
<Loaded Value="True"/>
<TopLine Value="1"/>
<UnitName Value="GTKGLArea_Demo"/>
<UsageCount Value="28"/>
</Unit0>
<Unit1>
<CursorPos X="34" Y="828"/>
<EditorIndex Value="4"/>
<Filename Value="exampleform.pp"/>
<IsPartOfProject Value="True"/>
<Loaded Value="True"/>
<TopLine Value="801"/>
<UnitName Value="ExampleForm"/>
<UsageCount Value="28"/>
</Unit1>
</Units>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IgnoreBinaries Value="False"/> <IgnoreBinaries Value="False"/>
@ -52,12 +30,24 @@
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item1> </Item1>
<Item2> <Item2>
<PackageName Value="GTKOpenGL"/> <PackageName Value="LazOpenGLContext"/>
</Item2> </Item2>
</RequiredPackages> </RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="openglcontrol_demo.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="OpenGLControl_Demo"/>
</Unit0>
<Unit1>
<Filename Value="exampleform.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ExampleForm"/>
</Unit1>
</Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>
<Version Value="4"/> <Version Value="5"/>
<SearchPaths> <SearchPaths>
<LCLWidgetType Value="gtk"/> <LCLWidgetType Value="gtk"/>
<SrcPath Value="$(LazarusDir)/lcl/;$(LazarusDir)/lcl/interfaces/gtk/"/> <SrcPath Value="$(LazarusDir)/lcl/;$(LazarusDir)/lcl/interfaces/gtk/"/>

View File

@ -19,7 +19,7 @@
*************************************************************************** ***************************************************************************
} }
program GTKGLArea_Demo; program OpenGLControl_Demo;
{$MODE objfpc}{$H+} {$MODE objfpc}{$H+}