ColorKey and ID3DXSPRITE interface
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!
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.
Don''t listen to me. I''ve had too much coffee.
Just keep as a single texture and use the source rectangle parameter in ID3DXSprite::Draw to specify the frame of animation.
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?
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?
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.
Don''t listen to me. I''ve had too much coffee.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement