I\'m using XNA 3.1
I have recently created a 2D Heads Up Display (HUD) by using Components.Add(myComponent)
to my game. The HUD looks fine, showing a 2D map
You have to enable the depth buffer:
// XNA 3.1
GraphicsDevice.RenderState.DepthBufferEnable = true;
GraphicsDevice.RenderState.DepthBufferWriteEnable = true;
// XNA 4.0
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
SpriteBatch.Begin
alters the state of the graphics pipeline:
In both versions depth buffering is disabled, that's what causes the issue.
Again, I cannot stress this enough:
Always make sure that ALL render states are correctly set before drawing any geometry.
Educate yourself on the purpose of each state and each stage in the rendering pipeline. If in doubt, try resetting everything to default.