Sign in to follow this  
LeChuckIsBack

Alpha Blending in DirectX 7

Recommended Posts

Hello there. I searched for this on the Internet, but found nothing (except DX9 stuff)... Let's say I need to fade in a textured triangle from completely transparent (not visible) to completely opaque (i wanna use this, for example, to popup some in-game menues). I think this is quite easy using Directx 9, but how can I do it using DirectX 7? (programming in DirectX 9 requires some special tools like Visual C++ 2003 .NET which I don't have, so I have to stick to DX7 for a while...) I've only managed to make object transparent (or better said translucent) and I don't wanna mess with the texture alpha - too complicated and I'm only using 16 bit display and textures anyway (just 1 bit of alpha). Can I use the alpha stored in the vertex or material colors to achieve transparency like in DX 9? There must be a solution since "they" included an ALPHA member in that material structure, for example. I think that would be perfect! Thanks.

Share this post


Link to post
Share on other sites
EmperiorRune    138
I don't know exactly, but if you can get a pointer to the texture data. And it's in a easy format to use, like R8G8B8_A8, you can write a for loop that goes through each byte of the alpha, and increment/decrement it. I've done this in SDL before. The larger the texture is, the longer it takes. There is probably some sorta tween effect I'm not aware of that does the same thing. Either way.. still something interesting to look into.

Share this post


Link to post
Share on other sites
jollyjeffers    1570
I wouldn't go for the texture-modifying route. That'll kill performance [smile]

Anyway, I dug up my old notes on D3D7-IM in VB6 (should be about the same) and the syntax looks pretty much identical to D3D8 and D3D9...

Set the texture stage to modulate alpha, enable alpha blending and then set the necessary source/destination blend factors.

The material's alpha will only come into effect if you're using fixed-function lighting.

hth
Jack

Share this post


Link to post
Share on other sites
don    431
Just to add to what Jack said, I'd probably modulate with an alpha set via D3DRS_TEXTUREFACTOR. That way you won't have to touch the vertex diffuse alpha or mess around with touching the texture map's pixels as you change the opacity per frame.

Share this post


Link to post
Share on other sites
Bad Maniac    252
Quote:
Original post by LeChuckIsBack (programming in DirectX 9 requires some special tools like Visual C++ 2003 .NET which I don't have, so I have to stick to DX7 for a while...)
I've worked with dx 9 in both visual studio 6.0 and DevCpp, you don't need any special tools to my knowledge.

Share this post


Link to post
Share on other sites
Quote:
Set the texture stage to modulate alpha, enable alpha blending and then set the necessary source/destination blend factors.

Hey Jack, can you please give me some small example?

Quote:
The material's alpha will only come into effect if you're using fixed-function lighting.

I don't know much about this fixed function lighting stuff. Could you tell me more?

[Edited by - LeChuckIsBack on November 14, 2005 12:31:56 AM]

Share this post


Link to post
Share on other sites
Mantrid    188
Quote:

I think this is quite easy using Directx 9, but how can I do it using DirectX 7? (programming in DirectX 9 requires some special tools like Visual C++ 2003 .NET which I don't have, so I have to stick to DX7 for a while...)


i'm a student so i got visual studio.net for free using the microsoft's "academic alliance". they give you a license (which i got through my uni) and a link to download it from their site

which in my opinion is pretty damn nice of the old chaps

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this