Alpha Blending in DirectX 7

Started by
6 comments, last by DrunkenHyena 18 years, 6 months ago
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.
Advertisement
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.
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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.

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.
JRA GameDev Website//Bad Maniac
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]
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

You can get VC++ 2005 Express for free:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=126606&SiteID=1
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement