
Text Print Issue
Posted Friday, 12 December, 2008 - 22:00 by juliuswang inHi Guys,
How's going.
I have encountered a text rendering issue in my program. The situation is, I am providing user a multiple windows that could be opened and closed on demand. Everything works just fine with my current code, except the text printing.
The very first time, if user opens a gl window, the text could be print correctly and if they do not close any window, the font is all-the-way correct. It, however, turns into blocks of solid color if user close one window and open another. Then everything it prints are just blocks of blocks of solid color.
I just use the uncached textprinter functions.
Thanks so much,
Sean
//These are in the same class.
internal TextureFont font = new TextureFont(new Font(FontFamily.GenericSerif, 12.0f));
internal TextPrinter printer = new TextPrinter();
internal void DrawAt(float x, float y, string text)
{
printer.Begin();
GL.Translate(x, y, 0.0);
printer.Draw(text, font);
printer.End();
}


Comments
Re: Text Print Issue
This is a design flaw of the TextureFont class: it stores all glyphs on the first context (window) it encounters. When you destroy the first window, all glyph are lost.
Possible workaround (may or may not work): create a hidden window that you keep alive for the whole duration.
I am working on a new TextPrinter implementation for the next release, which fixes this issue.
Re: Text Print Issue
Hi Fiddler,
Thanks so much for explaining this. I have banging my head to the wall on these issue. :D
Looking forward to your new work!
I really appreciate it!.
Sean