Witajcie.
Mam problem z scrollem tekstu w poziomie. Robie to wykorzystujac komponenty Andorra 2D i dolaczona biblioteke DirectX3D. Dlaczego w taki sposob, bo to jest jedyny dzieki ktoremu napis scroluje sie plynnie, ale jest pewno ale i z nim mam problem.
program testuje na sprzecie o parametrach: procek dwu rdzeniowy AMD 2.2GHz, Ram 2GB, Grafika ATI Radeon HD3200 z przydzielona pamiecia 320MB, system Winda XP.
Sprawa wyglada tak. Przy kodzie ponizej pasek scroluje sie plynnie ale mam 57% obciazenie procka.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AdDraws, AdClasses, AdTypes, AdStandardFontGenerator, AdFont,
AdCanvas, AdPerformanceCounter, AdFontFactory, AdMath, ExtCtrls, Buttons,
StdCtrls;
type
TForm1 = class(TForm)
Panel2: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
public
AdDraw1:TAdDraw;
Napis1:TAdFont;
AdPerCounter:TAdPerformanceCounter;
procedure Idle(Sender:TObject;var Done:boolean);
end;
var
Form1: TForm1;
c:double;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Top:=0;
Form1.Left:=0;
Form1.Width:=1680;
Form1.Height:=130;
Panel2.Left:=0;
Panel2.Top:=0;
Panel2.Width:=1680;
Panel2.Height:=73;
c:=0;
AdDraw1 := TAdDraw.Create(Panel2);
AdDraw1.DllName := 'D:\Test\AndorraDX93D.dll';
AdPerCounter := TAdPerformanceCounter.Create;
AdPerCounter.Interpolate:=true;
if AdDraw1.Initialize then
begin
Application.OnIdle := Idle;
AdDraw1.Scene.Setup3DScene(
Panel2.Width, Panel2.Height, AdVector3(0, 95, -110),
AdVector3(0, 95, 0), AdVector3(0,1,0));
end else
begin
halt;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
AdImageList.Free;
AdDraw1.Free;
end;
procedure TForm1.Idle(Sender: TObject; var Done: boolean);
var mat1:TAdMatrix;
begin
if AdDraw1.CanDraw then
begin
AdPerCounter.Calculate;
AdDraw1.ClearSurface(clBlack);
AdDraw1.BeginScene;
c := c + AdPerCounter.TimeGap*0.3;
mat1 := AdMatrix_Translate(1050-c, 50, 0);
Napis1:=AdDraw1.Fonts.GenerateFont('Arial', 60, [afBold]);
Napis1.Color:= Ad_ARGB(255,255,255,255);
Napis1.TransformationMatrix:= mat1;
Napis1.TextOut(0,0,'ALA MA KOCURA OŁ JE JE JE I TAK BLA BLA BLA ');
AdDraw1.EndScene;
AdDraw1.Flip;
end;
Done := false;
end;
end.
Jak troszke zmienie kod tzn. linie generowania tekstu dam po ustawieniu sceny czyli kod bedzie wygladal tak
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AdDraws, AdClasses, AdTypes, AdStandardFontGenerator, AdFont,
AdCanvas, AdPerformanceCounter, AdFontFactory, AdMath, ExtCtrls, Buttons,
StdCtrls;
type
TForm1 = class(TForm)
Panel2: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
public
AdDraw1:TAdDraw;
Napis1:TAdFont;
AdPerCounter:TAdPerformanceCounter;
procedure Idle(Sender:TObject;var Done:boolean);
end;
var
Form1: TForm1;
c:double;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Top:=0;
Form1.Left:=0;
Form1.Width:=1680;
Form1.Height:=130;
Panel2.Left:=0;
Panel2.Top:=0;
Panel2.Width:=1680;
Panel2.Height:=73;
c:=0;
AdDraw1 := TAdDraw.Create(Panel2);
AdDraw1.DllName := 'D:\Test\AndorraDX93D.dll';
AdPerCounter := TAdPerformanceCounter.Create;
AdPerCounter.Interpolate:=true;
if AdDraw1.Initialize then
begin
Application.OnIdle := Idle;
AdDraw1.Scene.Setup3DScene(
Panel2.Width, Panel2.Height, AdVector3(0, 95, -110),
AdVector3(0, 95, 0), AdVector3(0,1,0));
Napis1:=AdDraw1.Fonts.GenerateFont('Arial', 60, [afBold]); //te linie zostaly przeniesione
Napis1.Color:= Ad_ARGB(255,255,255,255); //
end else
begin
halt;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
AdImageList.Free;
AdDraw1.Free;
end;
procedure TForm1.Idle(Sender: TObject; var Done: boolean);
var mat1:TAdMatrix;
begin
if AdDraw1.CanDraw then
begin
AdPerCounter.Calculate;
AdDraw1.ClearSurface(clBlack);
AdDraw1.BeginScene;
c := c + AdPerCounter.TimeGap*0.3;
mat1 := AdMatrix_Translate(1050-c, 50, 0);
Napis1.TransformationMatrix:= mat1;
Napis1.TextOut(0,0,'ALA MA KOCURA OŁ JE JE JE I TAK BLA BLA BLA ');
AdDraw1.EndScene;
AdDraw1.Flip;
end;
Done := false;
end;
end.
to odciazenie procka mam na poziomie 0% ale tekst scroluje sie z skokami.
Wiec co jest nie tak i jak to powinno wygladac wlasciwie.
Dodam ze dlatego wykorzystalem scene 3D bo musze miec ten tekst do gory nogami a nie wiedzialem jak to zrobic przy scenie 2D
Pozdrawiam.
PS.
Sprawdzilem to jeszcze raz i kurcze nie wiem dlaczego ale ten drugi sposob teraz tez obciaza procka w 50%, wczesniej tak nie bylo.
Juz nie mam do tego sily.