Jump to content
  • Advertisement
Sign in to follow this  
Lord_Taren

Texture transparency using Direct3D Sprite class

This topic is 4971 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 am having trouble getting texture transparency to work using the Direct3D Sprite class. I have tried different file formats for the images. I have tried file formats that include the aplha channel and ones that don't. No matter how I try, the alpha channel is ignored. Here is a sample of the code I am using: xTmpTexture = TextureLoader.FromFile(GrafixEnv.Device, sTextureName, 0, 0, 1, 0, Direct3D.Format.A8R8G8B8,Direct3D.Pool.Managed, Direct3D.Filter.None, Direct3D.Filter.Point, 0, ref dxImageInfo); this.m_iWidth = dxImageInfo.Width; this.m_iHeight = dxImageInfo.Height; //* Begin the drawing sequence this.m_dxSprite.Begin(Direct3D.SpriteFlags.None); //* Draw the sprite this.m_dxSprite.Draw( (Direct3D.Texture)this.m_dxTexture, srcRect, new DirectX.Vector3(0, 0,0), this.m_v3Position, System.Drawing.Color.White.ToArgb()); this.m_dxSprite.End(); Is there some render state I need to set or is there something I am forgetting to do?

Share this post


Link to post
Share on other sites
Advertisement
For the Sprite flags you might want to try passing AlphaBlend (can't recall exact name, but it's in the docs).

Basically, it's being ignored because you specifically told it to by passing None. Fix that up and you should be good to go.

Share this post


Link to post
Share on other sites
I believe that when you call ID3DXSprite::Begin(), you need to specify the D3DXSPRITE_ALPHABLEND flag. The correct Managed syntax for this would be:

m_dxSprite.Begin( SpriteFlags.AlphaBlend );

This will automatically enable all of the alpha-blending renderstates that you need.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanx for the assistance.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!