Page 1 of 1

how to print a text string onto screen?

Posted: Sat Oct 10, 2015 1:57 pm
by yanbo2u
i just need to show something like FPS

Re: how to print a text string onto screen?

Posted: Sat Oct 10, 2015 6:04 pm
by Norbo
If you're using XNA, the SpriteBatch supports simple text drawing. Nothing specifically BEPUphysics related supports text drawing (or general graphics for that matter).

Re: how to print a text string onto screen?

Posted: Sun Oct 11, 2015 3:17 am
by yanbo2u
thank you Norbo for the quick reply.

I tried to use spriteBatch.DrawString(). Then, the graphics with BEPU engine messed up.

The attachment pictures show the scene before and after using spriteBatch to draw texts.

The code Draw function is like this :

Code: Select all

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.BlendState = BlendState.AlphaBlend;

            GraphicsDevice.Clear(Color.CornflowerBlue);

            scene.Draw(gameTime);


            spriteBatch.Begin();
            DrawText("this is a good text example");
            spriteBatch.End();

            base.Draw(gameTime);
        }

Re: how to print a text string onto screen?

Posted: Sun Oct 11, 2015 8:27 am
by JusTiCe8
Mixing 2D/3D needs this:

Code: Select all

GraphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };
(see http://rbwhitaker.wikidot.com/2d3d-combined for more details)

Hope this help.

Re: how to print a text string onto screen?

Posted: Sun Oct 11, 2015 9:20 am
by yanbo2u
thank you, JusTiCe8. that works.