Hello!
I tried your example!
And there is my solution (you have to use version undelphi 1.07b):
Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, DXClass, DXDraws, StdCtrls;
type
TForm1 = class(TForm)
dd1: TDXDraw;
DXTimer1: TDXTimer;
doBltFast: TRadioButton;
doDraw: TRadioButton;
procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);
procedure dd1Initialize(Sender: TObject);
procedure PrepareNewSurface;
private
newsurface: TDirectDrawSurface;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
nWidth: Integer = 0;
bGoing: Boolean = true;
procedure TForm1.PrepareNewSurface;
begin
newsurface.Fill( 0 );
newsurface.Canvas.Rectangle( 10, 10, 10 + nWidth, 50 );
if bGoing then
begin
Inc( nWidth, 3 );
if nWidth = newsurface.Width - 10 then
bGoing := not bGoing;
end
else
begin
Dec( nWidth, 3 );
if nWidth <= 10 then
bGoing := not bGoing;
end;
newsurface.Canvas.Release;
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
dd1.surface.fill( 0 );
PrepareNewSurface;
dd1.ClearStack;
if doDraw.Checked then
dd1.Surface.Draw( 0, 0, newsurface )
else
dd1.Surface.BltFast( 0, 0, dd1.surface.ClientRect, 0, newsurface );
dd1.surface.canvas.release;
dd1.Flip;
end;
procedure TForm1.dd1Initialize(Sender: TObject);
begin
newsurface :=TDirectDrawSurface.Create( dd1.DDraw );
newsurface.SetSize( dd1.Width, dd1.height );
end;
end.
Shortly, use simple for clear texture stack.
Regards
Bookmarks