Team Colors

I’m doing a 2d game with teams.
how would I do team colors without loading the sprites again into memory with a different color?
probably some form of alpha blending / masking but I’m new to openGL and don’t know exactly how to do this.
I have many sprites with certain colors on them that need to change to different colors depending on which team that unit belongs to.

I’m currently doing it with the gl texture palette extension since I only cared that the program ran on my machine, but now I want to get it to work on machines other than geForce based systems.


This may be a terrible way to do it, but
you could simple use a base texture that was
white and load it with different (non-fullbright) rgb values. So, that if you wanted a blue team you could load your base texture using 0.0, 0.0, 1.0

This may not be a good way to handle it…

I can think of many ways to do what you want. However, the best way would seem to be dependent on the number of team colors that could be in use at any given time and the number of unique sprite frames. For example, if the maximum number of team colors is relatively small and fixed, then I would likely just use team specific sprites. On the otherhand, if the number of sprite frames is very large (on the order of 1 MB or more), then I would resort to a either a multipass or multitexture method. In the multipass method, you first draw the sprite to the depth buffer only using an alpha test to reject the sprite background. Then in the next pass, you draw the team color (a colored quad that is the size of the sprite) to only the color buffer using a depth function of equals. Then finally draw the sprite to the color buffer only, using an appropriate alpha blend function (so the team color shows through the translucent parts of the texture) and alpha test (to reject the sprite background). Also note that if an alpha buffer is available, the multipass method can be reduced to two passes. With multitexture hardware you can mix the team color with the base texture using the combine extension, and you’d only have to draw the sprite once.

[This message has been edited by DFrey (edited 06-17-2001).]

personally ild go with the unique texture for each team (if fiessable?) like Q3 does, more flexible. than with other aproaches the colour will be in the same spot for each team eg a team with red shirts + an identicle looking team with blue shirts. using diff textures u can give the red team a logo on the front of there shirts and the blue team some sort of headband for example

You could have one texture saved on disk, but multiple copies (with certain color changes) loaded into separate OpenGL texture objects.