vhle's picture

textprinter & transparency

Does anyone know if there's a way to use blending with the textprinter class to create transparent text on the screen? I've tried using OpenGL's blending functions with no luck. Any help would be appreciated!



Comment viewing options

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

I'm not 100% certain, but it might be possible to use a text color with an alpha value of, say, 128 and the text should appear translucent automatically.

vhle's picture

I've tried the following with no luck:

Dim texFont As TextPrinter = New TextPrinter(OpenTK.Graphics.TextQuality.High)
Dim ff As Font = New Font("Times", 30)
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One)
texFont.Print("test", ff, Color.FromArgb(128.0F, 255.0F, 255.0F, 255.0F))

The text is still opaque and white. Am I doing something wrong? Thanks.

petrofftom's picture

I was having this exact same problem. I fixed it by changing code inside of the OpenTK code. I changed a few lines of code in GL12TextOutputProvider.cs. I changed the SetBlendFunction from
GL.BlendFunc(BlendingFactorSrc.ConstantColorExt, BlendingFactorDest.OneMinusSrcColor);
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
and then I changed the function SetColor from
After that transparency stuff worked just fine.

vhle's picture

Thanks, that totally worked! You're awesome!

the Fiddler's picture

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