PDA

View Full Version : GL_INTENSITY



Crane
09-13-2007, 02:08 PM
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?

Zengar
09-13-2007, 02:34 PM
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).

Korval
09-13-2007, 03:17 PM
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.

Crane
09-14-2007, 01:51 AM
So would something along the lines of the following would do the trick, or is there a catch?

(Pascal Code)


glTexImage2D(
GL_TEXTURE_2D,
0,
GL_INTENSITY,
Width,
Height,
0,
GL_LUMINANCE,
GL_UNSIGNED_BYTE,
PixelData
);

k_szczech
09-14-2007, 02:19 AM
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.

Korval
09-14-2007, 10:19 AM
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.