🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Masking to show player color....problem.

Started by
0 comments, last by lc_overlord 17 years, 6 months ago
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
Advertisement
The best method is to use two textures, the first one is a regular RGBA texture and the other one is a RGB or luminance texture.
the first texture contains the unit texture but with the player color left dark
the second one is a gray version of the player color.

First render the unit texture normally or with regular alpha blending.
then set blending func to (GL_ONE, GL_ONE), set glColor to the player color and render the second texture over the first one.

I think it's possible to use as small as 4 bit textures, but i read somewhere that internally they get converted to RGBA textures.

This topic is closed to new replies.

Advertisement