Texture transparency using Direct3D Sprite class

Started by
2 comments, last by GameDev.net 19 years, 5 months ago
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?
-------------------Emil Diegoediego@miami.edu
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.
Stay Casual,KenDrunken Hyena
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.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Thanx for the assistance.

This topic is closed to new replies.

Advertisement