how to print a text string onto screen?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
yanbo2u
Posts: 21
Joined: Sun Oct 04, 2015 4:41 pm

how to print a text string onto screen?

Post by yanbo2u »

i just need to show something like FPS
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to print a text string onto screen?

Post 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).
yanbo2u
Posts: 21
Joined: Sun Oct 04, 2015 4:41 pm

Re: how to print a text string onto screen?

Post 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);
        }
Attachments
This is the scene AFTER introducing spriteBatch text drawing
This is the scene AFTER introducing spriteBatch text drawing
after.PNG (30.59 KiB) Viewed 5220 times
This is the scene BEFORE introducing spriteBatch text drawing
This is the scene BEFORE introducing spriteBatch text drawing
before.PNG (35.96 KiB) Viewed 5220 times
JusTiCe8
Posts: 52
Joined: Mon Jun 01, 2015 9:02 am

Re: how to print a text string onto screen?

Post 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.
yanbo2u
Posts: 21
Joined: Sun Oct 04, 2015 4:41 pm

Re: how to print a text string onto screen?

Post by yanbo2u »

thank you, JusTiCe8. that works.
Post Reply