mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 14:19:17 +02:00
MG: updated gtkglarea demo
git-svn-id: trunk@362 -
This commit is contained in:
parent
a5a458d225
commit
82db53ce16
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -13,6 +13,7 @@ components/codetools/linkscanner.pas svneol=native#text/pascal
|
|||||||
components/codetools/memcheck.pas svneol=native#text/pascal
|
components/codetools/memcheck.pas svneol=native#text/pascal
|
||||||
components/codetools/sourcechanger.pas svneol=native#text/pascal
|
components/codetools/sourcechanger.pas svneol=native#text/pascal
|
||||||
components/codetools/sourcelog.pas svneol=native#text/pascal
|
components/codetools/sourcelog.pas svneol=native#text/pascal
|
||||||
|
components/gtk/gtkglarea/data/particle.bmp -text svneol=native#image/bmp
|
||||||
components/gtk/gtkglarea/data/texture1.bmp -text svneol=native#image/bmp
|
components/gtk/gtkglarea/data/texture1.bmp -text svneol=native#image/bmp
|
||||||
components/gtk/gtkglarea/data/texture2.bmp -text svneol=native#image/bmp
|
components/gtk/gtkglarea/data/texture2.bmp -text svneol=native#image/bmp
|
||||||
components/gtk/gtkglarea/data/texture3.bmp -text svneol=native#image/bmp
|
components/gtk/gtkglarea/data/texture3.bmp -text svneol=native#image/bmp
|
||||||
|
BIN
components/gtk/gtkglarea/data/particle.bmp
Normal file
BIN
components/gtk/gtkglarea/data/particle.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
@ -71,7 +71,8 @@ type
|
|||||||
|
|
||||||
TParticleEngine = class
|
TParticleEngine = class
|
||||||
//x, y, z: GLfloat;
|
//x, y, z: GLfloat;
|
||||||
Particle: array [1..500] of TParticle;
|
xspawn: GLfloat;
|
||||||
|
Particle: array [1..501] of TParticle;
|
||||||
procedure MoveParticles;
|
procedure MoveParticles;
|
||||||
procedure DrawParticles;
|
procedure DrawParticles;
|
||||||
//procedure Init;
|
//procedure Init;
|
||||||
@ -87,13 +88,15 @@ var AnExampleForm: TExampleForm;
|
|||||||
front, left1: GLuint;
|
front, left1: GLuint;
|
||||||
rx, ry, rz, rrx, rry, rrz: single;
|
rx, ry, rz, rrx, rry, rrz: single;
|
||||||
LightAmbient : array [0..3] of GLfloat;
|
LightAmbient : array [0..3] of GLfloat;
|
||||||
checked, blended, MoveCube, MoveBackground: boolean;
|
checked, blended, lighted, ParticleBlended, MoveCube, MoveBackground: boolean;
|
||||||
textures : array [0..2] of GLuint; // Storage For 3 Textures
|
textures : array [0..2] of GLuint; // Storage For 3 Textures
|
||||||
MyglTextures : array [0..2] of TglTexture;
|
MyglTextures : array [0..2] of TglTexture;
|
||||||
lightamb, lightdif, lightpos, light2pos, light2dif, light3pos, light3dif, light4pos, light4dif, fogcolor: array [0..3] of GLfloat;
|
lightamb, lightdif, lightpos, light2pos, light2dif,
|
||||||
|
light3pos, light3dif, light4pos, light4dif, fogcolor: array [0..3] of GLfloat;
|
||||||
ParticleEngine: TParticleEngine;
|
ParticleEngine: TParticleEngine;
|
||||||
drops: GLuint;
|
ParticleList, CubeList, BackList: GLuint;
|
||||||
|
|
||||||
|
var direction: boolean;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -117,7 +120,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LoadglTexImage2DFromBitmapFile(Filename:string; var Image:TglTexture): boolean;
|
function LoadglTexImage2DFromBitmapFile(Filename:string;
|
||||||
|
var Image:TglTexture): boolean;
|
||||||
type
|
type
|
||||||
TBITMAPFILEHEADER = packed record
|
TBITMAPFILEHEADER = packed record
|
||||||
bfType: Word;
|
bfType: Word;
|
||||||
@ -177,7 +181,10 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
MemStream:=LoadFileToMemStream(Filename);
|
MemStream:=LoadFileToMemStream(Filename);
|
||||||
if MemStream=nil then exit;
|
if MemStream=nil then begin
|
||||||
|
writeln('Unable to load "',Filename,'"');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
try
|
try
|
||||||
if (MemStream.Read(BmpHead, sizeof(BmpHead))<sizeof(BmpHead))
|
if (MemStream.Read(BmpHead, sizeof(BmpHead))<sizeof(BmpHead))
|
||||||
or (BmpHead.bfType <> $4D42) then begin
|
or (BmpHead.bfType <> $4D42) then begin
|
||||||
@ -216,16 +223,14 @@ begin
|
|||||||
try
|
try
|
||||||
for i:=0 to PixelCount-1 do begin
|
for i:=0 to PixelCount-1 do begin
|
||||||
MemStream.Read(AnRGBQuad,sizeOf(RGBQuad));
|
MemStream.Read(AnRGBQuad,sizeOf(RGBQuad));
|
||||||
{$IFOPT R+}{$DEFINE RangeCheck}{$ENDIF}
|
{$IFOPT R+}{$DEFINE RangeCheckOn}{$ENDIF}
|
||||||
{$R-}
|
{$R-}
|
||||||
with PRawImage(Image.Data)^ do begin
|
with PRawImage(Image.Data)^ do begin
|
||||||
p[i*3+0]:=AnRGBQuad.rgbRed;
|
p[i*3+0]:=AnRGBQuad.rgbRed;
|
||||||
p[i*3+1]:=AnRGBQuad.rgbGreen;
|
p[i*3+1]:=AnRGBQuad.rgbGreen;
|
||||||
p[i*3+2]:=AnRGBQuad.rgbBlue;
|
p[i*3+2]:=AnRGBQuad.rgbBlue;
|
||||||
end;
|
end;
|
||||||
{$IFDEF RangeCheck}
|
{$IFDEF RangeCheckOn}{$R+}{$ELSE}{$R-}{$ENDIF}
|
||||||
{$R+}
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
except
|
except
|
||||||
writeln('Error converting bitmap');
|
writeln('Error converting bitmap');
|
||||||
@ -254,6 +259,7 @@ begin
|
|||||||
Application.OnIdle:=@IdleFunc;
|
Application.OnIdle:=@IdleFunc;
|
||||||
OnResize:=@FormResize;
|
OnResize:=@FormResize;
|
||||||
blended:=false;
|
blended:=false;
|
||||||
|
lighted:=false;
|
||||||
ParticleEngine:=TParticleEngine.Create;
|
ParticleEngine:=TParticleEngine.Create;
|
||||||
|
|
||||||
ExitButton1:=TButton.Create(Self);
|
ExitButton1:=TButton.Create(Self);
|
||||||
@ -324,7 +330,7 @@ begin
|
|||||||
Name:='RotateZButton2';
|
Name:='RotateZButton2';
|
||||||
Parent:=Self;
|
Parent:=Self;
|
||||||
SetBounds(320,10,80,25);
|
SetBounds(320,10,80,25);
|
||||||
Caption:='Rotate Z -';
|
Caption:='P. Blending';
|
||||||
Checked:=false;
|
Checked:=false;
|
||||||
OnClick:=@RotateZButton2Click;
|
OnClick:=@RotateZButton2Click;
|
||||||
Visible:=true;
|
Visible:=true;
|
||||||
@ -362,7 +368,8 @@ end;
|
|||||||
constructor TParticleEngine.Create;
|
constructor TParticleEngine.Create;
|
||||||
var i: integer;
|
var i: integer;
|
||||||
begin
|
begin
|
||||||
for i:=1 to 500 do Particle[i]:=TParticle.Create;
|
for i:=1 to 501 do Particle[i]:=TParticle.Create;
|
||||||
|
xspawn:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TParticleEngine.DrawParticles;
|
procedure TParticleEngine.DrawParticles;
|
||||||
@ -370,9 +377,9 @@ var i: integer;
|
|||||||
begin
|
begin
|
||||||
//if blended then glEnable(GL_DEPTH_TEST) else glEnable(GL_BLEND);
|
//if blended then glEnable(GL_DEPTH_TEST) else glEnable(GL_BLEND);
|
||||||
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||||
for i:=1 to 500 do begin
|
for i:=1 to 501 do begin
|
||||||
glTranslatef(Particle[i].x, Particle[i].y, Particle[i].z);
|
glTranslatef(Particle[i].x, Particle[i].y, Particle[i].z);
|
||||||
glCallList(drops);
|
glCallList(ParticleList);
|
||||||
{glBegin(GL_TRIANGLE_STRIP);
|
{glBegin(GL_TRIANGLE_STRIP);
|
||||||
glNormal3f( 0.0, 0.0, 1.0);
|
glNormal3f( 0.0, 0.0, 1.0);
|
||||||
glTexCoord2f( 1.0, 1.0); glVertex3f(Particle[i].x+0.03, Particle[i].y+0.03, Particle[i].z);
|
glTexCoord2f( 1.0, 1.0); glVertex3f(Particle[i].x+0.03, Particle[i].y+0.03, Particle[i].z);
|
||||||
@ -387,24 +394,27 @@ end;
|
|||||||
|
|
||||||
procedure TParticleEngine.RespawnParticle(i: integer);
|
procedure TParticleEngine.RespawnParticle(i: integer);
|
||||||
begin
|
begin
|
||||||
Particle[i].x:=0;
|
{if (xspawn>2) and (direction=true) then direction:=false;
|
||||||
Particle[i].y:=0;
|
if (xspawn<-2) and (direction=false) then direction:=true;
|
||||||
|
if direction then xspawn:=xspawn+0.005 else xspawn:=xspawn-0.005;}
|
||||||
|
Particle[i].x:=xspawn;
|
||||||
|
Particle[i].y:=-0.5;
|
||||||
Particle[i].z:=0;
|
Particle[i].z:=0;
|
||||||
Particle[i].vx:=-0.0025+random(1000)/200000;
|
Particle[i].vx:=-0.005+random(2000)/200000;
|
||||||
Particle[i].vy:=0.02+random(750)/100000;
|
Particle[i].vy:=0.03+random(750)/100000;
|
||||||
Particle[i].vz:=-0.0025+random(1000)/200000;
|
Particle[i].vz:=-0.005+random(2000)/200000;
|
||||||
Particle[i].life:=random(10000)/2500+0.75;
|
Particle[i].life:=random(1250)/1000+1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TParticleEngine.MoveParticles;
|
procedure TParticleEngine.MoveParticles;
|
||||||
var i: integer;
|
var i: integer;
|
||||||
begin
|
begin
|
||||||
for i:=1 to 500 do begin
|
for i:=1 to 501 do begin
|
||||||
if Particle[i].life>0 then begin
|
if Particle[i].life>0 then begin
|
||||||
Particle[i].life:=Particle[i].life-0.01;
|
Particle[i].life:=Particle[i].life-0.01;
|
||||||
Particle[i].x:=Particle[i].x+Particle[i].vx;
|
Particle[i].x:=Particle[i].x+Particle[i].vx;
|
||||||
|
|
||||||
Particle[i].vy:=Particle[i].vy-0.0002; // gravity
|
Particle[i].vy:=Particle[i].vy-0.00035; // gravity
|
||||||
Particle[i].y:=Particle[i].y+Particle[i].vy;
|
Particle[i].y:=Particle[i].y+Particle[i].vy;
|
||||||
|
|
||||||
Particle[i].z:=Particle[i].z+Particle[i].vz;
|
Particle[i].z:=Particle[i].z+Particle[i].vz;
|
||||||
@ -417,7 +427,7 @@ end;
|
|||||||
procedure TParticleEngine.Start;
|
procedure TParticleEngine.Start;
|
||||||
var i: integer;
|
var i: integer;
|
||||||
begin
|
begin
|
||||||
for i:=1 to 500 do begin
|
for i:=1 to 501 do begin
|
||||||
RespawnParticle(i);
|
RespawnParticle(i);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -437,27 +447,23 @@ end;}
|
|||||||
procedure TExampleForm.IdleFunc(Sender: TObject; var Done: Boolean);
|
procedure TExampleForm.IdleFunc(Sender: TObject; var Done: Boolean);
|
||||||
begin
|
begin
|
||||||
GTKGLAreaControl1Paint(Self);
|
GTKGLAreaControl1Paint(Self);
|
||||||
Done:=false; // don't wait, come back as fast as possible
|
Done:=false; // tell lcl to handle messages and return immediatly
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
// Buttons
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
procedure TExampleForm.LightingButton1Click(Sender: TObject);
|
procedure TExampleForm.LightingButton1Click(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if glIsEnabled(GL_LIGHTING)=GL_TRUE then glDisable(GL_LIGHTING) else glEnable(GL_LIGHTING);
|
if lighted then glDisable(GL_LIGHTING) else glEnable(GL_LIGHTING);
|
||||||
|
lighted:=not lighted;
|
||||||
GTKGLAreaControl1Paint(Self);
|
GTKGLAreaControl1Paint(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TExampleForm.BlendButton1Click(Sender: TObject);
|
procedure TExampleForm.BlendButton1Click(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if glIsEnabled(GL_BLEND)=GL_TRUE then begin
|
blended:=not blended;
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
blended:=true;
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
blended:=false;
|
|
||||||
end;
|
|
||||||
GTKGLAreaControl1Paint(Self);
|
GTKGLAreaControl1Paint(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -479,28 +485,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TExampleForm.RotateZButton2Click(Sender: TObject);
|
procedure TExampleForm.RotateZButton2Click(Sender: TObject);
|
||||||
var i: integer;
|
|
||||||
begin
|
begin
|
||||||
for i:=1 to 300 do begin
|
ParticleBlended:=not ParticleBlended;
|
||||||
rz:=rz-0.05;
|
|
||||||
GTKGLAreaControl1Paint(Self);
|
GTKGLAreaControl1Paint(Self);
|
||||||
glFlush;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
procedure TExampleForm.FormResize(Sender: TObject);
|
procedure TExampleForm.FormResize(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
//GTKGLAreaControl1.Width:=AnExampleForm.Width-100;
|
//GTKGLAreaControl1.Width:=Width-100;
|
||||||
//GTKGLAreaControl1.Height:=AnExampleForm.Height-100;
|
//GTKGLAreaControl1.Height:=Height-100;
|
||||||
if GTKGLAreaControl1<>nil then
|
if GTKGLAreaControl1<>nil then
|
||||||
GTKGLAreaControl1.SetBounds(10, 30, Width-120, Height-40);
|
GTKGLAreaControl1.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, 50, 80, 25);
|
LightingButton1.SetBounds(Width-90, 180, 80, 25);
|
||||||
BlendButton1.SetBounds(Width-90, 80, 80, 25);
|
BlendButton1.SetBounds(Width-90, 210, 80, 25);
|
||||||
MoveCubeButton1.SetBounds(Width-90, 115, 80, 25);
|
MoveCubeButton1.SetBounds(Width-90, 50, 80, 25);
|
||||||
MoveBackgroundButton1.SetBounds(Width-90, 145, 80, 25);
|
MoveBackgroundButton1.SetBounds(Width-90, 80, 80, 25);
|
||||||
RotateZButton1.SetBounds(Width-90, 180, 80, 25);
|
RotateZButton1.SetBounds(Width-90, 115, 80, 25);
|
||||||
RotateZButton2.SetBounds(Width-90, 215, 80, 25);
|
RotateZButton2.SetBounds(Width-90, 145, 80, 25);
|
||||||
HintLabel1.SetBounds(10, 0, 80, 25);
|
HintLabel1.SetBounds(10, 0, 80, 25);
|
||||||
//writeln('Form: ',ExitButton1.Width);
|
//writeln('Form: ',ExitButton1.Width);
|
||||||
//writeln('GTKGLarea: ',GTKGLareaControl1.Height);
|
//writeln('GTKGLarea: ',GTKGLareaControl1.Height);
|
||||||
@ -520,9 +526,9 @@ procedure TExampleForm.GTKGLAreaControl1Paint(Sender: TObject);
|
|||||||
//xrotspeed:=0; yrotspeed:=0; zrotspeed:=0;
|
//xrotspeed:=0; yrotspeed:=0; zrotspeed:=0;
|
||||||
{init lighting variables}
|
{init lighting variables}
|
||||||
{ambient color}
|
{ambient color}
|
||||||
lightamb[0]:=0.6;
|
lightamb[0]:=0.5;
|
||||||
lightamb[1]:=0.6;
|
lightamb[1]:=0.5;
|
||||||
lightamb[2]:=0.6;
|
lightamb[2]:=0.5;
|
||||||
lightamb[3]:=1.0;
|
lightamb[3]:=1.0;
|
||||||
{diffuse color}
|
{diffuse color}
|
||||||
lightdif[0]:=0.8;
|
lightdif[0]:=0.8;
|
||||||
@ -588,15 +594,12 @@ begin
|
|||||||
MyglTextures[i]:=TglTexture.Create;
|
MyglTextures[i]:=TglTexture.Create;
|
||||||
end;
|
end;
|
||||||
{loading the texture and setting its parameters}
|
{loading the texture and setting its parameters}
|
||||||
if not LoadglTexImage2DFromBitmapFile('data/texture1.bmp',MyglTextures[0]) then begin
|
if not LoadglTexImage2DFromBitmapFile('data/particle.bmp',MyglTextures[0]) then
|
||||||
Halt;
|
Halt;
|
||||||
end;
|
if not LoadglTexImage2DFromBitmapFile('data/texture2.bmp',MyglTextures[1]) then
|
||||||
if not LoadglTexImage2DFromBitmapFile('data/texture2.bmp',MyglTextures[1]) then begin
|
|
||||||
Halt;
|
Halt;
|
||||||
end;
|
if not LoadglTexImage2DFromBitmapFile('data/texture3.bmp',MyglTextures[2]) then
|
||||||
if not LoadglTexImage2DFromBitmapFile('data/texture3.bmp',MyglTextures[2]) then begin
|
|
||||||
Halt;
|
Halt;
|
||||||
end;
|
|
||||||
glGenTextures(3, textures[0]);
|
glGenTextures(3, textures[0]);
|
||||||
for i:=0 to 2 do begin
|
for i:=0 to 2 do begin
|
||||||
glBindTexture(GL_TEXTURE_2D, Textures[i]);
|
glBindTexture(GL_TEXTURE_2D, Textures[i]);
|
||||||
@ -620,7 +623,8 @@ begin
|
|||||||
glColor4f(1.0,1.0,1.0,0.5); // Full Brightness, 50% Alpha ( NEW )
|
glColor4f(1.0,1.0,1.0,0.5); // Full Brightness, 50% Alpha ( NEW )
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
//glDisable(GL_DEPTH_TEST);
|
//glDisable(GL_DEPTH_TEST);
|
||||||
glLightModelf(GL_LIGHT_MODEL_AMBIENT, 1.0);
|
//glLightModelf(GL_LIGHT_MODEL_AMBIENT, 1.0);
|
||||||
|
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
|
||||||
{fog}
|
{fog}
|
||||||
glFogi(GL_FOG_MODE,GL_LINEAR); // Fog Mode
|
glFogi(GL_FOG_MODE,GL_LINEAR); // Fog Mode
|
||||||
glFogfv(GL_FOG_COLOR,fogColor); // Set Fog Color
|
glFogfv(GL_FOG_COLOR,fogColor); // Set Fog Color
|
||||||
@ -635,9 +639,10 @@ begin
|
|||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
||||||
//glEnable(GL_LIGHTING);
|
//glEnable(GL_LIGHTING);
|
||||||
|
|
||||||
// creating display list for particles
|
// creating display lists
|
||||||
drops:=glGenLists(1);
|
|
||||||
glNewList(drops, GL_COMPILE);
|
ParticleList:=glGenLists(3);
|
||||||
|
glNewList(ParticleList, GL_COMPILE);
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
glNormal3f( 0.0, 0.0, 1.0);
|
glNormal3f( 0.0, 0.0, 1.0);
|
||||||
glTexCoord2f( 1.0, 1.0); glVertex3f(+0.025, +0.025, 0);
|
glTexCoord2f( 1.0, 1.0); glVertex3f(+0.025, +0.025, 0);
|
||||||
@ -647,45 +652,8 @@ begin
|
|||||||
glEnd;
|
glEnd;
|
||||||
glEndList;
|
glEndList;
|
||||||
|
|
||||||
end;
|
BackList:=ParticleList+1;
|
||||||
|
glNewList(BackList, GL_COMPILE);
|
||||||
begin
|
|
||||||
if (gint(True) = gtk_gl_area_make_current(GTKGLAreaControl1.Widget)) then
|
|
||||||
begin
|
|
||||||
if not AreaInitialized then begin
|
|
||||||
myInit;
|
|
||||||
InitGL;
|
|
||||||
glMatrixMode (GL_PROJECTION); { prepare for and then }
|
|
||||||
glLoadIdentity (); { define the projection }
|
|
||||||
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); { transformation }
|
|
||||||
glMatrixMode (GL_MODELVIEW); { back to modelview matrix }
|
|
||||||
glViewport (0, 0, GTKGLAreaControl1.Width, GTKGLAreaControl1.Height); { define the viewport }
|
|
||||||
AreaInitialized:=true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
ParticleEngine.MoveParticles;
|
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
|
|
||||||
glLoadIdentity; { clear the matrix }
|
|
||||||
glTranslatef (0.0, 0.0,-2.5); { viewing transformation }
|
|
||||||
glScalef (1.0, 1.0, 1.0); { modeling transformation }
|
|
||||||
{rotate}
|
|
||||||
|
|
||||||
//yrot:=yrot+yrotspeed;
|
|
||||||
//zrot:=zrot+zrotspeed;
|
|
||||||
|
|
||||||
glPushMatrix;
|
|
||||||
|
|
||||||
if MoveBackground then begin
|
|
||||||
rrx:=rrx-0.5;
|
|
||||||
rry:=rry-0.25;
|
|
||||||
rrz:=rrz-0.4;
|
|
||||||
end;
|
|
||||||
|
|
||||||
glRotatef(rrx,1.0,0.0,0.0);
|
|
||||||
glRotatef(rry,0.0,1.0,0.0);
|
|
||||||
glRotatef(rrz,0.0,0.0,1.0);
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, textures[2]);
|
glBindTexture(GL_TEXTURE_2D, textures[2]);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glNormal3f( 0.0, 0.0, 1.0);
|
glNormal3f( 0.0, 0.0, 1.0);
|
||||||
@ -727,23 +695,10 @@ begin
|
|||||||
glTexCoord2f( 1.0, 0.0); glVertex3f(-2.5,-2.5, 2.5);
|
glTexCoord2f( 1.0, 0.0); glVertex3f(-2.5,-2.5, 2.5);
|
||||||
|
|
||||||
glEnd;
|
glEnd;
|
||||||
|
glEndList;
|
||||||
|
|
||||||
glRotatef(-rrz,0.0,0.0,1.0);
|
CubeList:=BackList+1;
|
||||||
glRotatef(-rry,0.0,1.0,0.0);
|
glNewList(CubeList, GL_COMPILE);
|
||||||
glRotatef(-rrx,1.0,0.0,0.0);
|
|
||||||
|
|
||||||
glPushMatrix;
|
|
||||||
|
|
||||||
if MoveCube then begin
|
|
||||||
rx:=rx+0.5;
|
|
||||||
ry:=ry+0.25;
|
|
||||||
rz:=rz+0.8;
|
|
||||||
end;
|
|
||||||
|
|
||||||
glRotatef(rx,1.0,0.0,0.0);
|
|
||||||
glRotatef(ry,0.0,1.0,0.0);
|
|
||||||
glRotatef(rz,0.0,0.0,1.0);
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, textures[1]);
|
glBindTexture(GL_TEXTURE_2D, textures[1]);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
{Front Face}
|
{Front Face}
|
||||||
@ -790,26 +745,96 @@ begin
|
|||||||
glTexCoord2f( 0.0, 0.0); glVertex3f( 0.5,-0.5, 0.5);
|
glTexCoord2f( 0.0, 0.0); glVertex3f( 0.5,-0.5, 0.5);
|
||||||
glTexCoord2f( 1.0, 0.0); glVertex3f(-0.5,-0.5, 0.5);
|
glTexCoord2f( 1.0, 0.0); glVertex3f(-0.5,-0.5, 0.5);
|
||||||
glEnd;
|
glEnd;
|
||||||
|
glEndList;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if (gint(True) = gtk_gl_area_make_current(GTKGLAreaControl1.Widget)) then
|
||||||
|
begin
|
||||||
|
if not AreaInitialized then begin
|
||||||
|
myInit;
|
||||||
|
InitGL;
|
||||||
|
glMatrixMode (GL_PROJECTION); { prepare for and then }
|
||||||
|
glLoadIdentity (); { define the projection }
|
||||||
|
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); { transformation }
|
||||||
|
glMatrixMode (GL_MODELVIEW); { back to modelview matrix }
|
||||||
|
glViewport (0, 0, GTKGLAreaControl1.Width, GTKGLAreaControl1.Height); { define the viewport }
|
||||||
|
AreaInitialized:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
ParticleEngine.MoveParticles;
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
|
||||||
|
glLoadIdentity; { clear the matrix }
|
||||||
|
glTranslatef (0.0, 0.0,-2.5); // -2.5); { viewing transformation }
|
||||||
|
glScalef (1.0, 1.0, 1.0); { modeling transformation }
|
||||||
|
{rotate}
|
||||||
|
|
||||||
|
//yrot:=yrot+yrotspeed;
|
||||||
|
//zrot:=zrot+zrotspeed;
|
||||||
|
|
||||||
|
glPushMatrix;
|
||||||
|
|
||||||
|
if MoveBackground then begin
|
||||||
|
rrx:=rrx-0.6;
|
||||||
|
rry:=rry-0.5;
|
||||||
|
rrz:=rrz-0.3;
|
||||||
|
end;
|
||||||
|
|
||||||
|
glRotatef(rrx,1.0,0.0,0.0);
|
||||||
|
glRotatef(rry,0.0,1.0,0.0);
|
||||||
|
glRotatef(rrz,0.0,0.0,1.0);
|
||||||
|
|
||||||
|
// draw background
|
||||||
|
if blended then begin
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
end;
|
||||||
|
glCallList(BackList);
|
||||||
|
|
||||||
|
glPopMatrix;
|
||||||
|
|
||||||
|
{glRotatef(-rrz,0.0,0.0,1.0);
|
||||||
|
glRotatef(-rry,0.0,1.0,0.0);
|
||||||
|
glRotatef(-rrx,1.0,0.0,0.0);}
|
||||||
|
|
||||||
|
glPushMatrix;
|
||||||
|
|
||||||
|
if MoveCube then begin
|
||||||
|
rx:=rx+0.5;
|
||||||
|
ry:=ry+0.25;
|
||||||
|
rz:=rz+0.8;
|
||||||
|
end;
|
||||||
|
|
||||||
|
glRotatef(rx,1.0,0.0,0.0);
|
||||||
|
glRotatef(ry,0.0,1.0,0.0);
|
||||||
|
glRotatef(rz,0.0,0.0,1.0);
|
||||||
|
|
||||||
|
// draw cube
|
||||||
|
|
||||||
|
|
||||||
|
glCallList(CubeList);
|
||||||
|
if blended then begin
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
end;
|
||||||
// draw particles here for dynamic particle system
|
// draw particles here for dynamic particle system
|
||||||
|
|
||||||
//ParticleEngine.DrawParticles;
|
//ParticleEngine.DrawParticles;
|
||||||
|
|
||||||
glRotatef(-rz,0.0,0.0,1.0);
|
glPopMatrix;
|
||||||
glRotatef(-ry,0.0,1.0,0.0);
|
|
||||||
glRotatef(-rx,1.0,0.0,0.0);
|
|
||||||
|
|
||||||
glpushMatrix;
|
{glRotatef(-rz,0.0,0.0,1.0);
|
||||||
|
glRotatef(-ry,0.0,1.0,0.0);
|
||||||
|
glRotatef(-rx,1.0,0.0,0.0);}
|
||||||
|
|
||||||
// draw particles here for static particle system
|
// draw particles here for static particle system
|
||||||
|
if ParticleBlended then glEnable(GL_BLEND);
|
||||||
ParticleEngine.DrawParticles;
|
ParticleEngine.DrawParticles;
|
||||||
|
if ParticleBlended then glDisable(GL_BLEND);
|
||||||
glPopMatrix;
|
//glFlush;
|
||||||
glPopMatrix;
|
glFinish;
|
||||||
glPopMatrix;
|
|
||||||
glFlush;
|
|
||||||
|
|
||||||
// Swap backbuffer to front
|
// Swap backbuffer to front
|
||||||
gtk_gl_area_swap_buffers(PGtkGLArea(GTKGLAreaControl1.Widget));
|
gtk_gl_area_swap_buffers(PGtkGLArea(GTKGLAreaControl1.Widget));
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user