I have a greyscale texture map that I wish to use as a font map, containing anti-aliased glyphs of individual characters, so ideally I want each texel to represent both luminance and alpha values, that is, GL_INTENSITY. The thing is, glTexImage2D does not support GL_INTENSITY as a format for the texel data. Is there a way around this, or do I have to double each byte in the texture map so I can use the valid GL_LUMINANCE_ALPHA?
I guess using GL_APHA (or GL_RED/BLUE etc.) as format would do the trick (only a suggestion, I have never done it myself).
The thing is, glTexImage2D does not support GL_INTENSITY as a format for the texel data.
It doesn’t specify it as an external format. Any single-component format will do; I use GL_LUMINANCE even though the internal format is GL_INTENSITY.
So would something along the lines of the following would do the trick, or is there a catch?
glTexImage2D( GL_TEXTURE_2D, 0, GL_INTENSITY, Width, Height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, PixelData );
Yes, it should work.
However you may not get what you want if you use GL_INTENSITY.
I would suggest using alpha-only texture.
When rendering fonts you usually want it to have constant color and variable opacity. You don’t want them to be darker on edges.
Of course, if your shader simply replaces the RGB with the font color, there’s no problem. But, then again, a GL_ALPHA texture accomplishes the same thing a bit more explicitly.