Archived

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

SikCiv

D3DX Sprite blitting

Recommended Posts

Ive setup D3DX and my sprites are being blitted by DrawSpriteSimple, but when they come out on the screen, the pixels that are not to be blitted (the color key) are blitted resulting in all the sprites being blitted as rectangles, instead of only the character. How do I set the color key of the blits? Ive tried DDSetColorKey, with no luck. Do u have to use an alpha mask or something?

Share this post


Link to post
Share on other sites
As D3DX uses D3D to draw the sprites you have to enable colorkeying in the Direct3DDevice. I beleive it is D3DRENDERSTATE_COLORKEYENABLE. You must also specify that the surface will be used with colorkeying when creating them.

I''m making an assumption here as I haven''t tried it. I have just reinstalled my system as well, so I can''t check the SDK docs.

Share this post


Link to post
Share on other sites
I had similar problems. the advice given is correct... BUT (and its a big but), some newer cards like the TNT2 do not support color keying in D3D at all (believe it or not), they ''fake'' the color key support by using alpha blending. The upshot of this is that color keys with D3DX on a TNT2 may not work at all. You have to use Alpha testing instead. Older cards (like my ATI Xpert) dont have this problem.
Theres more information on this nightmare scenario at nVidias website. Even if you dont have a TNT2, some of the users will :-)

http://www.positech.co.uk

Share this post


Link to post
Share on other sites
I''ve noticed that the sprite sample included with the DX SDK has this same problem. I started a thread here about six months ago asking this very same question. I tried *everything* with enabling colorkeying, and just about everything with alphablending and could not get it to work on a NeoMagic *or* TNT (1) card.

I think my final assumption ended up being that the D3DXCreateSpriteFromFile (I forget the exact function name, but it was something to that extent) did not properly set the color keyable bit for the surface it created. There seemed to be no way to fix this if you create your sprites in that manner, as you can only set that attribute during the surface creation.

I wish MS would just include the source to D3DX so we could verify/fix this ourselves.

I submitted a bug-report to MS, but never received any response.

Share this post


Link to post
Share on other sites