Your First XNA Game: Load DDS with Alpha Channel

Hello, just looking at the "Your First XNA Game" tutorial. It mentions using the DirectX Texture Tool to create a .dds file with an alpha channel rather than a .png.

Texture2D.FromFile(graphics.GraphicsDevice, "sometexture.dds");

doesn't seem to cut it for the alpha part. I tried putting the following before it:

TextureCreationParameters txParams = Texture2D.GetCreationParameters(graphics.GraphicsDevice, "sometexture.dds");

txParams.Format = SurfaceFormat.Rgba32;

to force it to use a8r8g8b8 but still nada.

Any suggestions?

Thanks

[615 byte] By [sdochert] at [2007-12-23]
# 1
I had similar issues until I changed the blending mode on the spritebatch:

spriteBatch.Begin(SpriteBlendMode.AlphaBlend);

bigbob at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 2

Thanks bigbob, that was exactly what I was looking for as well!
GeorgeClingerman at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 3

Hey George,

Looks like the "Your First XNA Game" sample's call to SpriteBatch.Begin doesn't pass in SpriteBlendMode.AlphaBlend. Looking at this post, I realize it probably should, since it's not too far out to expect that people will want to draw masked sprites with this code.

The tutorial will be updated in the documentation to draw alpha blended sprites.

Thanks for your feedback!

CharlesCox-MSFT at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 4
sdochert wrote:

Hello, just looking at the "Your First XNA Game" tutorial. It mentions using the DirectX Texture Tool to create a .dds file with an alpha channel rather than a .png.

Texture2D.FromFile(graphics.GraphicsDevice, "sometexture.dds");

doesn't seem to cut it for the alpha part. I tried putting the following before it:

TextureCreationParameters txParams = Texture2D.GetCreationParameters(graphics.GraphicsDevice, "sometexture.dds");

txParams.Format = SurfaceFormat.Rgba32;

to force it to use a8r8g8b8 but still nada.

Any suggestions?

Thanks

Yeah, I got to that bit and had no idea what the DIrect X Texture Tool was so I gave up for the evening. Anyone care to point me in the right direction ?

bombfrog at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 5
I think its in the DirectX SDK download - that's where the other tools talked about in the tutorials, instructions, help, forums, etc. are at. I'm in the process of downloading the DX SDK now also.
Jim.Welch at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...