Jump to content
  • Advertisement
Sign in to follow this  
Erik1234

Make an existing IDirect3DTexture9 texture transparent

This topic is 4421 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a pointe to a IDirect3DTexture9, lets say as: IDirect3DTexture9* pMyTexture; ... but, I would like to make this texture transparent. How would I do this?

Share this post


Link to post
Share on other sites
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!