Hello, I'm new to XNA as well as DirectX and am experiencing some weird side effects when drawing a sprite that I can't account for. I have a 3D ship that I can fly around using the Xbox360 controller (completed the XNA tutorials 1-3) and decided to see if I could implement pausing.
Well, i got everything working how I want it and even made a 2d sprite that loads a texture asset and draws it to the screen when the player pauses (just a blue rectangle with the word "Paused..." written on it). That works great too, except by drawing the sprite to the screen my 3d model suddenly becomes semi-transparent! Even when the sprite is no longer being drawn the model remains semi-transparent until I restart the game.
I am developing in XNA Game Studio Express and deploying onto my Xbox360.
I am confused by this side-effect of drawing the sprite. The 3d model references a .tga for it's texture but it is completely separate from my .bmp texture (which has been added through the content pipeline).
Here's the code that causes the effect (by commenting it out I no longer see the Pause sprite but also no longer get semi-transparency on the model):
spriteBatch.Begin(
SpriteBlendMode.None);new Rectangle(graphics.GraphicsDevice.Viewport.Width/2 - pauseTexture.Width/2,spriteBatch.Draw(pauseTexture,
graphics.GraphicsDevice.Viewport.Height/2 - pauseTexture.Height/2,
pauseTexture.Width,
pauseTexture.Height),
Color.White);spriteBatch.End();
At first I didn't use a SpriteBlendMode but thought maybe by explicitly using SpriteBlendMode.None I would avoid any possible transparency confusion, but it has no effect.
Register ...
By jimperry
Hi,I hope this doesn't break any of the rules, I have checked and I don't think that it does.The par...
By kinlan
Hello! My first post on the forum. My name is Phantasy, I like fantasy so that is why. I am sure XNA...
By phantasy
XBL Radio.com has put out their roundtable on XNA with myself and a couple of developers. Check it o...
By jimperry
What kind of licensing issues might arise if we want to run code builtfrom a GPL or LGPL library? An...
By michaelcummings, 2 Comments
Hello,So I am rendering a 3D scene. I do run a kind of old card ATI Radeon 9800 Pro+ (@XT)I am havin...
By chryso, 3 Comments
... Just Checking ...The XNA GSE for the 360 is supposed to be released ... "This Holiday Seas...
By echsbachs, 5 Comments
Hi everyone,I've looked through other posts regarding this, trying all of the suggestions, and I'm s...
By n_brady, 2 Comments
Hi all, How to create skyBox with Xna? I tired search with internet. But i can't find good tutorial...
By brian_tsim, 1 Comments
You might find these links helpful:
http://blogs.msdn.com/shawnhar/archive/2006/11/13/spritebatch-and-renderstates.aspx
http://msdn2.microsoft.com/en-us/library/bb203941.aspx
After drawing using SpriteBatch, why do my 3D objects draw incorrectly?
By default, SpriteBatch.Begin does not save your current render state, and will change certain render state properties that may make 3D objects render incorrectly. You can choose to either reset the render state yourself after the call to SpriteBatch.End, or call SpriteBatch.Begin and pass in SaveStateMode.SaveState, which will restore the render state after sprites are drawn.
elitayrien_msft | Mon, 03 Sep 2007 23:17:00 GMT |
Eli,
Are there any performance considerations to which option to choose? I certainly find it easier to set the SaveStateMode than to manually adjust my device, but I wonder if it would ever be prudent to manually change just the device settings necessary?
shazen | Mon, 03 Sep 2007 23:19:00 GMT |
I ended up using a different SpriteBatch.Begin overload as follows:
spriteBatch.Begin(
SpriteBlendMode.None,SpriteSortMode.BackToFront,SaveStateMode.SaveState);and now it works as I expect!
Thanks Eli!
nfurtwangler | Mon, 03 Sep 2007 23:20:00 GMT |
Sorry Eli,
I posted the last post before reading Shawn's blog you referenced. Never mind. ;-)
shazen | Mon, 03 Sep 2007 23:21:00 GMT |