From f1928dc9a0f8eb52227b4dc8eaa7575fc774dc39 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Thu, 8 Nov 2007 15:56:49 +0000 Subject: [PATCH] Improved handling of line-endings. Removed some warnings. --- Source/OpenTK/Fonts/TextPrinter.cs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Source/OpenTK/Fonts/TextPrinter.cs b/Source/OpenTK/Fonts/TextPrinter.cs index edaf5b75..2f3b1602 100644 --- a/Source/OpenTK/Fonts/TextPrinter.cs +++ b/Source/OpenTK/Fonts/TextPrinter.cs @@ -14,6 +14,7 @@ using System.Runtime.InteropServices; using OpenTK.Math; using OpenTK.OpenGL; using OpenTK.OpenGL.Enums; +using System.Diagnostics; namespace OpenTK.Fonts @@ -25,7 +26,6 @@ namespace OpenTK.Fonts { //static Regex break_point = new Regex("[ .,/*-+?\\!=]", RegexOptions.Compiled | RegexOptions.IgnoreCase); //static char[] split_chars = new char[] { ' ', '\n', '\t', ',', '.', '/', '?', '!', ';', '\\', '-', '+', '*', '=' }; - static bool use_vbo, use_arb_vbo, use_display_list; static bool functionality_checked = false; static ITextPrinterImplementation printer; @@ -38,6 +38,8 @@ namespace OpenTK.Fonts #endregion + #region static void CheckNeededFunctionality() + /// /// Checks the machine's capabilities and selects the fastest method to print text. /// @@ -53,8 +55,12 @@ namespace OpenTK.Fonts throw new NotSupportedException("DefaultLayoutProvider requires at least OpenGL 1.1 support."); functionality_checked = true; + + Debug.Print("Using {0} for font printing.", printer); } + #endregion + #region --- ITextPrinter Members --- public void Prepare(string text, TextureFont font, out TextHandle handle) @@ -106,13 +112,7 @@ namespace OpenTK.Fonts if (Char.IsSeparator(c)) last_break_point = index_count; - if (c == '\n' || c == '\r') - { - //x_pos = layoutRect.Left; - x_pos = 0; - y_pos += font.Height; - } - else + if (c != '\n' && c != '\r') { font.GlyphData(c, out char_width, out char_height, out rect, out texture); @@ -146,6 +146,12 @@ namespace OpenTK.Fonts font.MeasureString(text.Substring(i, 1), out measured_width, out measured_height); x_pos += measured_width; } + else if (c == '\n') + { + //x_pos = layoutRect.Left; + x_pos = 0; + y_pos += font.Height; + } ++i; } } @@ -171,7 +177,7 @@ namespace OpenTK.Fonts GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); - //GL.Disable(EnableCap.Texture2d); + GL.Disable(EnableCap.DepthTest); GL.BindTexture(TextureTarget.Texture2d, handle.font.Texture);