Link to home
Start Free TrialLog in
Avatar of pkmnfrk
pkmnfrk

asked on

Alpha Blending

Hi,

I am writing a 2D RPG engine in VB with DirectDraw 7. I was wondering if there is any easy way to do Alpha Blending with certain tiles.

I have a custom format for my tiles, which is simply a bunch of Long's (ABGR) describing the 32x32 tile.

I would like to know how to do the alpha stuff, since DD7 doesn't support it.
Avatar of joachimc
joachimc

I am not using DD7 any more but I am sure that alpha is supported in it. Isn't there the example with a background pic and something flying in circles on it. That is alpha blended I think
Avatar of pkmnfrk

ASKER

No. It says in the SDK quite clearly that "the alpha channel will be ignored" and "alpha blending is not supported in this version".
But why are you using DirectDraw? It can't do anything you cannot do with Direct3D [or DirectXGraphics as it is known in DX8+], and the simplicity comes at a price, namely that DirectDraw isn't that well supported in modern graphics drivers anymore. The functionality is there, sure, but the performance just isn't since modern cards are more and more tweaked towards handling 3D data.

I would very much suggest saying good bye to the soon-to-be-forgotten DirectDraw interfaces and use Direct3D instead. You will have to learn about new concepts, but that's a Good Thing (tm) anyway.

.f
SOLUTION
Avatar of tinkledoomhammer
tinkledoomhammer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One more thing:
If you don't need a lot of different shades of transparency (no fade-ins or -outs) then a binary shift would speed it up a little.
Avatar of pkmnfrk

ASKER

Hmm, I'll try your suggestion and see what I can do. I never really thought about approaching it from that angle. I'll try it before I award the points, though.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When you say D3D can do everything DD can do and much more, which I truly believe, could i make a 2D sprite engine with it? And would I be able to use rotation, scaling, alphablending, etc, all in it? And how much would I need to know about maths?
Avatar of pkmnfrk

ASKER

I've tried D3D and for some reason, I can't get it to work. (I'm probably not setting the geometry correctly)

Anyway, I found an easy solution for my project: scrap the alpha for now. I'll do it later, after I have SOMETHING ready for the public. <sigh>
If there is no way to create fast alpha blending in DirectDraw, so why some games, for example Jazz Jackrabbit 2, have it? And why this game runs on Pentium 90 ???!!!  :P
BAGR:

* I never claimed there wasn't a way to do fast alpha blending -- SIMD instruction sets are damn fast
* While there may not be alphablending, there certainly is colorkeying-support in DirectDraw -- that's what sprites in general use
* Jazz Jackrabbit 2 is old -- back in those days Direct3D was a _lot_ more computationally expensive

Anything else you have to add?

.f
I've now converted to D3D, and I can safely say that as long as you use LPD3DXSPRITEs, its great. Alpha blending is really easy too, you just set the Alpha channel when calling Draw function.
pkmnfrk:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
Question was fully answered, both in a software- as well as hardware-approach. I suggest splitting points between tinkledoomhammer and me [fl0yd].

.f