Buggy Rendering when drawing text,

Hello,

When I render without any text it renders like it should be:

but when I draw text it looks pretty different:

I’m also not able to switch to the wireframe mode when rendering text, I don’t know why.

Here’s my code for the text:

private void DrawText()
        {
            spriteBatch.Begin();
            spriteBatch.DrawString(font, "X: " + camera.Position.X, new Vector2(0, 0), Color.White);
            spriteBatch.DrawString(font, "Y: " + camera.Position.Y, new Vector2(0, 20), Color.White);
            spriteBatch.DrawString(font, "Z: " + camera.Position.Z, new Vector2(0, 40), Color.White);
            spriteBatch.End();
        }

And the code for rendering:

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            DrawText();

            if (world != null)
            {
                for (int a = 0; a < world.chunks.GetLength(0); a++)
                {
                    for (int b = 0; b < world.chunks.GetLength(1); b++)
                    {
                        if (world.chunks[a, b] != null)
                        {
                            world.chunks[a, b].draw(gameTime, camera, basicEffect);
                        }
                    }
                }
            }

            base.Draw(gameTime);
        }

What am I doing wrong there?

Have a look at this: http://blogs.msdn.com/b/shawnhar/archive/2010/06/18/spritebatch-and-renderstates-in-xna-game-studio-4-0.aspx

Not sure if it’s 100% applicable to your particular MonoGame flavour, but it’s worth a try.

It seems like a dirty renderstate to me, what happens if you draw the world before the text?

That won’t make any difference - if the text comes after the 3D content, then the next frame the 3D content will be drawn after the text with the same render states anyway. You need to actively reset the render states, as Teh Shawn (in his infinite wisdom) describes in the blog post.