Sign in to follow this  
Erik1234

Make an existing IDirect3DTexture9 texture transparent

Recommended Posts

There is no one single way to make a texture transparent. It requires some knowledge of what the state of Direct3D is. E.g. what blending mode is being used? How about alpha testing? To what degree do you want it transparent? Completely? Partially? A mixture of the two?

Share this post


Link to post
Share on other sites
ah, maybe I understand the question differently than mastaba, so i'll try another bullet:

You'd have to lock the texture's primary surface (assuming it's lockable, so if it is a SYSTEM texture - like a render target - forget it) Then you'd loop inot each pixel and modify their color value like (assumong ARGB)

oldColor = (oldColor & 0x00FFFFFF) | (alpha << 24); // alpha being a byte

The fact is, dont even think of doing thatonce per frame (unless you want a slide show but in such a case use MS powerpoint ;-)

Cheers, I hope that helped a bit
Janta

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
well, once I make the texture transparent in a frame, I will not make it transparent again. How do I get the primary surface?, do you mean LockRect(...)?

Share this post


Link to post
Share on other sites
The solution I proposed will work if you have one texture and want to change its opacity once and for all (or say, once in a while) and use that texture as such.

If you use alpha = 128, your texture will be half transparent for example.
Also, all the texture's pixel dont have to have the same alph, so you can play with differences...

And yup, I did meant LockRect(0, &lockedRect, NULL, 0); for example. Google for some example of how to youse, that wiped out of my mind sorry :)

Good luck.

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