PDA

View Full Version : Something wrong....



Furmiga
01-04-2004, 05:45 PM
Hi guys im new here and im new on Delphi Gamming dev. Im using UnDelphix to make a test and im getting some weird things: here ya go

My pc : ath 1.7 , GF4 64 8x , 512 DDR
Plataform : Win XP pro / Delphi 7




procedure TForm1.telaInitializeSurface(Sender: TObject);
begin
tela.Surface.Canvas.Font.Color := clWhite;
tela.Surface.Canvas.Font.Name := 'Zurich XCn BT';
tela.Surface.Canvas.Font.Size := 12;
end;

procedure TForm1.login;
var
borda : TRect;
begin
borda.Top := 200;
borda.Bottom := 280;
borda.Left := 250;
borda.Right:= 450;
tela.Surface.FillRectAlpha(borda,clRed,50);
tela.Surface.Canvas.Brush.Style := bsClear;
tela.Surface.Canvas.Textout( borda.Top + 60, borda.Left - 45,'Login');
tela.Surface.Canvas.Textout( borda.Top + 60, borda.Left - 25,'Pass');
if showfps then
tela.Surface.Canvas.Textout( 0, 0,'FPS: '+inttoSTR(timer1.FrameRate));
tela.Surface.Canvas.Brush.Color := clWhite;
tela.Surface.Canvas.FrameRect(borda);
tela.Surface.Canvas.Release;
end;

procedure TForm1.seila;
var
i : integer;
mp : TPoint;
begin
i := tela.Display.Width-10-imagens.Items[fps].PatternWidth;
GetCursorPos(mp);
if pointinrect(mp,bounds(i,10,imagens.Items[fps].Patt ernWidth,imagens.Items[fps].PatternHeight)) then
begin
imagens.Items[fps].Draw(tela.surface,i,10,1);
if mouseB then
begin
mouseB := false;
if showfps then
showfps := false
else
showfps := true;
exit;
end;
end
else
imagens.Items[fps].Draw(tela.surface,i,10,0);
end;

procedure TForm1.timer1Timer(Sender: TObject; LagCount: Integer);
begin
tela.Surface.Fill(0);
imagens.Items[LoginScreen].Draw(tela.surface,0,0,0 );
if situacao = 'login' then
login;
seila;
tela.Flip;
end;



when i run the test all fine with 60 fps ( monitor )
The problem is when i use the FillRectAlpha it drops to 51 fps on my pc and 30 on my Bro's ( and he got a better one lol ).
I was thinking in create some windows ( using alpha ) but with if i use like 4 times the FillRectAlpha my FPS drops to 14 lol

btw im calling situacao := 'login' on create.

Please take a look on my code and tell me what im doing wrong or if there is another way to make those windows.

ty in advance

Harry Hunt
01-04-2004, 06:32 PM
I just glanced at your code so maybe you are doing something wrong which I didn't see, but here's the problem with DelphiX and alpha blending:
DelphiX' alpha blending is based on DirectDraw which doesn't support hardware accelerated alpha blending. So what DelphiX does it blends the pixels by manipulating the color value of each pixel that is affected by the alpha-blend and does all this in software.
DelphiX's alpha blending is relatively fast but nonetheless it's always going to be extremely slow compared to hardware accelerated alpha blending.
So, here's what you can do:

1. If your backgrounds are not moving, you can pre-alpha blend the foreground and background on startup and store it in an off-screen buffer. That way you'll only have to do the alpha blending once.

2. You can use hardware acceleration by using DelphiX' 3D functions for 2D drawing (should be possible) or

3. You can use a different set of DirectX wrapper classes with built-in support for hardware accelerated alpha blending. e.g. PowerDraw, Omega, GameVision SDK or *cough* xcess (see my signature).

4. Maybe somebody else can tell you how to speed up things :P

Furmiga
01-04-2004, 06:42 PM
Ty man i ll take a look around and see whats best to me. I guess *cough* xcess can be good idea :)