Sign in to follow this  

Changing a ColorKey

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

This topic is 4377 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.

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