Jump to content
  • Advertisement
Sign in to follow this  
Telamon

Easy Color Keying in D3D

This topic is 4776 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'm writting a tile-based game using D3D in C#. I've got a single layer tilemap displaying and it works great. Now I'm trying to display tiles with transparent sections on top of the single layer. If I were using DirectDraw, I would just specify black as the color key and any black in the original image wouldn't be drawn. Is there a magical combination of source and destination render ops that I can set in D3D that will make the color black in the source texture transparent when rendered? I know I can always get this to work by adding alpha channels in all my imagery, either with a paint program or at runtime. But I'm looking for something quick and easy. Regards

Share this post


Link to post
Share on other sites
Advertisement
Look at the D3DXCreateTextureFromFileEx() function - it has a ColorKey parameter that does exactly what you want. Remember, to make a D3DCOLOR, you can use the D3DCOLOR_ARGB() macro (there are others that are similar, as well).

Share this post


Link to post
Share on other sites
You could also use the Bitmap class's MakeTransparent() function which will create an appropriate alpha channel for the colour you specify.

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!