I'm drawing text from a texture atlas containing an alphamap GL_ALPHA
, GL_UNSIGNED_BYTE
--- it's produced by stb_truetype, if that's any help. Right now I'm drawing with GL_BLEND
enabled and the texture with all the default settings. I can set the foreground colour with glColor3f
, the background is transparent, and everything works fine.
The problem is, on some platforms drawing transparent text is too slow. And I don't actually need it; the background is always a solid colour. I am, in fact, filling it with glRectf
just before drawing the texture.
Experiments have shown that disabling GL_BLEND
fixes all my performance issues, but of course that gives me solid blocks of colour instead of text. Looking at the documentation for glTexEnvi
, it seems to me that it ought to be possible to draw the texture without blending, getting it to just apply the alpha value to fixed source and destination colours. But I can't figure out how, the documentation is rather opaque, and just trying stuff isn't helping.
(Maybe I need to have GL_BLEND
enabled but tell it somehow to use my background colour rather than reading from the framebuffer?)
Can anyone enlighten me?
I am using old-fashioned fixed-pipeline pre-shader OpenGL, by the way, so I can't simply do all this in the shader fragment.