unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AdDraws, AdClasses, AdTypes, ExtCtrls;
type
TForm1 =
class(TForm)
Panel1: TPanel;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private-Deklarationen }
public
AdDraw:TAdDraw;
AdSurf1, AdSurf2: TAdTextureSurface;
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
AdDraw := TAdDraw.Create(Panel1);
AdDraw.DllName := '
AndorraDX93D.dll';
if AdDraw.Initialize
then
begin
AdSurf1:=TAdTextureSurface.Create(AdDraw);
AdSurf1.SetSize(256,256);
AdSurf2:=TAdTextureSurface.Create(AdDraw);
AdSurf2.SetSize(256,256);
end
else
begin
ShowMessage(AdDraw.GetLastError);
halt;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
AdDraw.Free;
AdSurf1.Free;
AdSurf2.Free;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if AdDraw.CanDraw
then
begin
AdDraw.ClearSurface(clBlack);
AdDraw.BeginScene;
//Die Zeichenfläche an sich auf der sich die Grafik hinter der Maske befindet
if AdSurf1.CanDraw
then begin
AdSurf1.ClearSurface(Ad_ARGB(255,255,255,255));
with AdSurf1.Canvas
do begin
Pen.Color:=Ad_ARGB(255,0,0,255);
Brush.Color:=Ad_ARGB(255,0,0,255);
Ellipse(10,10,30,30);
Circle (70,70,50);
Release;
end;
end;
// Das ist meine "Lochmaske" die vor dem Bild steht
if AdSurf2.CanDraw
then begin
AdSurf2.ClearSurface(Ad_ARGB(0,255,255,255));
with AdSurf2.Canvas
do begin
Pen.Color:=Ad_ARGB(255,0,0,0);
Brush.Color:=Ad_ARGB(255,0,0,0);
Rectangle(20,20,60,60);
Rectangle(60,65,65,195);
Release;
end;
end;
//Enable stencil buffer and alpha masking
AdDraw.Options := AdDraw.Options + [aoStencilBuffer, aoAlphaMask];
//Increment the stencil buffer value for a pixel, if a pixel is set there
AdDraw.AdAppl.SetStencilOptions(0, $FFFF, asfAlways);
AdDraw.AdAppl.SetStencilEvent(asePass, asoIncrement);
AdSurf2.Image.Draw(AdDraw,0,0,0);
//Only draw a pixel, if the stencil value is larger than zero
AdDraw.AdAppl.SetStencilOptions(0, $FFFF, asfLessThan);
AdDraw.AdAppl.SetStencilEvent(asePass, asoKeep);
AdDraw.Options := AdDraw.Options - [aoAlphaMask];
AdSurf1.Image.DrawEx(AdDraw, AdRect(0, 0, 256, 256), AdRect(0, 0, 256, 256), 0, 0, 0, 255, bmAlpha);
AdDraw.Options := AdDraw.Options - [aoStencilBuffer];
AdDraw.EndScene;
AdDraw.Flip;
end;
end;
end.