juliuswang's picture

Text Print Issue

Hi 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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

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.

juliuswang's picture

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