protected void OnLoad(object sender, EventArgs e) { spriteBatch = new SpriteBatch(); texture = new Texture(new Bitmap(@"Content/test.png")); sprite = new Sprite(texture); arial = new BitmapFont("Content/arial_test"); text = new Text(arial, "The quick brown fox \njumps over the lazy dog.", new Vector2(0, 256), Color.Black); fpsFont = new BitmapFont(@"Content/fps_font"); fpsCounter = new ClockDisplay(Game.Clock, fpsFont, Vector2.Zero, Color.Black); // White is also default camera = Camera.CreateOrthographic(Game.ClientSize.Width, Game.ClientSize.Height, -1, 1); }
private void GenerateText() { float dy = 0.0f; foreach (Data data in Enum.GetValues(typeof(Data))) { // This is not technically required but *ensures* that this does not create a ton of OpenGL VAOs/VBOs. if (TextItems[data] != null) TextItems[data].Dispose(); TextItems[data] = new Text(font, GetInfo(data), Position + new OpenTK.Vector2(0, dy), Color); dy += font.MeasureString(data.ToString()).Y; } }
public static void AddString(this SpriteBatch spriteBatch, Text text) { textToDraw.Add(text); }