Sign in to follow this  

[D3D10] transparent sprites

This topic is 2854 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 having trouble to get my sprites to draw with transparent background. I feel like I'm doing something wrong in code, although for all I know this could be a problem with actual .bmp file. Although I feel like I've done everything right creating the bmp file and saved it in the right format and everything it just shows up with a white background. Anyway I'm using an ID3DX10Sprite to draw a collection of ID3D10Texture2D objects, each of which have transparency. My sequence of calls is basically like this: sprite->Begin(D3DX10_SPRITE_SORT_DEPTH_FRONT_TO_BACK); device->OMSetBlendState(blend, {0.0f, 0.0f, 0.0f, 0.0f}, 0xFFFFFFFF); foreach (ID3D10Texture2D texture in textures) sprite->DrawSpritesBuffered(texture, 1); sprite->Flush(); sprite->End(); where 'blend' is an ID3D10BlendState created with the following sequence of code:
	D3D10_BLEND_DESC desc;
	ZeroMemory(&desc, sizeof(D3D10_BLEND_DESC));
	desc.AlphaToCoverageEnable = TRUE;
	desc.BlendEnable[0] = TRUE;
	desc.SrcBlend = D3D10_BLEND_SRC_ALPHA;
	desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA;
	desc.BlendOp = D3D10_BLEND_OP_ADD;
	desc.SrcBlendAlpha = D3D10_BLEND_SRC_ALPHA;
	desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA;
	desc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
	desc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;
	
	VERIFY_HR(g_app->graphics().device()->CreateBlendState(&desc, &blend_));

Any thoughts on what might be going wrong? And how can I tell if it is a problem with the image format or with the blending code?

Share this post


Link to post
Share on other sites
Wow, ok. Figured out the problem but it seems kind of stupid. Guess I'll post here since I saw the same question at least 10 times on google and nobody ever had an answer.

Use the DirectX Texture Tool that comes with the DirectX SDK to convert all the files to .dds format and it works fine. Seems kind of odd that it doesn't support bmp files though.

Share this post


Link to post
Share on other sites

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