OK I will see it.
OK I will see it.
Ijcro.
If you'd like I have written a simple example problem reproduction:Originally Posted by ijcro
Code:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXClass, DXDraws, StdCtrls; type TForm1 = class(TForm) dd1: TDXDraw; DXTimer1: TDXTimer; rb1: TRadioButton; RadioButton1: 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; if radiobutton1.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;
If I use Non-hardware acceleration (removing the [do3D] from options), it works but with software.
Thanx!
Hello!
I tried your example!
And there is my solution (you have to use version undelphi 1.07b):
Shortly, use simpleCode: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.for clear texture stack.Code:dd1.ClearStack;
Regards
Ijcro.
First of all, thank you for the solution!
This works for Draw, but for DrawAlpha it does not work :cry:
Please, send me your demo (code) with DrawAlpha or DrawAdd, I see it!
Thanks
Ijcro.
Just change the dd1.surface.Draw to dd1.Surface.DrawAlpha, in the same example, with an alpha of 100 for example.Originally Posted by ijcro
Thanx
OK.
Ijcro.
You can try this construction, but small problem with alpha is here still... :cry: sorry
Code:procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer); begin dd1.surface.fill(dd1.Surface.ColorMatch(clBlack)); dl1.Items.Find('krecci').StretchDraw(dd1.Surface, dd1.Surface.ClientRect, 0); PrepareNewSurface; dd1.ClearStack; if doDraw.Checked then //dd1.Surface.Draw( 0, 0, newsurface ) dd1.Surface.Draw(0, 0, newsurface.ClientRect, newsurface) else if doBlend.Checked then begin if dd1.Surface.Lock then begin dd1.Surface.DrawAlpha(dd1.Surface.ClientRect, newSurface.ClientRect, newsurface, True, 128); dd1.Surface.UnLock; end; end else dd1.Surface.BltFast(0, 0, dd1.surface.ClientRect, 0, newsurface); //dd1.surface.canvas.release; dd1.Flip; end;
Ijcro.
I made little the analyse of problem.
Problem has two parts.
At first it is refresh of image surface.
It is not bug in unDelphiX. The concept no compute with change the picture in DDS, but prefer direct drawing. ClearStack dramatically suspend speed of drawing, I no advice it (so only for special purpose).
And second it is drawing...using DrawAlpha, DrawAdd and etc.
I think that it can be bug. I did track all the calls low level routines to DirectX and all returned with DD_OK flag (I am using last published version 1.07b). But pictures no show! This can be the same bug that picture is drawing on empty Surface. But I don't know best solution.
You can use ...
1/ technique of videotexture like Hori's sample
2/ predefined picture and draw it throught DXImageList (from one picture)
3/ directly drawing via DXDraw.Surface[.Canvas]
4/ own another technique for me unknown
Many clever and handy programmers are here.
Can anybody help us with this problem? For better unDelphiX? Thanks!
Ijcro.
Bookmarks