Commit Description:
Add timers for Simulation and various engines...
Commit Description:
Add timers for Simulation and various engines Starting to add additional timers for different stages of the process of updating in order to get more insight into what is slowing it down. The update takes 9ms, which is much longer than it used to. Engine-specific timers are coming later.
File last commit:
Show/Diff file:
Action:
SpriteFontPlus/samples/SpriteFontPlus.Samples.BMFont/Game1.cs
88 lines | 2.1 KiB | text/x-csharp | CSharpLexer
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace SpriteFontPlus.Samples.BMFont
{
/// <summary>
/// This is the main type for your game.
/// </summary>
public class Game1 : Game
{
GraphicsDeviceManager _graphics;
SpriteBatch _spriteBatch;
private SpriteFont _font;
public Game1()
{
_graphics = new GraphicsDeviceManager(this)
{
PreferredBackBufferWidth = 1024,
PreferredBackBufferHeight = 768
};
Content.RootDirectory = "Content";
IsMouseVisible = true;
Window.AllowUserResizing = true;
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
_spriteBatch = new SpriteBatch(GraphicsDevice);
Texture2D texture;
using (var stream = TitleContainer.OpenStream("Fonts/test_0.png"))
{
texture = Texture2D.FromStream(GraphicsDevice, stream);
}
string fontData;
using (var stream = TitleContainer.OpenStream("Fonts/test.fnt"))
{
using (var reader = new StreamReader(stream))
{
fontData = reader.ReadToEnd();
}
}
_font = BMFontLoader.LoadXml(fontData, name => new TextureWithOffset(texture));
GC.Collect();
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
_spriteBatch.Begin();
// Render some text
_spriteBatch.DrawString(_font, "The quick brown fox jumps over the lazy dog",
new Vector2(0, 0), Color.White);
_spriteBatch.End();
base.Draw(gameTime);
}
}
}