public void Draw(float x, float y, float z, float scaleX, float scaleY, string text, Color color) { int fontValue, textLength, textBufferLength, fontColor; float u, v, translation, fontSizeX, fontSizeY, fontWidth, fontHeight, fontMargin; Matrix4 fontTranslation, fontWorld; Render.GetWorld(ref world); Matrix4.CreateTranslation(x, y, 0.0f, out fontTranslation); Matrix4.Mult(ref world, ref fontTranslation, out fontWorld); Render.SetWorld(ref fontWorld); translation = 0.0f; fontSizeX = 16 * scaleX; fontSizeY = 16 * scaleY; fontWidth = 1.0f / 16.0f; fontHeight = 1.0f / 16.0f; fontMargin = 1.0f / 256.0f; fontColor = color.ToArgb(); for (int i = 0, j = 0; i < text.Length; i++, j += 4) { fontValue = (int)text[i]; u = (float)(fontValue % 16) * fontWidth + fontMargin; v = (float)(fontValue >> 4) * fontHeight + fontMargin; fontVertices[j].Position.X = translation; fontVertices[j].Position.Y = 0.0f; fontVertices[j].Position.Z = z; fontVertices[j].TextureCoordinate.X = u; fontVertices[j].TextureCoordinate.Y = v + fontHeight; fontVertices[j].Color = fontColor; fontVertices[j + 1].Position.X = fontSizeX + translation; fontVertices[j + 1].Position.Y = 0.0f; fontVertices[j + 1].Position.Z = z; fontVertices[j + 1].TextureCoordinate.X = u + fontWidth; fontVertices[j + 1].TextureCoordinate.Y = v + fontHeight; fontVertices[j + 1].Color = fontColor; fontVertices[j + 2].Position.X = translation; fontVertices[j + 2].Position.Y = fontSizeY; fontVertices[j + 2].Position.Z = z; fontVertices[j + 2].TextureCoordinate.X = u; fontVertices[j + 2].TextureCoordinate.Y = v; fontVertices[j + 2].Color = fontColor; fontVertices[j + 3].Position.X = fontSizeX + translation; fontVertices[j + 3].Position.Y = fontSizeY; fontVertices[j + 3].Position.Z = z; fontVertices[j + 3].TextureCoordinate.X = u + fontWidth; fontVertices[j + 3].TextureCoordinate.Y = v; fontVertices[j + 3].Color = fontColor; translation += fontTranslations[fontValue] * scaleX; } textLength = text.Length << 2; textBufferLength = 24 * textLength; Render.Apply(); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)textBufferLength, IntPtr.Zero, BufferUsageHint.DynamicDraw); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)textBufferLength, fontVertices, BufferUsageHint.DynamicDraw); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, textLength); Render.SetWorld(ref world); }