end;
procedure TForm1. Button3Click (Sender: TObject);
begin
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
end;
procedure TForm1. Button4Click (Sender: TObject);
begin
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
end;
procedure TForm1. Button5Click (Sender: TObject);
begin
Human. Rotation.zx:=Human. Rotation.zx+0.2;
end;
procedure TForm1. Button6Click (Sender: TObject);
begin
Human. Rotation.zx:=Human. Rotation.zx-0.2;
end;
procedure TForm1. FormCreate (Sender: TObject);
begin
vis:=0;
initmas;
DC:=GetDC(Handle);
SetDCPixelFormat;
HRC:=wglCreateContext(DC);
wglMakeCurrent (DC, HRC);
glViewport (0, 0, ClientWidth-Panel1. Width, ClientHeight);
glClearColor (0,0,0,0);
glEnable (GL_DEPTH_TEST);
glMatrixMode (GL_PROJECTION);
glLoadIdentity;
gluPerspective (30.0, ClientWidth / ClientHeight, 0.1, 1000.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity;
glEnable (GL_TEXTURE_2D); // Enable Texture Mapping
LoadTexture ('texture.bmp', MyTextureTex, FALSE);
with Human do
begin
with Position do
begin
x:=6.4;
y:=0;
z:=-0.3878;
end;
with Rotation do
begin
y:=91;
zx:=10;
end;
end;
end;
procedure TForm1. FormDestroy (Sender: TObject);
begin
wglMakeCurrent (0,0);
wglDeleteContext(HRC);
ReleaseDC (Handle, DC);
DeleteDC(DC);
end;
procedure TForm1. Timer1Timer (Sender: TObject);
begin
InvalidateRect (Handle, nil, false);
end;
procedure TForm1. TrackBar1Change (Sender: TObject);
begin
Label2. Caption:=floattostr (TrackBar1. Position);
vis:=TrackBar1. Position;
end;
procedure TForm1. FormResize (Sender: TObject);
begin
glViewport (0, 0, ClientWidth-Panel1. Width, ClientHeight);
glMatrixMode (GL_PROJECTION);
glLoadIdentity;
gluPerspective (30.0, ClientWidth / ClientHeight, 0.1, 1000.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity;
end;
procedure TForm1. FormPaint (Sender: TObject);
var
ps:TPaintStruct;
Const
LPos: Array [0..3] of GLFloat = (3.0, 10, -100.0, 1.0);
begin
BeginPaint (Handle, ps);
glClear (GL_COLOR_BUFFER_BIT or
GL_DEPTH_BUFFER_BIT);
glLoadIdentity;
glRotatef (Human. Rotation.zx, Abs (cos(DegToRad (Human. Rotation.y))), 0,0);
glRotatef (Human. Rotation.y, 0,1,0);
glTranslatef (Human. Position.x,
Human. Position.y,
Human. Position.z);
Draw;
EndPaint (Handle, ps);
SwapBuffers(DC);
end;
procedure TForm1. FormMouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
changemas;
end;
procedure TForm1. FormMouseMove (Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
GetCoordinate (x, y);
end;
end.