Jump to content
  • Advertisement
Sign in to follow this  
briandra3

Changing a ColorKey

This topic is 4592 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

Hi, Is there anyway to change a LPDIRECT3DTEXTURE9's Color Key after the texture has been created? I know you can set the colorkey with the CreateTextureFromFileEx function, but what if you want to change it after the texture's been created? Thanks, Brian

Share this post


Link to post
Share on other sites
Advertisement
Yes and no. Technically, you aren't setting a color key and neither does the texture loading function you used. You will have to lock the texture data and manually set the alpha component to zero for every pixel of the color or colors you want to be transparent.

If the alpha values for the images are important (i.e. the image file and your application makes use of varing values through the image) you may wish to either save an extra copy of the original and un-modified image from which to derive or simply re-load the image file each time the color-key needs to change.

Share this post


Link to post
Share on other sites
Either use a dynamic texture (D3DUSAGE_DYNAMIC flag) or use a managed texture. By managed texture I refer to both managed by DirectX via the D3DPOOL_MANAGED flag or manually using a second system mem texture and copying the data via IDirect3DDevice::UpdateTexture or IDirect3DDevice::UpdateSurface.

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!