BlendFunc for textured fonts with changing backgrounds

I am trying to use Textured fonts so that I can display text in my openGL scene. However, I am having a hard time finding glBlendFunc values ​​that will work.

The background on which the text will be placed is a grayscale image, but will change at runtime. As the background changes, text can be on top of any color from black to white.

The best values ​​I've found are glBlendFunc (Gl.GL_SRC_COLOR, Gl.GL_ONE_MINUS_SRC_ALPHA). This will make the black box surrounding the character disappear, but the character itself will disappear as the background moves towards white.

Please, help!

+1


source to share


1 answer


Do you want the text to be inverted based on the background color? white text on black, black text on white? I think you can achieve the inversion via blendfunc.



Alternatively, you can use a font texture that has a "border" built into it to help make the character stand out from the background. Imagine a white font with a smooth alpha blended black "glow". The font will look good with almost all colors.

+1


source







All Articles