Masking to show player color....problem please help

OpenGL,Ortho,2D game:

Ok i have these units in my 2d game i want to display using various player colors.However the unit image is just 1 image.The pixels where player color should appear are known/marked out by a specific color.The unit image is displayed as a textured quad. I want to use only the unit image & say some mask to display any player color in the unit image.

So i thought the mask could be white only where player color should be present(black otherwise) & of same dimension as the unit image.

Now if i multiply a texture of dimensions=unit image but color=player color with mask, i will get a black image with the player color present in the exact positions i want them in the unit image. Now how to superimpose this image on the unit image to get the player colors there as well?.

Anyone has a better idea on how to do this whole thing? i want masks of 1 bit depth only.How to store such masks in video memory so they occupy 1 bit depth only…textures have to be 8bpp at least i think

Yes, GPU is free to choose internal format of texture so even if you create 1-bit texture it will most likely be stored as 8-bit.

As for combining player image with masked player color I have two suggestions for you:

Put mask to alpha-only texture - when rendering use alpha blending or alpha test (or both):

glAlphaFunc(GL_GREATER, 0.01f);

Put mask to luminance only texture (this is what you currently do), and use the following blend function:

glBlendFunc(GL_ONE, GL_ONE);

Additionally, texture with player image should have black pixels where mask is white (it should be pre-multiplied by inverse of mask).

First solution will be faster if your players occupy lots of pixels on the screen since it skips invisible pixels using alpha test.