Now, I was tinkering around today trying to get my font stuff caught up with Evil Steve (who, funnily enough is using D3D for his rendering). What we both did is load the fonts white onto a pure-alpha texture, so that we could color them on the fly with diffuse colors.
Coming from D3D (years ago), diffuse colors are the color components defined per-vertex. Apparently this is not the case with OpenGL, which defines diffuse per-material.
My dilemma is - is there anyway to emulate the behavior of blending together the primary color with the texture fragment such that it would behave as if it were the diffuse? (Aside from writing a shader, which would be... ugh.)
The Red Book suggested using GL_COMBINE with various ... stuffs, and the one that was the closest was GL_INTERPOLATE. It interpolated by a weighted value. Which, I mean, was close, but not what I wanted.
Basically, I need a way to color my fonts which can be batched with everything else that's being rendered (everything is drawn in 1 call; though this could be changed, I rely on drawing order to sort stuff right now, so batching per-material is not possible. I'd have to break that 1 call into an ungodly number of calls to change materials).
Ugh, I suck at explanations. I guess, uhh, what I need is like -
Color Fragment | Texture Fragment | Desired Output
(r,g,b) (1,1,1) (r,g,b)
(1,1,1) (r,g,b) (r,g,b)
(rf,gf,bf) (rs,gs,bs) actually... I have no idea.
Auuguhhh I know this isn't going to work. Time to approach from a different perspective, I think.
Color Fragment | Texture Fragment | Desired Output
(rf,gf,bf) (rs,gs,bs,0) (rf,gf,bf)
(rf,gf,bf) (rs,gs,bs,1) (rs,gs,bs)
Hurr, from that we can induce that the formula that I need is -
Cf*(1-As)+Cs*As
...and my Red Book is packed in the car since I'm leaving for next semester tommorrow. ARGH. Any ideas on this one guys? :S