Archived

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

ColorKey and ID3DXSPRITE interface

This topic is 5573 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 using DX8.0 to do a 2d game and I''m using the ID3DXSPRITE interface to draw sprites. I used to load the textures with D3DXCreateTextureFromFileEx and all worked fine. The problem arises with animated sprites: After I saved the frames on one bitmap I followed these steps: 1)Create a Surface with IDirect3DDevice8::CreateImageSurface. 2)Load the bitmap on the surface with D3DXLoadSurfaceFromFile. 3)Create a texture for each frame on the image with D3DXCreateTexture. 4)Retrieve the surface of the texture with GetSurfaceLevel and copy part of the big surface to this surface using IDirect3DDevice8::CopyRects. This works, but I''ve lost the ColorKey capabilities, that D3DXCreateTextureFromFileEx offered! The problem is that D3DXCreateTexture doesn''t give the possibility to specify a D3DCOLOR ColorKey.. Is there any way to solve this problem with ID3DXSPRITE or do I have to abandon this interface? Thanks for any help!

Share this post


Link to post
Share on other sites
After loading the texture, you can lock it, and your program can manually set the alpha of all color-keyed texels to 0.0.


Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just keep as a single texture and use the source rectangle parameter in ID3DXSprite::Draw to specify the frame of animation.

Share this post


Link to post
Share on other sites
Thanks!

I''ll try with ID3DXSprite::Draw to change the source rectangle!

Sneftel:After locking the texure how can I change alpha of all color-keyed texels to 0.0?

Share this post


Link to post
Share on other sites
Use a for-loop. If the RGB component is equal to a certain value, set the A component to 0.0. Fairly straightforward.


Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites