Sign in to follow this  

Help with D3DXSPRITE and Alphablending.

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

Hi, I'm getting some really strange behaviour from ID3DXSprite->Draw() when using Alpha Blending and I can't figure out what is going on. Relavent code below: Loading the texture:

	CreateTexErr = D3DXCreateTextureFromFileEx(
					m_pDevice, 
					_pFileLoc, 
					D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2,
					D3DX_DEFAULT,
					0,
					D3DFMT_A8R8G8B8,
					D3DPOOL_MANAGED,
					D3DX_FILTER_NONE, 
					D3DX_DEFAULT,
					_ColourKey, 
					&pNewTexture->SrcFileInfo, 
					NULL, 
					&pNewTexture->pTexture);



Starting the drawing:

m_pSpriteInterface->Begin(D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_ALPHABLEND); 



Drawing the sprite:

// m_RenderList[count]->m_ColourKey = D3DCOLOR_RGBA(255,255,255,255);

		m_pSpriteInterface->Draw(	
					m_pTextureManager->GetTexture(m_RenderList[count]->m_TextureID), 
					0, 
					0, 
					&m_RenderList[count]->m_Center, 
					m_RenderList[count]->m_ColourKey);
	




The problem... I'm assuming that as the alpha value in the D3DCOLOR_RGBA() macro is lowered towards 0, the more transparent the image should get, but this isn't happening. As I lower the alpha value, the sprite stays completely unchanged until an alpha value of about 10-15 where it will gradually get a little bit more transparent (but not much) and then at the value of 1 the texture will no longer be drawn. I'm obviously doing something stupid here, I've been trying to figure it out for a good few hours with no luck. I've tried adding the usual renderstates, enabling alpha blending, etc, but nothing seems affect what it is doing at the moment. Any help is much appreciated. [Edited by - Boonio on September 17, 2007 2:13:45 PM]

Share this post


Link to post
Share on other sites
try to change m_RenderList[count]->m_ColourKey to 0x40ffffff and then 0x10ffffff (write manually) and then see what happens, maybe you aren't using color in the right way...

In your example instead of m_RenderList[count]->m_ColourKey you are using m_ColourKey ? (I see it is uncommented)

Share this post


Link to post
Share on other sites
Thanks for the response.

Sorry, I just put the m_ColourKey in the comments to show how I was setting the ColourKey being used. I'll edit it so it's a bit clearer.

That same thing is happening with the hex values. :(

Share this post


Link to post
Share on other sites
Thanks for all the replies, much appreciated.

I'm a complete idiot. :)

It was nothing to do with the alphablending or the render states or anything like that. I was registering objects to be rendered but not clearing the render list after drawing. So the same texture was being drawn over itself thousands of times, which made me think alpha blending was going crazy.

Oh well, another learning experience. :)

Share this post


Link to post
Share on other sites

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