unit Unit1;
interface
uses
Windows,Forms,dglOpenGL, ExtCtrls, Classes;
type
TForm1 =
class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Render;
procedure Timer1Timer(Sender: TObject);
end;
var
Form1: TForm1;
DC : HDC;
//Handle auf Zeichenfläche
RC : HGLRC;
//Rendering Context
test: extended;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
// Erstellen
DC:= GetDC(
Handle);
RC:= CreateRenderingContext(
DC,[opDoubleBuffered],32,24,0,0,0,0);
ActivateRenderingContext(
DC, RC);
glClearColor(0.3, 0.4, 0.7, 0.0);
// Hintegrund
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
// Vernichten
DeactivateRenderingContext;
DestroyRenderingContext(RC);
ReleaseDC(
Handle,
DC);
end;
// Render = Zeichnen
procedure TForm1.Render;
begin
glClear(GL_COLOR_BUFFER_BIT
or GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
gluPerspective(100, ClientWidth/ClientHeight, 1, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
glTranslatef(0, 0, -10);
glRotatef(test,0,1,0);
glBegin(GL_QUADS);
glColor3f(0, 0, 0); glVertex3f(-5, -9, 1);
glColor3f(0, 0, 1); glVertex3f(9, -9, 1);
glColor3f(0, 0, 1); glVertex3f(9, 6, 1);
glColor3f(0, 0, 1); glVertex3f(-5, 6, 1);
glEnd;
SwapBuffers(
DC);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Render;
test:=test+4;
end;
end.