Sign in to follow this  

Sprites and Alpha channels

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

im using an ID3DXSprite and i want to use an alpha channel in the texture but it doesn't seem to want to work am i limited to using the sprites draw function for create an alpha level? currently i am doing this before i draw but it is not working d3dd->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); d3dd->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); d3dd->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); where d3dd is the Direct3DDevice pointer any help would be grand thanks

Share this post


Link to post
Share on other sites
I'm not sure of the specifics of the D3DX Sprite stuff, so I don't know specifically what states it sets on it's own. But you might need to set the texture stage state properties, too. You'll want to set the D3DTSS_COLOROP to D3DTOP_SELECTARG1, probably, and set D3DTSS_COLORARG1 to D3DTA_TEXTURE, of course, and make sure to also set D3DTSS_ALPHAOP to D3DTOP_SELECTARG1, and D3DTSS_ALPHAARG1 to D3DTA_TEXTURE. It might likely default D3DTSS_ALPHAOP to D3DTOP_DISABLE. *checks docs* Okay, never mind, the default is D3DTOP_SELECTARG1 and D3DTA_TEXTURE, just like you should want. But I don't know. Might be something to look into anyway.

Share this post


Link to post
Share on other sites
The way I do alpha blending with ID3DXSprite is as follows:

I call the sprite's "Draw" function, passing all the relevant information to it.


Draw(pSprite_Texture, &src_Rect, NULL, NULL, 0, &vPosition, D3DCOLOR_COLORVALUE(1.0f, 1.0f, 1.0f, alpha));



Here, &src_Rect is the adress of the rectangle, specifying coordinates on the texture pointed to by pSprite_Texture. My final argument in the function is how I control the alpha blending: I pass 1.0f for all three color channels, and the value "alpha" for the alpha channel (in a D3DCOLOR_COLORVALUE macro), where alpha is pre-determined and is between 0.0 and 1.0.

1.0 is completely visible, 0.0 is completely transparent.

Nothing else special is happening.

Share this post


Link to post
Share on other sites

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