unit Plane1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Material, light, Transfrm, cOpenGL, OpenGL;

type
  TForm1 = class(TForm)
    OpenGL1: TOpenGL;
    Transform1: TTransform;
    Light1: TLight;
    Transform2: TTransform;
    Material1: TMaterial;
    Material2: TMaterial;
    procedure Transform1Paint(Sender: TObject);
    procedure Transform2Paint(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure FormResize(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Transform1Paint(Sender: TObject);
begin
  Light1.Apply;
end;

procedure TForm1.Transform2Paint(Sender: TObject);
begin
  Material1.Apply;
  Material2.Apply;
  glBegin(GL_POLYGON);
    glVertex3f(-0.4,-0.6,+0.0);
    glVertex3f(+0.4,+0.2,+0.0);
    glVertex3f(+0.4,-0.8,-0.0);
    glVertex3f(-0.4,+0.4,-0.0);
  glEnd;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  Transform1.Apply;
  Transform2.Apply;
  glFlush;
  OpenGL1.ErrorCheck('FormPaint');
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  if OpenGL1.Smaller then
    FormPaint(Sender);
end;

end.
 