I m trying to draw grayscale image in color as texture in OpenGL using two colors. Black goes to color1 and white goes to color2. Texture is loaded using GL_RGBA
.
I have tried two solutions:
1)
- Load image as texture
- Draw image on screen
- Enable blending
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
and draw rectangle with color1glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE);
and draw rectangle with color2
But... When I apply first color, there is no black color on screen and when second color is applied it is combined with first color too.
2)
- Save image as texture but don t use grayscale image, use white image with alpha channel that is same as grayscale
- Draw rectangle with color1
- Draw image
But... When image is drawn it doesn t use color1 where image is transparent, instead it uses current color set with glColor.
Any help will come in handy :)