Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Slow alpha blending with DelphiX

  1. #1
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Slow alpha blending with DelphiX

    Hi all,

    Quick question... I'm working on my first attempt at a real game engine. One of the things I want to do is to provide a field of visibility that blends out items that appear higher than the player layer as they move closer.

    I've created an array that has alpha values 255, 170, 85 down to 0 in the area around the player.

    If I don't use alpha blending and instead I simply don't draw the 9 around and above the character, it doesn't slow down. As soon as I start using the drawAlpha function of TDXImageList.items, my frame rate drops to 11. Normally I time it down to 25fps from around 66-72fps (we don't need lots of speed since its supposed to have a retro feel).

    Although this isn't a necessary, it does look nice, so Is there any other way of achieving this type of blending, without the slow down? Am I simply using the wrong software configuration options (Surface is 640x480x24)?

    Just in case the rest of how it works is relevant... it goes something like this...

    [pascal]
    dxd.surface.fill(0);

    yLoop
    xLoop
    Calculate map pos from player pos and xLoop,yLoop

    Draw map tile using TDXImageList.items.draw(dxd.surface,xCoord,yCoord, 0);

    Obtain alpha value from alpha map

    Draw overlapping tile using TDXImageList.items.drawAlpha(dxd.surface,xCoord,yC oord,0,alpha);

    End xLoop
    End yLoop

    // Draw player sprite

    // Movement processing

    // Draw console command results/debugging text/console

    dxd.flip

    [/pascal]
    :: AthenaOfDelphi :: My Blog :: My Software ::

  2. #2

    Slow alpha blending with DelphiX

    Depending on what version you're using this may be fast or slow, there is now a hardware accelerated version of DelphiX known as "unDelphiX". You might want to check it out, if it's not what you're using. There is a semi-new version of it at the homepage I linked to. (As of November last year, bottom item)

    Well, one way to smoothly vary the alpha is just a simple percentage calculation. Just round the result of 255*Percent and you'll have it without the array.

  3. #3

    Slow alpha blending with DelphiX

    Try searching around the forum, this problem was brought up many times before

  4. #4
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Slow alpha blending with DelphiX

    Basically what Robert said.

    The guy who made the updates to the continuation of the DirectX project called UnDelphiX is a guy named Jaro. He added hardware acceleration to the existing UnDelphi code(code that was already updated from theDelphiX version and made to work with Delphi 7, optimized, etc --it's just better! )

    If you are looking for the semi-official site for UnDelphiX, go to Turbo and look for the UnDelphiX link. That's [size=9px](what I think)[/size] the best place to go for the latest packaged copy of it.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  5. #5
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Slow alpha blending with DelphiX

    Hi Robert,

    I've just downloaded the unDelphiX demo program... the difference is amazing. Its funny, because I looked at unDelphiX before DelphiX, but decided not to download it for some reason.

    Calculating the alpha value itself is the easy part. I opted to use the array method to save clock cycles for more important stuff. It was just the alpha blend functions that were slowing things down, so hopefully unDelphiX will fix that.

    * WOW * - I just installed unDelphiX... what else can I say... DelphiX to unDelphiX and hardware acceleration on... 11fps to around 70fps.

    Thanks :-D
    :: AthenaOfDelphi :: My Blog :: My Software ::

  6. #6

    Slow alpha blending with DelphiX

    No problem. I might not be a great programmer myself, but I read around.

    Planning on supporting weaker PCs or effects that use a lot of clock cycles?

  7. #7
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Slow alpha blending with DelphiX

    Quote Originally Posted by Robert Kosek
    Planning on supporting weaker PCs or effects that use a lot of clock cycles?
    What are you saying about my PC

    Basically, I'm trying to leave as many clock cycles free as possible so I can use scripting to provide the game logic rather than hard coding stuff, but obviously flexibility has its price and that price is clock cycles. That and the fact my PC is an Athlon 800 with a 32MB GeForce 2 GTS... it needs all the help it can get :-D

    Many thanks guys.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  8. #8

    Slow alpha blending with DelphiX

    Perhaps my advice would be obvious for You, but have You tried to
    turn of the doWaitVBlank option in DXDraw?
    And another thing, You may be interested in this topic:
    http://www.pascalgamedevelopment.com...er=asc&start=0

    and this link http://www.micrel.cz/Dx/ for further DelphiX speed up

    Regards,
    Wodzu

    Edited:

    I didn't know that Jaro=ijcro so You probably visited those links

  9. #9

    Slow alpha blending with DelphiX

    Also check out this thread.
    http://www.pascalgamedevelopment.com...pic.php?t=2560

    It talks about using multiple surfaces to speed up drawing in DelphiX. (should still work for unDelphiX)

    I know FPS isn't your main worry, but just something to keep in mind.

  10. #10

    Slow alpha blending with DelphiX

    What are you saying about my PC
    Well... twasn't meant in reference to your PC, but, ok? [size=7px]Don't tell, but my last PC was a pI 233mhz, with 32mb geforce 4(I think) PCI... Delphi 6 took ~8 minutes to boot.[/size]

    So you're planning on a highly intelligent game, then? Good. I hope it's something akin to an RTS ... I've not had fun with one since AOK! Going for glitz lately. :roll: If not, bah, sounds neat anyway.

    Guys, it's kinda hard to squeeze more FPS out of a system that old, she's doing a fabulous job as is.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •