james_lohr's picture

TextPrinter - Blending

Blending does not seem to work with the TextPrinter.

I found this old thread: http://www.opentk.com/node/1353

This is akin to using new TextPrinter(TextQuality.Medium), only with four times the memory consumption. Better to switch to TextQuality.Medium instead.

I didn't understand what you meant by this Fiddler : I'm already using TextPrinter(TextQuality.Medium) and not getting blending, so do I need to make the code changes suggested?


Comments

Comment viewing options

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

What do you mean blending is not working? Did you enable blending either manually or through TextPrinter.Begin()? (instance method)

james_lohr's picture

I simply want to be able to render text at varying opacities. At the moment, no matter what I try I get solid text even though I'm able to render primitives / textures at varying opacities just fine.

>>or through TextPrinter.Begin()? (instance method)

I don't understand. I'm not using TextPrinter.Begin() - I assumed this is simply used to set up an ortho perspective, but since I'm already in orthogonal mode, I'm not using this.

I've tried enabling blending and specifying an alpha value manually:

GL.Enable(EnableCap.Blend);
GL.Color4(1.0, 1.0, 1.0, 0.5f);
printer.Print("This is still solid", myFont, Color.Red, RectangleF.Empty, OpenTK.Graphics.TextPrinterOptions.NoCache);

I've also tried providing a color4:

printer.Print("This is still solid", myFont, Color.FromArgb(128, 255, 0, 0), RectangleF.Empty, OpenTK.Graphics.TextPrinterOptions.NoCache);

In both cases I get solid text. Perhaps I'm missing something obvious?

the Fiddler's picture

I see.

I wish I could help, but the TextPrinter is deprecated/unsupported and I really don't recall whether this was supposed to work or not. Your best bet would be to either take the TextPrinter code and adopt it to your needs or use a different text printing method (I recommend using System.Drawing to render text into a texture and then splat parts of this texture onto quads. This way you have full control over color, alpha and anything else you might need).

james_lohr's picture

Thanks FIddler.

>>(I recommend using System.Drawing to render text into a texture and then splat parts of this texture onto quads. This way you have full control over color, alpha and anything else you might need)

Given the amount of strife the TextPrinter has given me, I'm very tempted to do this. The trouble is that I would want to write a reasonably complete little library to do it, which would be an unnecessary deviation from my project. Has anyone perhaps written such a library already?

the Fiddler's picture

Check out the Texture Utility Library in the gallery, it offers a TextureFont class that might be of use. There is an engine called XRevolution should also be able to render text.