When I tried adding text to my MonoGame program, I encountered a problem. It stopped rendering 3D objects properly, cutting front faces on some, not displaying others altogether.
I've tried ending the batch after drawing the models too, to the same effect
public override void Draw(GameTime gameTime)
{
spriteBatch.Begin();
string output = "Score";
spriteBatch.DrawString(spriteFont, output, Vector2.Zero, Color.LightGreen,
0, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
spriteBatch.End();
foreach (BasicModel model in models)
{
model.Draw(((Game1)Game).GraphicsDevice, ((Game1)Game).mainCamera);
}
base.Draw(gameTime);
}
Why is my text implementation screwing up my 3D models?
SpriteBatch.Begin() changes some grapic pipeline render states in a way that is best for 2d rendering but not for 3d rendering.
So after rendering your 2d, you need to reset those states for the 3d rendering.
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
Now your 3d will draw fine. See this link for more info.
Add those 2 lines between your spriteBatch.End()
and your foreach()