protected override void OnLoad() { // The font factory allows us to extract the font information and construct a font texture using the // System.Drawing library. var systemFont = new System.Drawing.Font(FontFamily.GenericSansSerif, 64, GraphicsUnit.Pixel); var(textureData, font) = FontFactory.From(systemFont, 1); fontTexture = textureData.ToTexture(t => { t.SetFilterMode(TextureMinFilter.LinearMipmapLinear, TextureMagFilter.Nearest); t.GenerateMipmap(); }); // We set up a mesh builder, and renderer as usual. We bind the font texture from the font loading into the // shader. meshBuilder = new ExpandingIndexedTrianglesMeshBuilder <UVVertexData>(); var renderable = meshBuilder.ToRenderable(); shaderProgram = ShaderProgram.FromShaders( ShaderFactory.Vertex.FromFile("text.vs"), ShaderFactory.Fragment.FromFile("text.fs")); renderer = BatchedRenderer.From(renderable, shaderProgram, new TextureUniform("fontTexture", TextureUnit.Texture0, fontTexture)); // The text drawer is a helper class to help us draw text assuming that it will be rendered with the right // font texture bound. var textDrawer = new TextDrawer <UVVertexData, Void>(font, meshBuilder, (p, uv, _) => new UVVertexData(p, uv)); textDrawer.DrawLine( Vector3.Zero, "Hello World!", 64, 0.5f, 0.5f, Vector3.UnitX * 2 / 1280, -Vector3.UnitY * 2 / 720, default); }