procedure TForm1.Render(Sender: TObject;
var Done: Boolean);
var
Geschwindigkeit: Single;
i: Integer;
begin
glClear(GL_COLOR_BUFFER_BIT);
Geschwindigkeit := 0.65;
glEnable(GL_TEXTURE_2D);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1);
glEnable(GL_CULL_FACE);
glCullFace(GL_GREEN);
For i := 1
to FrameObjekte
do
begin
glBindTexture(GL_TEXTURE_2D, Frame[i].SavedFrame[Round(CurrentFrame[i])]);
CurrentFrame[i] := CurrentFrame[i] + Geschwindigkeit;
If CurrentFrame[i] > NumFrames[i]-1
then CurrentFrame[i] := 0;
glBegin(GL_QUADS);
glTexCoord2f(Frame[i].ALeft,Frame[i].ABot); glVertex2f(Frame[i].ALeft,Frame[i].ABot);
glTexCoord2f(Frame[i].ARight,Frame[i].ABot); glVertex2f(Frame[i].ARight,Frame[i].ABot);
glTexCoord2f(Frame[i].ARight,Frame[i].ATop); glVertex2f(Frame[i].ARight,Frame[i].ATop);
glTexCoord2f(Frame[i].ALeft,Frame[i].ATop); glVertex2f(Frame[i].ALeft,Frame[i].ATop);
glEnd;
end;
SwapBuffers(
DC);
Done := False;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
i1, i2: Integer;
TexNummer:
String;
begin
// OpenGL Inialitisieren
DC := GetDC(
Handle);
If not InitOpenGL
then Halt;
RC := CreateRenderingContext(
DC, [opDoubleBuffered], 32, 24, 0, 0, 0, 0);
ActivateRenderingContext(
DC, RC);
// Frames laden
For i1 := 1
to FrameObjekte
do
begin
CurrentFrame[i1] := 0;
SetLength(Frame[i1].SavedFrame, NumFrames[i1]);
For i2 := 0
to NumFrames[i1]-1
do
begin
TexNummer := IntToStr(i2);
If i2 < 10
then
TexNummer := '
0'+Texnummer;
LoadTexture(FramePfad[i1]+TexNummer+'
.tga', Frame[i1].SavedFrame[i2], False)
end;
end;
// Positions angaben für Objekt 1
Frame[1].ALeft := 0;
Frame[1].ABot := 0;
Frame[1].ATop := 1;
Frame[1].ARight := 1;
// Positions angaben für Objekt 2
Frame[2].ALeft := 0;
Frame[2].ABot := -1;
Frame[2].ATop := 0;
Frame[2].ARight := 1;
// Resize erlauben und Formgröße auf Fullscreen bringen
AppCanResize := True;
WindowState := wsMaximized;
Timer1.Enabled := False;
Timer2.Enabled := True;
end;
procedure TForm1.FormCanResize(Sender: TObject;
var NewWidth,
NewHeight: Integer;
var Resize: Boolean);
begin
Resize := AppCanResize;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
var
TempBool: Boolean;
begin
Application.OnIdle := Render;
TempBool := False;
Render(Self, TempBool);
Timer2.Enabled := False;
end;