Hey!
I’ve got a texture, and I’d like to flood on top of that a bit of colour with some transparency (say red, with alpha equal to 0.5).
What I’ve got as input data is the texture and the mask (white / black OR (!) white with shades of grey).
Now what’s the best and easiest way to go? I do not need the best performance available, what I need is good performance and portability
Here’s what I’ve got:
unsigned char pixeldata[imagewidth * imageheight];
unsigned char mask[imagewidth * imageheight];
...
if (necessary)
doThresholdOnMask(mask);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, imagewidth, imageheight, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixeldata);
..
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, imagewidth, imageheight, GL_LUMINANCE, GL_UNSIGNED_BYTE, mask);
displayTexture();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER, 0.1f);
glEnable(GL_ALPHA_TEST);
displayMask();
and this gives me almost what I need, except ‘the mask’ is black and I’d like it to be reddish (with some transparency). Do I need to do some multi-texturing? Or maybe glTextEnv is the way to go (somehow)? Or maybe does setting GL_ALPHA as format in glTexImage2D would be something for me? What does it do btw? I do not understand completely all the manuals.
I’ve found this: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=20 and it looks good, but since I only need some colour I guess I do not need to draw first the texture, then put the mask and then flood it with red. Or maybe it’s the best solution?
Now, it would be perfect, if the mask could be in shades of grey, and the transparency of my colour could depend on these values (but this is not essential)
What’s the best thing to do?
Thanks for any help,
Kornel