Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

SikCiv

Changing D3D8Texture Colorkey runtime

This topic is 6271 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 use D3DXLoadTextureFromFileEx to create a colorkeyed texture when I load my graphic files, though sometimes I need to draw the same texture but without colorkeying, and D3DXSprite->Draw() doesnt have a colorkey flag. Is there a way to disable and enable colorkeying after the texture has been created?

  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites
Advertisement
G''day!

I don''t think you can do this with D3DXSprite. One thing that might work (though it''s a hack) would be to call D3DXSprite->Begin() then turn off alphablending. Begin() should turn alphablending on, but if you turn it off manually after Begin (but before you draw) it may work.

Alternately:

1)Don''t use D3DXSprite, it''s simple to make your own interface which will give you more control. My dhEngine has a crude Sprite drawing function. It doesn''t take over any renderstate stuff so you can do it yourself. It also filters out redundant renderstates for greater efficiency. (It''s available on my site).
2)Load 2 copies of the texture, one with colourkey, one without.
3)Lock the texture and do the colourkeying yourself. When you want alpha, change all those pixels to transparent, when you want opaque, lock it and change all the alphas off. There''s an example for programmatically doing the colour key stuff, check out my web page (Computed Alpha Example). It''s probably a better idea to just have 2 copies though (idea #2).



Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites

  • 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!