// Quad zeichnen
procedure DrawObject(X, Y, aType: Integer; Moving: Boolean);
begin
If not Moving
then BlockBool(X, Y, aType);
glRotatef(90, 0, 0, 1);
// Test-Drehung
glBindTexture(GL_TEXTURE_2D, Blocks[aType]);
glBegin(GL_QUADS);
glTexCoord2f(0+(1/(TexSize[aType].X*24+2)), 0+(1/(TexSize[aType].Y*24+2))); glVertex2f(X, Y);
glTexCoord2f(1-(1/(TexSize[aType].X*24+2)), 0+(1/(TexSize[aType].Y*24+2))); glVertex2f(X+BlockSize*TexSize[aType].X, Y);
glTexCoord2f(1-(1/(TexSize[aType].X*24+2)), 1-(1/(TexSize[aType].Y*24+2))); glVertex2f(X+BlockSize*TexSize[aType].X, Y+BlockSize*TexSize[aType].Y);
glTexCoord2f(0+(1/(TexSize[aType].X*24+2)), 1-(1/(TexSize[aType].Y*24+2))); glVertex2f(X, Y+BlockSize*TexSize[aType].Y);
glEnd;
glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
end;
// Render Code [ist im OnIdle der App]
procedure TMainForm.Render(Sender: TObject;
var Done: Boolean);
var
i, i1, i2: Integer;
begin
Done := False;
glClear(GL_COLOR_BUFFER_BIT
or GL_DEPTH_BUFFER_BIT);
For i1 := 0
to FieldSize
do
For i2 := 0
to FieldSize
do
BlockLines[i1][i2] := False;
If High(Objects)-1 > Low(Objects)
then
For i := Low(Objects)+1
to High(Objects)-1
do
DrawObject(Objects[i].X, Objects[i].Y, Objects[i].aType, False);
If High(Objects) > Low(Objects)
then
DrawObject(Objects[High(Objects)].X, Objects[High(Objects)].Y, Objects[High(Objects)].aType, True);
SwapBuffers(
DC);
end;